Show HN: Robyn – “Batman Inspired” Python Web Framework Built with Rust
robyn.tech
robyn.tech
At some places where there were no better alternatives, framework utilizes sync functions under the hood, such as some databases.
Overall there are also places where functions are async running in sync bodies, but they're not running on main thread.
asyncio.to_thread[0] as a quick workaround, just keep track of your thread count. Obviously frameworks and libraries with asyncio support should be chosen whenever possible.
> Overall there are also places where functions are async running in sync bodies, but they're not running on main thread.
That would be a design mistake, as functions have colors[1] with async/await. That's currently my biggest gripe in the python ecosystem, apart from modules maintaining their own hidden state.
[0]: https://docs.python.org/3/library/asyncio-task.html#asyncio....
[1]: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...
In general I assume disk I/O is slow enough (even on SSD) to care about blocking the event loop and delegating the calls to a thread. But I've been wrong about this before. For example, a call to stat is technically blocking, but the overhead of delegating it to a thread is actually more expensive (on my Framework 13) and blocks the loop longer than just doing the call outright in the main thread.
The examples look very similar to Fast API and the requests per second comparisons make Robyn look very speedy![0]
I'm sure the developer has more of a vision than just "faster fast api" though - would love to hear more!
Developer has been working on this project for a few years now, here is the updated roadmap, shared by the developer and maintainer of the project.[2]
- doesn't require any external ASGI in Prod
- has in-built CORS
- Rust runtime
in my opinion
- FastAPI has built-in CORS. Has for years. I don't remember it ever not having.
I don't see how Robyn is faster for development and prototyping.
Can't speak for Robyn author, but in my opinion it's not a valid comparison. The only thing Granian and Robyn have in common is the usage of Rust and PyO3, but that would be like comparing two projects using Cython.
Granian is just a server, and as such it is comparable to projects like uvicorn, Daphne, hypercorn, gunicorn, uwsgi. It can be used to run any WSGI or ASGI application out there. Robyn is a web framework, and thus it does a lot more than Granian, and as such it can be compared to other async first web frameworks, like starlette, litestar, sanic, quart, Emmett, blacksheep.
If we're talking about performance then.. well it's still Python running the app code. There's no way to escape that. If we're talking about features, ergonomics, etc. then again, Granian is just a server, so there's not so much to talk about :)
It is not comparable to Django.
The global request object, the bad integration with sqlalchemy, the strong coupling with an application object that forced the indirection of blueprints...
If you start again from scratch, forcing people to migrate their stack and therefor leave their ecosystem behind, at least fix the glaring API problems.
[0] https://www.techempower.com/benchmarks/#hw=ph&test=plaintext...
[1] https://robyn.tech/documentation/en/api_reference/const_requ...
[0] https://flet.dev
[0] https://github.com/sparckles/Robyn says 50% Python, 25.3% JS, 20.7% Rust — but all the JS code seems to be for their docs site, so it is reasonable to say 20.7 / 70.7 = 29.2% is in Rust.
https://robyn.tech/documentation/en/api_reference/advanced_f...
Once you know and rewatch it you see all these subtle clues along the way.
Hence the event loop in Rust runtime for async makes more sense here.
Async is all about cooperative concurrency where a task yields in places that it would normally block. The tasks can all run in a single thread.
However, my experience is that this isn’t always the case. My company has a medium-large Python web app in production, and having viewed performance profiles, I can say definitively that Python code execution occupies a non-trivial amount of processing time. Of course the single largest time sink is the LLM requests we make, but if we could magically nullify the Python processing time, our latency would significantly improve.
The culprit in this case may be specific to FastAPI and Pydantic rather than Python generally, but the point still holds that not all web frameworks and resultant apps are equivalent.
That said, I’ve been dreaming of rewriting large chunks of it in golang. I’ve always known Python was relatively slower than other languages, but I saw a recent benchmark measuring golang as 50x faster than Python. Perhaps the benchmark won’t translate to real world performance, but still - 50x is difficult to ignore.