If you're running a web server, no matter the traffic, you've most likely looked at pretty graphs from your server and turned into a efficiency nut of some kind. You're always looking at what is using your RAM, what's eating up your CPU, and what's clogging up your network. If you're not, you should be! While there's tons of tips, tricks, and techniques you can apply to your server to run your software stack as efficiently as possible, KeepAlives settings in Apache are something that many people overlook and can have a dramatic impact on Apache's memory usage. We're really only going to focus on two Apache directives found in your main Apache configuration file.
On Debian/Ubuntu = /etc/apache2/apache2.conf
On RHEL/CentOS = /etc/httpd/httpd.conf
KeepAlive (On | Off)
KeepAliveTimeout (# of seconds to stay alive before timing out)
In short KeepAlives are a way for Apache to process multiple HTTP requests over a single TCP connection. This can help serve your files quicker by the client (visitor's browser) and the server (Apache) not having to reestablish a new TCP connection for each and every file on your web page. Although, if used improperly, this can hurt your server by keeping these connections open longer than they need to be and causing unnecessary memory usage by your server. This memory usage is what we're going to tackle a bit with KeepAlives.