Support

Forums

Contact Me

Speed up your apache server running PHP


Since I am facing performance problem due to the load of visitors and a badly configured server, I decide today to document my findings in this new series of articles.

As soon as PHP run as FastCGI and no more inside an Apache module (mod_php4.so is not multi threaded), You should be able to switch the default MPM setting of Apache from MPM prefork to MPM worker.

So, what's the difference between prefork and worker?

Quoting from the Apache MPM Prefork page: http://httpd.apache.org/docs/2.0/mod/prefork.html
MPM Prefork implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3.

And for the Apache MPM Worker says: http://httpd.apache.org/docs/2.0/mod/worker.html
MPM Worker implements a hybrid multi-process multi-threaded server. By using threads to serve requests, it is able to serve a large number of requests with less system resources than a process-based server.


Server: Strato (www.strato.de)
Operating system: SuSE / openSuSE
Requirements: root access and basic Unix knowledge

1 Edit the file  
# vi /etc/sysconfig/apache2

and change the key:

APACHE_MPM=" "


to

APACHE_MPM="worker"


2 You can now tune also  default parameters in file /etc/apache2/server-tuning.conf
Here are my settings, these are still the default setting of Apache

vi /etc/apache2/server-tuning.conf

# worker MPM

<IfModule worker.c>
    ServerLimit 16
    # initial number of server processes to start
    StartServers         2
    # minimum number of worker threads which are kept spare
    MinSpareThreads     25
    # maximum number of worker threads which are kept spare
    MaxSpareThreads     75
    # maximum number of simultaneous client connections
    MaxClients       150
    # constant number of worker threads in each server process
    ThreadsPerChild     25
    # maximum number of requests a server process serves
    MaxRequestsPerChild  6000
</IfModule>




3 start
# apache2-reconfigure-mpm
this recreate the file  /etc/apache2/sysconfig.d/loadmodule.conf
and restart apache automatically. Test Your site to ensure everything still work as expected.


You might also like:
Need for Speed? mod_pagespeed from Google
926 days ago
Need for Speed? mod_pagespeed from Google
mod_pagespeed is the latest addition to our family of products, performing on-the-fly optimiza
Subversion and mod Security
1465 days ago
Subversion and mod Security
I was receiving some strange errors (HTTP error 501) while committing to my public subversion (h
Installing Munin on OpenSuse 11.x
1493 days ago
Installing Munin on OpenSuse 11.x
  Munin the monitoring tool surveys all your computers and remembers what it saw. It presents a
default thumbnail image alt
1549 days ago
Percona XtraDB Storage Engine, scalling betten than innodb
From http://www.mysqlperformanceblog.com Percona XtraDB includes all of InnoDB’s ACID-co
Site optimization: it's all about your image size and format
1576 days ago
Site optimization: it's all about your image size and format
I really like this small Firefox extension Smushit as it allow to quickly check if all my images are
default thumbnail image alt
1598 days ago
Avoid Hotlinking or so called bandwidth stealing
From WikiPedia Inline linking (also known as hotlinking, leeching, piggy-backing, direct linki
blog comments powered by Disqus

Donations

Thank You for supporting my work