Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>
share|improve this question

3 Answers 3

up vote 5 down vote accepted

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.

share|improve this answer

What's running within Apache? Often, your limit for threading is going to be with non-threaded modules or application code.

share|improve this answer

By default with the stock configs available in most packaged versions of Apache you won't have to do anything.

How Apache works on multi-core systems and how you configure it is greatly influenced by which MPM you use. One of the more common MPM is prefork.

Prefork basically gives you a separate process for every request. Processes can be easily spread out by the OS to use all cores.

The worker MPM actually enables multi-threaded operation, but it isn't compatible with some Apache modules which are not thread safe (i.e. PHP).

See this page Core Features and Multi-Processing Modules, and follow the links and read about the various modules available.

share|improve this answer
    
If I'm running a PHP site with mostly java and js plugins is this feasible? Also my configuration at present doesn't have any prefork or workers yet? –  Grimlockz Sep 13 '11 at 16:37
1  
@Grimlockz You're using one MPM or another - you'll want to find out which is in place. How is your PHP configured within Apache? –  Shane Madden Sep 13 '11 at 16:41
    
I've edited the question with my apache2.conf hope that helps –  Grimlockz Sep 13 '11 at 17:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.