The effect of network latency on the performance of Apache pre-fork web server model

Web server performance is a complex topic, involving many variables. When thinking of the variables that affect how a web server performs normally the following come to mind:

  • Database
  • CPU
  • Memory
  • Disk

But one thing that is not mentioned most often is the affect of network latency on the performance of the application.

How network latency can impact the application performance?

When a client makes a request to your web server, the data packets have to travel from the across the Internet to your web server and then all the way back. Now there is an OS defined limit on the amount of data that can be sent over a TCP socket at a single time. If the amount of data to be sent is more than this limit, then the web server has to wait until the data has been delivered to the remote client. The effect of this phenomenon is that in addition to the time spent processing the client request, the Web server serving the request must also wait on the latency caused by slow network connections.

Apache process forking model and how it work!

Following is the definition of the process forking model taken straight from the Apache web server documentation:

“This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server. Each server process may answer incoming requests, and a parent process manages the size of the server pool. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries. It is also the best MPM for isolating each request, so that a problem with a single request will not affect any other.”

Broadly speaking, Apache process forking model is the widely used model among the Apache web server setups because of its stability. In the process forking model, a new process is forked to handle requests sent to the web server, this ensures that even in the case of a fall-out, only that child process crashes out and hence there is no effect on the web server itself.

While appearing to be very stable and crash-resistive, this model is resource intensive, because every process consumes resources, even if its idle, resources such as memory, persistent database connections and a slot in the process table.

Now combine this with the effect of network latency!

The effect of network latency on the performance of Apache pre-fork Web Server

Suppose a web server receives a client request and a new child process is forked to handle that request, this process is allotted resources and holds up a slot in the process table.
Now this process is marked as handling a request, not just until the request is processed by the application, but until the data has been delivered physically.
Now there is also a fixed limit on the number of child processes that can be forked, and if this number is reached and any further client request arrives, then those requests have to wait in a queue for the processes to free up. If there are very many client requests coming to your server, then network latency starts playing a big role in the performance of the web server.

Hence we learn the following:

The greater the network latency, the greater time the processes take to get free up and the greater time other requests have to wait in the queue. All this adds up to the response time.

Conclusion

See how network latency is yet another important variable in the world of web server performance that needs tuning. In the next post I will be showing a solution that can greatly minimize the effect of network latency on the performance of a web server, so stay tuned!

Ovais is a storage architect with keen focus on reliability, efficiency and performance of OLTP databases, more specifically MySQL. He currently works at Uber on ensuring storage reliability and scalability. Previously, he helped different web properties scale their MySQL infrastructure. He also worked at Percona as a Senior MySQL consultant and at a few other startups in various capacities.