Speed is of the essence when it comes to CRO, and dropping a few microseconds here and there can make a big impact on conversion rates. One way that you can speed up your site if you’re using Apache is to enable KeepAlive. Should you do this? What are the pros and cons? And how do you do it? Let’s take a look.
What is KeepAlive?
With HTTP, once connection is made to transfer a file, it is closed again once that’s done. KeepAlive is a tool which allows the browser and server to use the same connection for multiple file transfers. It’s as if you were going shopping: you could stop at 10 different stores in different parts of town, or you could go to a one-stop shop and get everything faster. That’s essentially the appeal of KeepAlive.
This does a few things: it increases your site speed, and it decreases your CPU usage, which can reduce cost. On the downside, it can increase the amount of server memory you’re using; in other words, Apache is tied up keeping those connections open, taking RAM from other clients. Now, you have to weigh whether that is more or less important than CPU. Which do you have more of, and which can you afford to detract a bit from? If you have a lot of images and graphics, enabling KeepAlive will speed up your site significantly for users.
One other note: KeepAlive is not great if your site has bursts of high activity at certain times a day. For instance, if you tend to get a lot of traffic from 5pm to 7pm, you may want to ensure KeepAlive is turned off.
Enabling KeepAlive
In CentOS, the file is called httpd.conf. Make sure your settings are correct:
- KeepAlive: default setting should be set to “On.” Easy enough so far!
- MaxKeepAliveRequests. How many requests do you want a single connection to handle? Typically, 50 – 75 is sufficient.
- KeepAliveTimeout. This setting controls how long the server waits for new requests from connected clients. To avoid wasting RAM, this should be set at between 1 and 5.
And that’s that. KeepAlive won’t be an optimal solution for every site, but it can help your CRO efforts immensely if you have an image-heavy site, can make the tradeoff between CPU and RAM, and have relatively flat levels of traffic during the day.