4

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>
Sathyajith Bhat
  • 286
  • 1
  • 5
  • 23
Grimlockz
  • 315
  • 1
  • 2
  • 11

3 Answers3

11

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.

EEAA
  • 108,414
  • 18
  • 172
  • 242
3

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

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
3

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.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • 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