Over the last few weeks, I focused on removing overhead from the request hot path in Django Bolt. The results from v0.6.4 → v0.7.0 are honestly better than I expected. I remember when I put 60k RPS in GitHub README because that was the maximum I was able to get from this. Now the same endpoint under the same condition achieves 160k RPS.

github.com/dj-bolt/django-bolt

Here is how I did it.

⚡ Removed logging-related extra work from the Python hot path

Every request was paying a logging tax multiple time.time() calls, duration calculations, and formatting. I was surprised when I found out that for primitive requests, the logging is taking 28 % of the overhead. Flamegraphs saved the day here. No access logging is run in Rust. It still logs properly, it just does not do extra work not needed.

⚡ Zero-copy response bodies

Using PyBackedBytes allows response bodies to move between Python and Rust without extra memory copies. We get a reference to bytes inside the Python part, and actix can read the reference and send the data without copying the full response into Rust.

⚡ Trivially-async detection

Some async def views never actually await. These are now detected at registration time and dispatched synchronously using `core.send()`. So we don't have to use Tokio machinery for trivial async functions.

⚡ Lower allocation overhead

Optional hashmaps and static response metadata eliminate several small heap allocations per request. Before, we were allocating empty dicts instead of `None`, which is much faster.

⚡ Pre-compiled response handlers

Response serialization logic is compiled once during route registration instead of running isinstance chains on every request.

https://github.com/dj-bolt/django-bolt

GitHub - dj-bolt/django-bolt: Rust-powered API framework for Django achieving 60k+ RPS. Uses Actix Web for HTTP, PyO3 for Python bridging, msgspec for serialization. Decorator-based routing with built-in auth and middleware.

Rust-powered API framework for Django achieving 60k+ RPS. Uses Actix Web for HTTP, PyO3 for Python bridging, msgspec for serialization. Decorator-based routing with built-in auth and middleware. - ...

GitHub

Hey @farhanaliraza great job on this new release of Django Bolt.👏

I suggest everyone to try it. 👍

#Django #DjangoBolt #Rust #Python

@paulox Thank you. Excited for it now.
@farhanaliraza I have just one question why not just use granian instead of the http server extra code?

@paulox For the asgi mount part ?
I tried using it but the granian code is coupled together. It can be by making granian a dependency. But it will still conflict because I have configuration for actix server for the main API part and granian for the asgi part .

So I just implemented bad version of granian 😅

@paulox @farhanaliraza this is super timely as I just began a new Django api personal project, can't wait to try it out
@moondog8 @paulox Great. Let me know of your experience.