Boost Server Throughput: From Blocking I/O to NIO and Asynchronous Models
This article uses a bank workflow analogy to compare blocking I/O (BIO), non‑blocking I/O (NIO), and asynchronous processing, showing how task decomposition and specialized threads dramatically increase system throughput while illustrating the trade‑offs of each approach.
1. Blocking I/O (BIO)
When a customer arrives, a single employee handles the entire four‑step process (form filling, verification, security retrieval, and receipt printing). With ten employees, each can serve one customer at a time, processing 6 customers per hour each, for a total of 60 customers per hour. The first step often leaves employees idle, illustrating the inefficiency of a pure BIO model where each request occupies a dedicated thread.
2. Non‑blocking I/O (NIO)
To improve throughput, the bank assigns one employee (A) to collect forms and then distributes completed forms to the remaining nine employees for the subsequent steps. Assuming a large number of customers, employee A becomes saturated, while the nine workers each handle a customer in 5 minutes, processing 108 customers per hour. This division of labor mirrors the NIO architecture: a main reactor accepts connections and delegates them to sub‑reactors (or a thread pool) that perform I/O, while worker threads handle business logic.
3. Asynchronous Model
The third step (security retrieval) still causes a 3‑minute wait. By assigning a dedicated employee B to handle this step, the counter staff can immediately move to the next customer after step two, while B retrieves the cash and notifies the customer when it’s ready. This reduces the counter’s idle time and raises throughput to 240 customers per hour (8 staff handling a 2‑minute step).
In modern web services, the third step corresponds to remote calls (e.g., RPC or HTTP). Using asynchronous techniques, such as Jetty Continuations, can dramatically lower resource usage and increase overall throughput, though it may not reduce individual request latency.
4. Summary
The key takeaway is “divide and conquer”: split tasks and assign specialized workers to each part. This principle improves performance not only in computing but also in broader organizational contexts.
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.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
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.
