CHAPTER 7Production-Ready HTTP Servers
In this chapter, you will learn about techniques to improve the robustness and stability of HTTP server applications. You will learn how to implement time-outs at various points of your server's request handling life cycle, abort request processing to preserve server resources, and implement graceful shutdowns. Finally, you will learn how to configure your HTTP server so that there is a secure communication channel between a client and your server. Let's get started!
Aborting Request Handling
Consider a specific functionality that your web application provides—say, allowing the user to perform a search over a large dataset based on certain parameters. Before you made this feature available to the users, you performed extensive testing and found out that a search request completes within 500 milliseconds for all of your test scenarios. However, once users started making use of the feature in their applications, you found that, for certain search criteria, the requests may take up to 30 seconds to be completed, sometimes without success. What's worse is that the same search would complete successfully within 500 milliseconds when retried. You are now concerned that this may result in your application being exploited, as multiple such requests can make it incapable of serving any request—operating system resources are finite— open file descriptors, memory, and so on. Sounds familiar? This is how denial of service (DoS) attacks are accomplished! ...
Get Practical Go now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.