# ASGI equivalent in Julia for High performance?

**URL:** <https://discourse.julialang.org/t/asgi-equivalent-in-julia-for-high-performance/69809>\
**Category:** Web Stack\
**Created:** [October 15, 2021, 8:08am UTC](https://discourse.julialang.org/t/asgi-equivalent-in-julia-for-high-performance/69809 "2021-10-15T08:08:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mks/32/18374_2.png) [@mks](https://discourse.julialang.org/u/mks)\
**Post date:** [October 15, 2021, 8:08am UTC](https://discourse.julialang.org/t/asgi-equivalent-in-julia-for-high-performance/69809/1 "2021-10-15T08:08:16Z")

</div>

Hello,

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?

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [October 15, 2021, 2:52pm UTC](https://discourse.julialang.org/t/asgi-equivalent-in-julia-for-high-performance/69809/2 "2021-10-15T14:52:59Z")

</div>

Aren’t all those trying to work around the Python GIL problem?

---

<div class="post-metadata">

**Author:** ![mks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mks/32/18374_2.png) [@mks](https://discourse.julialang.org/u/mks)\
**Post date:** [October 15, 2021, 3:34pm UTC](https://discourse.julialang.org/t/asgi-equivalent-in-julia-for-high-performance/69809/3 "2021-10-15T15:34:52Z")

</div>

ASGI is the asynchronous version of WSGI (Flask) which is well explained here: [HOWTO Use Python in the web — Python 2.7.18 documentation](https://docs.python.org/2/howto/webservers.html#step-back-wsgi)

I cannot explain it so elaborated, hence I’d like to cyte Clark E. Evans from another discussion here:

So we have:

> [Multi-Threading · The Julia Language](https://docs.julialang.org/en/v1/manual/multi-threading/#Starting-Julia-with-multiple-threads)  
> By default, Julia starts up with a single thread of execution. This can be verified by using the command [`Threads.nthreads()`](https://docs.julialang.org/en/v1/base/multi-threading/#Base.Threads.nthreads):

```julia
julia> Threads.nthreads()
1

```

Lets start Julia with 4 threads:

```julia
$ julia --threads 4

```

[https://docs.julialang.org/en/v1/base/parallel/#Tasks](https://docs.julialang.org/en/v1/base/parallel/#Tasks)

By default, Tasks are coroutines.

> <https://github.com/tanmaykm/FastCGI.jl/blob/master/src/bufferedoutput.jl#L11>

> 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](https://asgi.readthedocs.io/en/latest/#) 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.

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [October 15, 2021, 7:24pm UTC](https://discourse.julialang.org/t/asgi-equivalent-in-julia-for-high-performance/69809/4 "2021-10-15T19:24:35Z")

</div>

Thanks. I do all my web work in Go, but I’m interested in starting to do some in Julia, and it’s good to where there may be limitations.

---

<div class="post-metadata">

**Author:** ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)\
**Post date:** [November 16, 2021, 1:44pm UTC](https://discourse.julialang.org/t/asgi-equivalent-in-julia-for-high-performance/69809/5 "2021-11-16T13:44:08Z")

</div>

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.

And Java.

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.
