4 ms·
Would anyone recommend using Julia for things like web servers? Python is used for web servers, and is slow. But Julia doesn’t really seem marketed to that appl
by hellofunk 8y ago
Would anyone recommend using Julia for things like web servers? Python is used for web servers, and is slow. But Julia doesn’t really seem marketed to that application domain, despite that I would expect it to do a better job with the demands on a server due to its performance.
I know web frameworks exist for Julia, but I’m wondering how practical it is to actually use this language for that purpose?
- goatlover 8y agoIf your only requirement is performance, then you'd probably be better off using Go or Node. My guess is you would use Julia for a web server when it ties into other things you're using Julia for. But maybe I'm wrong here. It seems that "use the right tool" turns into use Python or JS or Excel for all the things.
- oblio 8y agoI guess you’re not up to date: Excel is getting JS scripting soon and most likely Python scripting not long after that :D
- goatlover 8y agoHaha, well then! World conquest is surely right around the corner with that combo. Maybe allow for some Rust plugins and have it run on blockchain, just to be on safe side.
- eigenspace 8y agoI'm not knowledgeable on this topic at all, but I can tell that the bulk of julia development hasn't involved a lot of thought towards web technologies. So I wouldn't be surprised to learn that the infrastructure just isn't really there to support web servers well in julia. That said, my personal favourite thing about julia is not actually its speed but the fact that it's an incredibly expressive, flexible and composable language (I'd say julia learned all the mot important lessons lisp had to teach). If I had to guess, I'd think that building the infrastructure for devs to work on web servers from the ground up may very well be easier in julia than in most other langauges, including python. I may be off the mark though. One other note since it was mentioned elsewhere, there actually is work being done right now to have julia compile to WebAssembly code which could be pretty cool!
- st1ck 8y agoIt'd make sense for numerical computations. Otherwise, there are like 10 faster-than-Python languages I'd consider instead of Julia (incl. Erlang/Elixir, Go, Rust, Java/Scala, Haskell).
- rz2k 8y agoI remember reading some posts early on, either on Reddit or in the mailing list, where people asked about its suitability for web frameworks and servers. The idea was that what it let you abstract away, and what it made easy to do at a low level would work well in that problem space, too. However, it was pretty actively discouraged. I suspect they didn't want a lot of voices influencing the direction of the language while it was still being formed. A lot of what make R a poor general purpose language help make it effective in its specific domain for its specific users. It might be worth people taking another look at it after 1.0 is released, as long as they have low expectations about influencing the direction of the language's development.
- wenc 8y ago> Python is used for web servers, and is slow What is the specific context for this? Serving concurrent users? Or raw processing? If it's the former, there are ways around this. If you'd like to replace Python for this, I'd look at something like Go rather than Julia. If it's the latter, Julia might help, but there are a bunch of tradeoffs to consider. Julia is a language that was primarily designed for numerical computation.
- ffriend 8y agoAlmost certainly yes. Although it doesn't mean it's the best choice for your specific task. Python had a long history of web server development. I think, aiohttp may be considered state of the art now. Let's measure its performance: from aiohttp import web async def handle(request): return web.Response(text="Hello") app = web.Application() app.add_routes([web.get('/', handle),]) web.run_app(app) using `wrk` for testing: $ wrk -t1 -c1000 -d30s http://127.0.0.1:8080/ Running 30s test @ http://127.0.0.1:8080/ 1 threads and 1000 connections Thread Stats Avg Stdev Max +/- Stdev Latency 164.59ms 17.12ms 537.35ms 83.97% Req/Sec 6.05k 0.95k 7.74k 74.33% 180749 requests in 30.08s, 26.72MB read Requests/sec: 6008.75 Transfer/sec: 0.89MB So we have ~6k rps on a single CPU core. As far as I remember, Tornado has ~4k rps, while built-in Flask server can process only about ~1k requests per second . Yes, you are unlikely to use Flask dev server in production, but for aiohttp it's indeed a recommended way. Now let's measure Julia's HTTP.jl server: using HTTP HTTP.listen() do request::HTTP.Request return HTTP.Response("Hello") end which gives: $ wrk -t1 -c1000 -d30s http://127.0.0.1:8081/ Running 30s test @ http://127.0.0.1:8081/ 1 threads and 1000 connections Thread Stats Avg Stdev Max +/- Stdev Latency 105.95ms 108.35ms 1.99s 98.40% Req/Sec 9.65k 1.69k 13.66k 80.21% 271917 requests in 30.09s, 16.10MB read Socket errors: connect 0, read 0, write 0, timeout 274 Requests/sec: 9035.73 Transfer/sec: 547.67KB So it's 9k (with a few failed requests though). This doesn't include any routing, input data parsing, header or cookie processing, etc., but it amazes me how good the server is given that web development is NOT considered a strong part of the language. The downside of Julia web programming is the number of libraries and tools (e.g. routers, DB connectors, template engines, etc.) - they exist, but are quite behind Python equivalents, so gotchas are expected. Yet I'm quite positive about future of web programming in Julia.