Double AdSense income by changing your Apache config

From miscellus

Double your AdSense income by tinkering with your server's Apache config

tl;drThe following suggestions assume you run your own Unix server, that server is running at least Apache version 2.4, that you understand the implications of meddling with your Apache configuration and that while this amazing fix worked for me, it may not work for you - caveat emptor!

The change was made on the 18th, earnings were much improved and so was the CTR

I run my own Apache server with a number of websites, one of them is very popular, others not so. I cover the costs of running a server by using AdSense. Over the years this has become less profitable, however, I'm always looking for ways to improve my income. To this end I'm always tinkering with the server's configuration, most of the experiments I've made don't seem to improve the situation, some of them make it much worse - nothing ventured, nothing gained!

My current server is a fresh install so the Apache configuration was default. Whilst I made plenty of changes, the basic config was out of the box. I did plenty of reading about the various MPM's [Multi-Processing Modules] and was surprised to see that it was often cited that MPM Event was the fastest for most standard servers. The default configuration out of the box was PreFork MPM, so you would assume that the best would be the default.

I amended my Apache config to use Event MPM and within one hour my AdSense income had improved, as had my Click Through Rate [CTR]. I was staggered, normally tinkering changes take a day or so to make a difference, not hours.

Improved CTR, but still problems

The next morning I checked the server and discovered that Apache had crashed at midnight and since then, had not served any connections. The logs were full of the same error

AH00485: scoreboard is full, not at MaxRequestWorkers

and the load average was 236. Clearly something was very wrong - however, my takings for that day, when the server had only been running for 12 hours, was better than my normal 24 hour takings. All I need to do now is to prevent the server from crashing.

Event MPM is buggy

A quick Google tells us that Event MPM is buggy and has lots of problems, see end of article for more details. But it had worked for 12 hours before falling over. With such a phenomenal improvement there was no way I could return to Worker MPM, what about restarting Apache on a regular basis? In the end restarting every 35 minutes seemed to work well. The load average was constantly around .65, which on this box gives me a good performance, and whatever had been causing Apache to fall over had not been given long enough to become a problem.

My Working Event MPM Configuration

The following config has worked for me on Sunday, my busiest day of the week and there have been no further problems. I still see

AH00485: scoreboard is full, not at MaxRequestWorkers

in the httpd error logs but it does not seem to be causing any problems.

Crontab entry to restart httpd daemon every 35 minutes
*/25 * * * * /sbin/apachectl restart > /var/log/httpd/apache-restart.log 2>&1

Event MPM config

Edit /etc/httpd/conf.modules.d/00-mpm.conf, comment out your current MPM and uncomment Event MPM and add the following Event MPM configuration variables.

#LoadModule mpm_worker_module modules/
LoadModule mpm_event_module modules/
<IfModule event.c>
    StartServers 3
    MinSpareServers 5
    MaxSpareServers 10
    ServerLimit 250
    MaxRequestWorkers 250
    MaxConnectionsPerChild 1000
    KeepAlive Off
    GracefulShutdownTimeout 5
    MinSpareThreads 62
    MaxSpareThreads 186

If this article has helped you out, do please give me a social media click or drop me an email with your thoughts.

See also