Why slow responses are the worst

As we learned from Socket-Based Protocols in previous chapters, generating a slow response is worse than refusing a connection or returning an error, particularly in the context of middle-layer services. A quick failure allows the calling system to finish processing the transaction rapidly. Whether that is ultimately a success or a failure depends on the application logic. A slow response, on the other hand, ties up resources in the calling system and the called system.

How slow responses occur

Slow responses usually result from excessive demand. When all available request handlers are already working, there’s no slack to accept new requests. Slow responses can also happen as a symptom of some underlying problem. Memory leaks often manifest via slow responses as the virtual machine works harder and harder to reclaim enough space to process a transaction. This will appear as a high CPU utilization, but it is all due to garbage collection, not work on the transactions themselves.

Get hands-on with 1400+ tech skills courses.