Apache Connection vs. Request

apache-2.2processrequest

I apologize in advance if this is a basic question, but I am quite confused after reading the Apache documentation and other tutorials.

Does a single Apache prefork process serve all HTTP requests for a given client? That's what I thought, but when I reduce maxclients down to a low number, my page load times go to a crawl. This despite the fact I'm the only client on the server in question. This would suggest each process serves a single HTTP request at a time, rather than serving all requests within the TimeOut window.

So if a single webpage requires 15 HTTP requests to load fully, do I require 15 prefork Apache processes to optimally serve it?

Best Answer

The way that we typically think about the HTTP protocol, this shouldn't be an issue.

Modern browsers use keep-alive connections, which can only carry one request at a time; in that sense, using MaxClients 1 ought not have an impact, since each request in those connections is completed before the next starts.

However, that's another thing about modern browsers; they use multiple connections. These days, you might get an html page that requires the loading of 40 other resources; images, javascript, css. It doesn't make much sense from an efficiency perspective to pile them all up single-file to send via one connection; instead, they're split up into a handful connections (each of which is still single-file) to fetch concurrently.

I can't find a good authoritative source of information on each browser's behavior, but what I can find suggests that 6 connections is about normal. This is where the concurrency of your server comes into play; each of those 6 connections can concurrently request a resource, acting as 6 different clients from the server's perspective.