Hosting Web Apps in Julia

package
#43

Sounds great. I got the plot margins fixed up, so now it’s looking great.

I’ll keep tweaking this, but we should take this to the issues on the repositories now. I think that the JuliaWebAPI is great and very easy to use. I’ll chat around and see if we can get any help hosting this, but please take your time: we are in no rush here (but it is super cool).

However, if others have alternative solutions, feel free to share.

#44

It’s possible to use heroku:

There is also the Julia Openshift Cartridge:

Which is operating in this direction:
http://julia-tareaito.rhcloud.com/

2 Likes
#45

I googled for status:

Found also:


"Have you heard the good word? Rust can now target asm.js and WebAssembly (wasm) via
emscripten." [Note, below in Rust 1.14, said to be “experimental”.]

And; didn’t look into:


"Everything works"

Rest is not directly related to [only[ web/Julia, just interesting, and might be an indirect way to target the web or compiling to assembly in general:

http://notes.willcrichton.net/rust-the-new-llvm/
“Rust compiles to LLVM” [but stated other way around better] “Rust in this kind of ecosystem offers five primary advantages over LLVM:”

[and disadvanages]

“2. The story for dynamic languages needs refinement. Specifically, it needs a battle-hardened GC (as far as I know, there’s really only one major attempt so far).” [rust-gc]

“To my knowledge, Lia is the first major language that actually compiles directly to Rust.”

[competitor to Julia?]


"Lia is a dynamically typed and garbage collected programming language that seamlessly interopts with Rust by using Rust as a compile target."

one advantage, not for web…, just released Rust 1.14 has over Julia (LLVM?):

“MIPS
and
s390x-unknown-linux-gnu”

Didn’t look into new MIR for Rust, or if it’s an alternative compiler target:

Julia static compilation
#46

Not sure what you mean, are you answering

  1. as you want Julia compiled to JS, or just work in a browser? Escher already makes JS for you (you do not have to write it is CSS or HTML, as far as I understood). It’s just not arbitrary JS generated from Julia.

  2. or asking about “server backend”? It has that, but not a possibility of a separate, e.g. Apache as Genie.jl does.

#47

The JS still has to be dynamically generated at the server and sent back.

#48

For anyone who is curious about where this has ended up, here’s the application:

http://app.juliadiffeq.org/

and here’s a blog post about it:

7 Likes
Catering for non-coders
#49

This is awesome, @ChrisRackauckas. I’ll definitely look back on this as a reference if I need to host Julia computation in the future. Thanks for the great project and writeup!

#50

This is really good. Thank you.

I’d like however to add one perspective I suspect a lot of non-technical people would share:

Being able to build a webapp for your package is a very attractive feature. It would be very useful to have some bare-bones, ultra simple, dumbed-down tutorial that includes some but not all of the components from this project. Maybe a simple sin plot with some input from the user?

My point is that there are scores of scientists that built some cool package they’d like to share in the form of a webapp, but very few of them built a webapp before. They (read: me) don’t know much about the terminology and parts involved in building and deploying a webapp. While this project demonstrates how this can be done, its level of complexity prevents these users from replicating it.

Imagine a template where the user could just replace the sin function with her own, adding or subtracting simple features, and following dumbed-down instructions on how to deploy it all on some standard server (e.g. aws). THAT would elevate the functionality of this effort tremendously!

6 Likes
Plots.jl but for GUI
Catering for non-coders
#51

+1 to this. It’s the case for me as well but I guess it’s pretty general in research environments. My overall feeling is that for simple stuff the (amazing) package Interact.jl can take care of all the interactivity, without needing to know anything about web programming (javascript html etc…). As soon as it gets more complicated than that it’s not so clear how to proceed. Escher.jl seemed ideal but it doesn’t seem recommended anymore. I could really use a tutorial on “build a webapp for dummies”.

2 Likes
#52

I’ve been planning a package to do just this, and will try to have a minimal working package with a lot of documentation within the next week and a half. My eventual goal is that you should be able to call a single function like

microservice("my_fn",  (x, y) -> x + 2*y)

and then be able to go to http://some.url/my_fn#?x=2?y=2 to get a JSON representation of the output. Doing this for base will be easy, but making it adaptable enough to work for arbitrary packages will be tricky.

4 Likes
#53

Here is the example on the REPL using Bukdu.

To get the master branch by
Pkg.clone("https://github.com/wookay/Bukdu.jl")

julia> importall Bukdu

julia> type CalculateController <: ApplicationController
           conn::Conn
       end

julia> function my_fn(c::CalculateController)
           q = c[:query_params]
           x, y = map(v -> parse(Int, v), (q[:x], q[:y]))
           render(JSON, x + 2*y)
       end
my_fn (generic function with 1 method)

julia> Router() do
           get("/my_fn", CalculateController, my_fn)
       end

julia> Bukdu.start(8080)
INFO  Listening on http://127.0.0.1:8080

Now you can request as
http://127.0.0.1:8080/my_fn?x=2&y=3

thanks.

2 Likes
#54

Looks great!

I would like to see that example in the repo somewhere. From the repo example in the README, I cannot see how one would do such a request.

Bukdu can be deployed on Heroku. Go to the demo site (https://bukdu.herokuapp.com).

It would be more helpful to give a step by step for this. The deployment part is tricky, and you already found out how to do it!

1 Like
#55

I’m also looking for azure hosting instructions. Anyone know if the Data Science VM can be used out of the box for this purpose?

#56

I’m thinking of a better way such as having conn::Conn in the controller.
would you mind post an issue to the Bukdu repository.
thanks!

#57

@yakir12 – A general method of deploying an API from within a notebook or the REPL will take a while longer, but https://github.com/amellnik/JuliaHerokuEndpoint now has a minimal but functional example as well as fairly detailed descriptions. If you have any trouble or if the instructions are unclear at any point please file and issue there and I would be glad to help.

2 Likes
#58

OMG, thank you! Awesome, I’ve booked off all next week to play around with this. Thanks!

#59

Some very nice code and documentation in this thread.

For completeness, I will point out JuliaWebAPI.jl which allows you to expose any Julia function via ZMQ or HTTP transports. It’s a small but robust codebase, and has been used in production for many years.

Regards

Avik

1 Like
#60

This is awesome! Thanks again!

1 Like
#61

Just to provide another example of deploying a Julia web app, here’s my project: https://github.com/markhalonen/sauna-sim

I used Joseki for my simple JSON api with a couple GET endpoints, worked great.

I hosted on AWS ec2 after failing to get my project working on AWS Lambda or Heroku.

More details in my blog post: https://medium.com/@markhalonen/deploying-julia-1eb8a1686ca1

12 Likes
#62

Very nice post!

BTW, from what I’ve heard, AWS Lambda could work if you

  1. Download and install Julia when the lambda function is first invoked. This is done to work around the 250 MB limit.

  2. Keep it warm by calling the lambda function regularly. This is done to avoid the first hit performance issue, which is not specific to Julia but rather an artifact of the current lambda service.

Another option is to deploy Julia and your app as a Docker image and deploy it on AWS Fargate. I haven’t tried but I can imagine that it should work.