I am trying to optimize apache on my virtual server on Digital Cloud hosting. I am following a tutorial that tells me to make sure the following values are set in my apache2.conf

KeepAlive Off


<IfModule mpm_prefork_module>
StartServers 2
MinSpareServers 6
MaxSpareServers 12
MaxClients 80
MaxRequestsPerChild 3000

However, the only thing I can find in this file is "KeepAlive Off". There is no sign of any of the other properties or the

The location of my file is /etc/apache2/apache2.conf and I am using Ubuntu 14.04 x64 with apache 2.4.7. Can anyone tell me why this is not present in my file? Is it safe to simply just add it in?


closed as too broad by Ward, mdpc, Tom O'Connor May 21 '14 at 15:52

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Wouldn't it be better to have KeepAlive on? This will greatly reduce the amount of TCP connections to your server and therefore yield better performance. Or am I missing something? – jornane May 19 '14 at 22:55
  • @Yørn Am I total noobie in web optimization so I do not know one way or the other. If you know for certain this is the case, then thank you for sharing, I will make the change – Teddy13 May 19 '14 at 22:56

My guts tell me you have WordPress, Drupal or similar heavy-weight PHP application installed and now you are wondering why your Apache does not serve out ONE HUNDRED BILLION requests per second.

The truth is that nowadays you first have to tune everything on top of Apache (or any other web server software). Most likely the bottleneck is in your application, [lack of] caching, bad database/SQL query design, some database software running with its default settings, or some other reason.

In your typical environment the web server software itself is the last one needing any kind of optimization, unless your traffic amount is hefty.

Please be more specific and tell us why and what you are actually trying to performance tune.

Edit after your comment

Still, before going as far as optimizing Apache, you need to carefully study and benchmark your application and database on top of it. "Why he's repeating that, I just wanna optimize my Apache!!", you probably now wonder.

It all comes up to how fast your application can render something that Apache can serve out. If your app and/or database takes two seconds to return something, then optimizing Apache itself is pretty much useless, it won't make anything faster if the bottleneck is elsewhere. And, in any case, after running those benchmarks you can have an idea how to begin tuning your Apache.

So, what to do if your application is slow? Varnish or a similar front-end cache, memcached etc would be more a performance boost in that case, not tuning Apache.

  • Thanks for the response. I am not running WordPress or any type of content management system. The reason for this "optimization" is because I am building an application that I potentially foresee receiving a decent amount of traffic. For that reason, I have split my design by having separate servers running the database and running apache. So, I am looking to optimize apache to get the best performance possible per server. I understand that it cannot serve 100 billion requests per second. I am simply trying to maximize/optimize to the best of its ability. Thanks! – Teddy13 May 20 '14 at 19:46

Apache is not unreasonably configured by default given that the writers of that configuration can't know what you're going to run on top of it, or much about the server you're going to run it on. It leans towards the requirements of serving static content though. As soon as you start dynamically producing content, things change.

For a given application and hardware, you can certainly do better than the default, and very likely people here can advise you on that, but you do need to provide more information on your setup.

There are a lot of knobs to tweak, and the way they should each be configured is very interdependent. There's no simple recipe that will substitute for a good understanding of what's involved, and hands on investigation of what bottlenecks you're actually running into. You need to come up with a general strategy and configure accordingly rather than just think about various settings in isolation, and then you need to review what's actually going on, and improve, under load conditions appropriate to your expected use.

So, if you really want to work this out yourself, rewrite your question, with a lot more information, and I give a general gist of what that means below. Then think about whether this is really appropriate for a serverfault question. You probably can't answer it all at once.

Also think about whether this is really something you want to do something yourself. My guess is you've got enough to learn already with writing your application, and you'd be better off working with an experienced sysadmin to set up your system, and occasionally look over it and tweak the configuration, and discuss with you how to make your application work well with the system.

  1. Tell us about your hosting environment type (VPS? Bare metal?) and resources (RAM, disk systems, cpu).

  2. Tell us a little about your application(s), and more about how they will be run. For the purposes of optimisation, the first focus here is on how memory will be used, and on how long each request is likely to take to service. There's a great deal of difference between running the app inside the apache processes (eg mod_php) as compared to in a separate engine (eg php-fpm). Also some systems run a multi-threaded application server, which is significantly different to running multiple system processes. It's also important to know how much memory each request will take.

  3. In general there are many ways to lay out your configuration. There is good advice to be had about best practices, but there are different philosophies here, and it's important to be consistent so you know where to find things. Don't expect that everyone is using the same layout as you. You've said that you're running ubuntu, so probably just try to be consistent with that Ubuntu's approach. In particular, that means avoiding, as far as possible, making changes in /etc/apache2/apache.conf, and instead using files in /etc/apache/conf.d/ and the sites in /etc/apache/sites-available/. This will make it a lot easier whenever a newer version of apache brings changes to apache.conf. Sticking close to the default ubuntu approach will make it easier for people familiar with Debian and Ubuntu to know where things are likely to be on your system, and will make it easier to use advice from those people.

  4. Optimising the apache configuration is quite dependent on your caching architecture. While it adds complexity, to get a high performing application/server, you're going to need a front end caching system (probably start with page level caching with varnish or squid), and also layers of caching within your application. Whether or not you have such a caching layer will make a lot of difference to how you should optimise apache. However, to use such a layer effectively, your application needs to be able to send appropriate headers to the caching layer.


Yes, you can add KeepAlive. It is part of the core of Apache, so it's not dependent on a module. By default it is on.


Edit: You refer to the prefork module. On the module page, it reads.

This MPM is very self-regulating, so it is rarely necessary to adjust its configuration directives.

The impression I get from these changes, is that it may improve the performance of your server if it is under constant high load. In such a case, it may however be better to look for a new server. If you don't have specific load requirements, the defaults will probably work best for you.

  • It is not so much about the KeepAlive but the components below it. I have KeepAlive in my file, I do not have the rest of it. Can I add the rest of it in? Thanks – Teddy13 May 19 '14 at 22:57
  • I think I found the source of your article. I don't think these settings will give higher performance, unless some very specific cases. What is the reason you want to change the default performance settings? – jornane May 20 '14 at 7:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.