October 28, 2007

Make your webserver stable…

I gathered some ideas and tricks how to configure your webserver to prevent it from not serving request anymore. Sadly I cannot try it out on my blog, because it is not my own server.

Slashdot, Reddit, delicious, Furl, Newsvine and Digg are direct an enormous amount of user in a short time to very interesting articles. To prevent your server to fail I suggest you to check these things.

Check the mpm_prefork mod

In this module you should focus on the following three values:

  • StartServers: Defines how many servers should be created at startup
  • MaxClients: Number of servers allowed tobe started
  • MaxRequestPerChild: Defines how many requests a server should handle before beeing killed.

Suggestion: Put your StartServers around 32 and keep the MaxClients high. When tweaking here don’t forget to check how many connections your database can handle, you might have to change things there too.

Disable KeepAlive

… make the math. Apache is keeping the connection alive by default for about 15 sec. It supports a max of 256 connections at a time. If you have 800 people requesting your site at a time Apache will serve the max amount of supported connections (256) and let the other 544 people wait. A workaround would be to decrease the KeepAlive to a lower value.

Focus on the PHP settings

You should check if PHP is running in CGI mode, because if that is the case it is damn slow. It should be configured to run as a module (mod-php5), thats the fastest way you can have it.

Benchmarking

To benchmark your site just checkout ab. It normally comes with the default Apache installation.
Run ab -n 10000 -c 100 http://yourhost/index.php

This makes 10k requests split over 100 smiultaneous connections. The results are somehow self speaking.

August 25, 2007

PHPIDS for wordpress

My first attempt to write a plugin for wordpress. It enables phpids for wordpress. There is no way yet to configure it. If I have time I will implement this feature as well as a Filter autoupdater.

Installation is easy:

  1. Copy the contents of the file to your wp-content/plugins folder
  2. Enable the plugin in the admin menu
  3. chmod 777 the file in wp-content/plugins/phpids/log.txt

tar.gz download here

zip download here

NOTE: check for new Filter releases at phpids to update the filter.