Throughput is a measure of the number of requests that can be fulfilled in a given time interval.
The throughput of a system depends on several factors:
- Network Latency: The amount of time it takes for the message to get from the client to our application, as well as between different components of the application
- Performance: The computation speed of the program itself
- Parallelism: Whether requests can be processed in parallel
We can increase throughput using the following strategies:
- Deploying our application geographically close to the client: Generally, this reduces the number of hops that a request must make through proxy servers, and thus reduces network latency. We should also deploy components that depend on each other close together, preferably within the same data center. This also reduces network latency.
- Ensure servers have sufficient resources: This makes sure that the CPU on your servers are sufficiently fast, and that the servers have enough memory to perform their tasks without having to use swap memory.
- Deploy multiple instances of an application behind a load balancer: This allows multiple requests to the application to be processed at the same time.
- Ensure your application code is non-blocking: JavaScript is an asynchronous language. If you write synchronous, blocking code, it will prevent other operations from executing while you wait for the synchronous operation to complete.