Coder Social home page Coder Social logo

ASGI support about aiohttp HOT 4 OPEN

FeldrinH avatar FeldrinH commented on May 20, 2024
ASGI support

from aiohttp.

Comments (4)

Dreamsorcerer avatar Dreamsorcerer commented on May 20, 2024

There may also be some performance benefits to ASGI over WSGI, but I don't know enough about the internals of how aiohttp interfaces with WSGI to make specific claims about this.

We don't support either... (a quick search suggests it wouldn't even be possible to support WSGI as it's sync only). The discussion you linked to Andrew even says that performance may be lower with ASGI: #2902 (comment) #2902 (comment)

I think, as per those previous discussions, I don't see any major advantages to implementing this, and so I doubt anyone here will want to invest time into it. However, if someone wants to give it a go, we'll consider merging it. If the integration is a simple as the attempt in 2017, then it looks reasonable: https://github.com/aio-libs/aiohttp/pull/2035/files
(I suspect though, that it will result in losing some features and creating some compatibility issues...)

from aiohttp.

FeldrinH avatar FeldrinH commented on May 20, 2024

We don't support either... (a quick search suggests it wouldn't even be possible to support WSGI as it's sync only).

I might have misunderstood something then. I noticed that aiohttp supports Gunicorn (https://docs.aiohttp.org/en/stable/deployment.html#nginx-gunicorn) and assumed that since Gunicorn is a WSGI server aiohttp somehow uses (or abuses) WSGI to communicate with Gunicorn.

from aiohttp.

Dreamsorcerer avatar Dreamsorcerer commented on May 20, 2024

OK, Gunicorn integration is it's own thing: https://github.com/aio-libs/aiohttp/blob/master/aiohttp/worker.py
I'm not familiar with how Gunicorn works. Though that code looks like it still sets up the usual runner/server, so I don't see how it'd be integrating with WSGI (maybe it's able to use Gunicorn as some kind of worker manager without the WSGI integration?).

from aiohttp.

webknjaz avatar webknjaz commented on May 20, 2024

Yes, the docs compare it with supervisord. I think it just let's one have parallelism through multiple processes.
There's no WSGI because those standards were created way before asyncio was a thing (PEP 333 — 2003 / PEP 3333 — 2010). The HTTP servers would load WSGI importables once (per process) and keep calling them for each request. They would take care of parsing HTTP and the WSGI frameworks would be able to focus on the application logic. These servers with WSGI interfaces are usually written in compiled languages (Apache, nginx etc) and so their HTTP parsers are more performant than the pure-python ones. It made sense not to have the HTTP server part written in Python (though, such projects exist too — Cheroot, waitress to name a few).

My understanding is that ASGI is an attempt to reinvent it for async interfaces. However, aiohttp's HTTP parser is a C-extension so perhaps that's the reason Andrew thought it would have a performance hit for aiohttp-based apps — because of an extra layer of indirection and having our parser replaced with a potentially slower one. Note that it was when we were relying on the different underlying parser implementation and things may be slightly different post migration to llhttp, but I wouldn't expect it to be noticeable.

Whoever ends up working with this should also make and document a performance comparison. I'm not necessarily against the implementation, provided it isn't contributed in a way that brings a lot of maintenance burden. It'd also have to be fully covered with tests.

from aiohttp.

Related Issues (20)

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.