Chapter 61. Do More with Less
Ivan Krnić
Cloud infrastructure introduces many benefits, such as elastic scaling, immutable deployments, and a pay-as-you-go pricing model. Pay-as-you-go is a huge advantage since we’re paying only for what we’re actually using, but also a liability if our applications are not as efficient as possible. It’s not that we didn’t want our applications to be efficient before the cloud—it’s just that the pay-as-you-go model has made this even more important, since cloud usage is billed by actual resource usage.
The traditional client/server programming model relies on a thread pool. Whenever a client makes a request to the server, one thread from the server’s thread pool is dedicated to processing that request. If that request processing includes a blocking call to an external resource, the whole thread is idling until that call is finished. Because one thread is dedicated to each client request, if there are more concurrent client requests than threads in the pool, excess client requests will be dropped. To increase the application capacity, we need to either increase the size of the thread pool or scale the application. In the former case, we’re increasing memory usage. In the latter, we’re also increasing the CPU usage. Both actions seriously impact cloud usage and are reflected in the pay-as-you-go pricing.
A better ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access