I wonder if there will be more work on an ASGI Framework equivalent in Julia. I see all the recent Python webframeworks use ASGI, like FastAPI, Scarlette or Quart. How come we do not see this in Julia?
FastCGI appears to be the underlying tech of ASGI Frameworks in Python.
There is FastCGI.jl, but it doesn’t get so much attention it seems. Afaik HTTP.jl is not made this way, but it may be on the roadmap?
If you have a long-running request, you really should @yield occasionally if you want your server to be responsive. It seems that the lower-level FastCGI code is yeilding the active task while waiting for sockets.
The TLDR; so long as you’re not writing any long-running responses, you can probably just ignore this all and it’ll work just fine. Lower-level libraries will yield as needed. A corollary is that when ever you interact with the database, read/write to a file, or write data to a socket, another task might be scheduled to run. You have to be careful thinking about the libraries you use that do IO.
The benefit of using HTTP’s Request is that it builds a complete response string before sending it to the socket, avoiding an unexpected interruption in processing.
So, in the Python world, there is ASGI Documentation — ASGI 3.0 documentation which could be used by all sorts of backend implementations. The Julia community has not contemplated an “API” for web programming, but it might benefit them to emulate something like ASGI. This is based upon a “coroutine” based assumption rather than preemptive multi-tasking.
FastCGI is not related to Python and has absolutely nothing to do with the GIL.
FastCGI is just a way for long lived processes to remain live between Web requests such that Web requests don’t pay the startup penalty over and over.
Which makes it a suitable partner for Julia.
It also made it a good partner for Python which also suffers from startup costs.
It also means you don’t need to build an entire web serving mechanism, battle hardened on the live internet instead of rolling one yourself and then forgetting about CSRF and huge headers, and 10Mb data urls etc. being thrown at you.