Can Python Handle Millions of Requests per Second? Inside Japronto’s High‑Performance Microframework
This article explores recent Python performance improvements, benchmarks a new microframework called Japronto that can process over a million HTTP requests per second using techniques like HTTP pipelining, C extensions, and careful memory management, and outlines its features and future directions.
Python’s performance has improved dramatically: CPython 3.6 introduced a new dictionary implementation, and CPython 3.7 added faster call rules and dictionary lookup caching. PyPy’s JIT compiler and NumPy’s C‑extension compatibility further boost scientific workloads.
Inspired by these advances, the author focused on web and micro‑service development and discovered Japronto, a brand‑new microframework designed for speed, scalability, and lightweight operation. Leveraging asyncio, Japronto claims to be faster than both NodeJS and Go.
Benchmark tests on an AWS EC2 c4.2xlarge instance (8 vCPUs, Xeon E5‑2666 v3 @ 2.90 GHz, Ubuntu 16.04.1, Python 3.6 compiled from source) used the wrk tool with 1 thread, 100 connections, and 24 requests per connection (total concurrency 2400). The results showed Japronto achieving 1,214,440 requests per second, surpassing many other servers.
Japronto fully supports HTTP 1.x, including request pipelining. By processing a batch of pipelined GET requests in a single system call, it reduces kernel‑user space transitions and minimizes the overhead of multiple syscalls. The framework also employs scatter/gather I/O (though not yet fully utilized) and strives to keep object allocation low, reusing memory blocks aligned to 4 KB boundaries.
Key implementation details include:
Core components written in C (parser, protocol handling, connection management, routing, request/response objects).
Lazy loading of protocol headers and other objects to avoid unnecessary allocations.
Use of the ultra‑fast picohttpparser library, which exploits SSE4.2 instructions for rapid HTTP token matching.
Integration with uvloop, a libuv‑based event loop that relies on epoll for asynchronous I/O.
Additional optimizations such as minimizing cache‑line invalidations, avoiding circular references, and careful memory reuse contribute to the high throughput.
Japronto’s feature set includes HTTP 1.x with chunked uploads, full HTTP pipelining support, configurable keep‑alive, synchronous and asynchronous views, master‑multiworker processing, hot code reloading, and a simple routing syntax.
The author invites contributors to help with documentation, testing, and future work on WebSockets and asynchronous HTTP response streams.
While the techniques described are applicable to other languages (Ruby, JavaScript, PHP), the author notes that further development requires community support.
Images illustrating performance comparisons, HTTP pipelining, and the picohttpparser architecture are included below:
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
