Linux – Setting up Apache to use multiple cores

apache-2.2linuxmulti-core

Recently I have purchased a 6 core server which is running Ubuntu 10.04 and Apache. How do you set up apache to use all 6 cores and what is the best practice to do this?

Is it possible and if it is possible does it have something to do with the below (these are not my settings)?

<IfModule prefork.c> 
StartServers 10 
MinSpareServers 10 
MaxSpareServers 20 
ServerLimit 1500 
MaxClients 1500 
MaxRequestsPerChild 4000 
</IfModule>

<IfModule worker.c> 
StartServers 2 
MaxClients 150 
MinSpareThreads 25 
MaxSpareThreads 75 
ThreadsPerChild 25 
MaxRequestsPerChild 0 
</IfModule> 

Cheers

This is my current config

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

# event MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_event_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>

Best Answer

Apache (and any other multi-threaded application) will use all available cores by default. As long as you don't have Apache set to use less servers than you have cores, there's no other action you need to take.

Related Topic