9 ms·
Granian – a Rust HTTP server for Python applications
- Alifatisk 4y agoAny plans on implementing H3?
- _joel 4y agoFrom github > Have a single, correct HTTP implementation, supporting versions 1, 2 (and eventually 3)
- nethunters 4y agoLooking at the code it relies on Hyper which doesn't support H3 yet https://github.com/hyperium/hyper/issues/1818 https://github.com/hyperium/hyper/issues/1818
- gi0baro-dev 4y agoGranian maintainer here. As other people pointed out, the project relies on the Hyper Rust project, which at the moment doesn't support HTTP/3. Once the project will add support for this, will be implemented in Granian as well.
- djstein 4y agofor those wishing to use http3 with a Python web framework, the ASGI hypercorn[1] currently supports it. made a Django example last week with a sample client based on the examples from aioquic[2]: https://github.com/djstein/django-http3-example https://github.com/djstein/django-http3-example this example also includes the first pass at async Django REST Framework using adrf[3] based on these GitHub issues: - https://github.com/encode/django-rest-framework/pull/8617 https://github.com/encode/django-rest-framework/pull/8617 - https://github.com/encode/django-rest-framework/issues/8496 https://github.com/encode/django-rest-framework/issues/8496 sources [1]: https://github.com/pgjones/hypercorn https://github.com/pgjones/hypercorn [2]: https://github.com/aiortc/aioquic https://github.com/aiortc/aioquic [2]: https://github.com/em1208/adrf https://github.com/em1208/adrf
- Alifatisk 4y agoThat’s so cool, I have been looking around for something similar but in Ruby. Couldn’t find anything, just a talk about the possibility of implementing it.
- gi0baro-dev 4y agoTrue. The "bad" thing about hypercorn is its poor performance, at least for now :/
- TigerTeamX 4y agoLooks super interesting. One of the things that I wanted to improve on are Gunicorn's latency and here: https://github.com/emmett-framework/granian/tree/master/benchmarks https://github.com/emmett-framework/granian/tree/master/benc... shows way better latency for Granian. Kudos. just, when would you consider this good enough for production?
- ddorian43 4y agoNo comparison with uwsgi in the link.
- manfre 4y agoIt's unlikely for new projects to compare against uwsgi because "The project is in maintenance mode". https://uwsgi-docs.readthedocs.io/en/latest/ https://uwsgi-docs.readthedocs.io/en/latest/
- dangrie158 4y agoSo you mean feature complete and it only needs updates to fix bugs or security issues? Since it still is maintained (which is what maintenance mode means or not) why would you not include it in a comparison?
- InvaderFizz 4y agoI would guess that people see "maintenance mode" and think that means it's pretty much EoL and will no longer receive security patches in the near future. That is certainly the mental model I have for something in maintenance mode.
- Bjartr 4y agoTo me the whole point of saying "maintenance mode" is to tell people to only expect things like necessary security patches and critical bug fixes instead of new features. If those things aren't happening, then there isn't any maintenance going on.
- AMCMneCy 4y agoThere is a similar project https://github.com/sansyrox/robyn https://github.com/sansyrox/robyn A framework for Python, the core of which is written in Rust
- patrick91 4y agoyes, it was shared yesterday on HN ;) also this is more low-leven than Robyn, so I think it could be used to build other frameworks like Robyn
- Thaxll 4y agoIt looks like a wrapper arround hyper?
- giancarlostoro 4y agoMy first thought was "this better be WSGI!!!" and sure enough it is. If you're doing Python web development and you have no idea what WSGI or ASGI are, you really ought to learn more about them. ASGI is the Async equivalent / answer to WSGI. It is one of the main ways to deploy any web application in Python. Every major web framework supports it OOTB and heck, even one of the fastest web frameworks for Python (FastAPI) uses it exclusively. Thanks to WSGI you can have projects like this that focus on scaling out your Python web all to the fullest extent possible.
- nicolaslem 4y agoThis. There was recently a trendy thread on HN about how great CGI was. WSGI is basically one of the spiritual successors to CGI: it's a simple way for a web server and a Python application to interact. It addresses one of the major shortcomings of CGI by not requiring to launch a new process for every request. 20 years later it is still going strong and is still by far the main way Python web apps are served.
- assume_role 4y agoDo python mains not know what FastCGI or mod_python are?
- nicolaslem 4y agoWSGI and mod_wsgi were designed as an improvement over mod_python which was pretty much an Apache only thing. As for FastCGI, although it is language agnostic it didn't really get traction outside of PHP.
- uranusjr 4y agoWSGI (same for ASGI) is a level above FastCGI (or CGI or whatever) in the stack; it exists so each Python web framework does not need implement ways to talk to CGI, FastCGI or whatever. Instead the framework implements a Python function, and the user can choose a WSGI server to wrap this Python function into whatever is needed to talk to any kind of language-agnostic gateways, including CGI, FastCGI, or even mod_python.
- fortran77 4y agoPython comes with an HTTP server built-in! https://docs.python.org/3/library/http.server.html https://docs.python.org/3/library/http.server.html
- dangrie158 4y agoThis is a different scope aimed at hosting a production service. The Python included http Server is super useful but for completely different use cases.
- nicolaslem 4y agoThe standard lib equivalent would rather be wsgiref. https://docs.python.org/3/library/wsgiref.html https://docs.python.org/3/library/wsgiref.html
- cpach 4y agoYeah. AFAIK that one is not intended for prod.
- ultra_nick 4y agoCollaborating with Python/Web is a great way Rust to market itself.
- patrick91 4y agoalso for tool, see Ruff: https://github.com/charliermarsh/ruff https://github.com/charliermarsh/ruff (I'm a big fan!)
- grubby 4y ago+1 for ruff! the creator seems like a cool dude too
- linhns 4y agoOne of the best thing related to Python in recent years. Completely resolved the speed problem during linting that often keeps me away from using the language.
- WhyNotHugo 4y agoRuff very suddenly popped out of nowhere and re-implemented SO MANY development tools into one single codebase, all while making it stupid fast? I just came across it earlier today and it almost sounds too good to be true.
- ddejohn 4y agoVery cool. Sounds like a perfect fit for the Starlite framework, which is using Rust for route handling.
- kortex 4y agoCan anyone give a quick synopsis of why this RSGI is needed? Can't ASGI code be called from a Rust socket termination, a la Gunicorn?
- gi0baro-dev 4y agoIs not needed, is just a different async protocol implementation. Granian supports both interfaces, is a matter of how you want to write your application. As you can see from benchmakrs (https://github.com/emmett-framework/granian/tree/master/benchmarks#interfaces https://github.com/emmett-framework/granian/tree/master/benc...), the main advantage today of RSGI vs ASGI is the performance.
- gdcbe 4y agoSerious question: why would I want to use this? Is the answer as simple as “because I want to develop in Python”?. Because if you’re going to do it in Rust, why not just go all the way with something like Axum? That being said, first time I hear about WSGI/ASGI, so I did some reading. From an educational perspective I’m intrigued and even will check the codebases at some point to see how it works. But from a production POV I do not get why I would want to use it. What’s so great about it - besides letting you develop a reasonably fast server in Python, surely it is more then that?
- connicpu 4y agoGranian is more of a web server for python that just happens to be implemented in Rust. Python developers using Granian wouldn't need to know or write any Rust, just like they don't need to know or write any C in order to use python modules that just happen to have C components to make them faster. The module containing substantial Rust code is merely an implementation detail.
- woile 4y agoTheoretically, an asgi server sits in front of your fastapi or starlette. This asgi servers are usually written in python (maybe calling some c code underneath). You can "probably" gain some performance by writing the asgi server in rust. I don't know how much better is this.
- gi0baro-dev 4y agoYou can check benchmarks https://github.com/emmett-framework/granian/tree/v0.2.2/benchmarks#vs-3rd-parties https://github.com/emmett-framework/granian/tree/v0.2.2/benc... ;)
- simonw 4y ago"What’s so great about it - besides letting you develop a reasonably fast server in Python, surely it is more then that?" Sounds to me like you've figured out the reason for this project just fine!
- dahateb 4y agoInteresting project. Would it be able to run a fastapi project just like uvicorn in production?
- gi0baro-dev 4y agoYup: `granian --interface asgi your_module:your_fastapi_app`