What are the best Apache configurations for an API?

I have the $20/month server and I am hosting a sales page, user panel and API.

The API gets a lot of traffic and the static homepage too. The entire site, all 3 parts, are built with Django/Python with Apache.

The settings I’m running are:

Timeout 10 MaxClients 75 MaxRequestWorkers 512 ServerLimit 32

Daily average traffic stats: 1500 Page Views 500 Unique Visits 200 First Time Visits 300 Returning Visits

The server will go down about once an hour for 1-2 minutes. Are there any configurations I should be using or considering?


@macdonjo I’m not sure I understand the “The server will go down about once an hour for 1-2 minutes”. So you’re saying that every hour, the server doesn’t work or respond with errors? If yes, can you please provide the logs of Apache, Django and (I’m guessing) MySQL, from when the problem occurs, since that will give us something to work with.

For a $20 droplet, it should be able to sustain multiple thousands of visits every hour without any problems - unless your application is very heavy or slow to respond.

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


We’d definitely need to see the logs in this case – for Apache, MySQL, and Django; unless you know which service is going down, in which case we should take a look there first.

Traffic wise, 500-1,000 visitors a day shouldn’t cause that much stress on a 2GB Droplet, so my initial thought would be that you need to fine-tune Apache + MySQL.

What I would recommend starting with is Apache unless your application doesn’t rely on caching of MySQL queries and fetching cached data (for repeated requests for the same thing, in cases where data doesn’t change instantly from requests to request). In this case, you may need to do both.

To start with Apache, backup your current configuration, then try something such as:

KeepAlive On
KeepAliveTimeout 10
MaxKeepAliveRequests 100
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 300

In your configuration, you have both MaxRequestWorkers and MaxClients – looking at the Apache documentation, MaxRequestWorkers is what it’s called now, so you’re essentially setting the same thing twice. So you can remove the MaxClients setting altogether.

MaxRequestWorkers was called MaxClients before version 2.3.13. The old name is still supported.