A web application's throughput is dependent on the number of concurrent requests it can serve as well as how quickly it can serve each of these requests. An application will be able to handle most web requests very quickly and move on to serving the next request. However, what happens if a single request takes 10, 20, or even 30 seconds to complete? The Unicorn worker processing that request will be unable to take on another one until its current long-running request is complete. Under normal traffic, this would probably be fine. Another Unicorn worker will pick up the incoming requests, but it becomes a problem when an application needs to be processing a high number of requests very quickly.
In this recipe, we will learn how to timeout long-running requests to keep them from tying up resources and hurting our application's throughput.