Giter Club home page Giter Club logo

julia-webserver's Introduction

julia-webserver

An example Julia webserver configuration which can be hosted on services such as Render or Fly.io This example is very basic, it allows you to create super fast servers for very specific purposes. If you prefer a fully fledged Model View Controller (MVC) application, then take a look at Genie.jl.

MyApp

This example repository works as follows. Let's say that we create an app called MyApp. The source code for the app is located in src/MyApp.jl. To be able to run it quickly, we need to use PackageCompiler.jl to compile packages. Otherwise, it might take 10 seconds or more for the server to start responding after a server restart which is not acceptable for a microservice. The power of microservices is that they can quickly be restarted. Okay, so how much do we compile? We could choose to compile all dependencies, but that would mean that everything needs to be re-compiled once our app changes. So, as a trade off, this example repository compiles only the dependencies of MyApp. This should be quick enough for most cases. As a side-note, to speed up the app itself once that is necessary, run the app's code when the module is loaded. This will cause some of the MyApp code to be covered by the precompilation and can take about 50% from the running time. See, also Makie.jl/src/precompiles.jl.

Anyway, back to the code. The Dockerfile shows how the docker is created. The file creates the sysimage and configures a starting point to start the server. Here, build-sysimage.jl will compile all direct dependencies of MyApp and run scripts/precompile-execution.jl. In the execution file, a HTTP server is started and closed again. Running such a simple server causes much of the HTTP.jl code to be compiled which greatly reduces the time to first response.

To deploy this code on Render.com, copy this repository and link it to your Render account. After about 10 minutes of building a Docker container, Render will run this example server online. You can then visit the site and see a webpage. If you push changes to MyApp, they will be visible within a few minutes.

Instructions for Fly.io are similar.

julia-webserver's People

Contributors

rikhuijzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dayitachaudhuri

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.