Question

I am having some troubles with CPU loading with Apache Web Server.

We are running a Ubuntu Server 12.04 LTS on a Virtual Machine. Our server have the following specs:

  • 8GB RAM;
  • 4 vCPUs (12ghz);

We configured the server to run a Drupal (7.23) based website. So, we installed Apache, PHP, MySQL... The versions are below:

  • Apache 2.2.22;
  • PHP 5.3.10 (The PHP are running as Apache Module.);
  • APC 3.1.7;
  • MySQL 5.5.31 (all innodb tables);

I am running some apache modules too. Take a look (apachectl -M):

  • core_module (static)
  • log_config_module (static)
  • logio_module (static)
  • mpm_prefork_module (static)
  • http_module (static)
  • so_module (static)
  • actions_module (shared)
  • alias_module (shared)
  • authz_host_module (shared)
  • deflate_module (shared)
  • dir_module (shared)
  • env_module (shared)
  • include_module (shared)
  • mime_module (shared)
  • php5_module (shared)
  • proxy_module (shared)
  • proxy_http_module (shared)
  • reqtimeout_module (shared)
  • rewrite_module (shared)
  • setenvif_module (shared)
  • ssl_module (shared)
  • status_module (shared)

On apache2.conf, we have this config:

    Timeout 90
    KeepAlive On
    MaxKeepAliveRequests 80
    KeepAliveTimeout 5
    HostnameLookups Off
    LogLevel warn

    <IfModule mpm_prefork_module>
        StartServers          10
        MinSpareServers       10
        MaxSpareServers       30
        MaxClients           120
        MaxRequestsPerChild 1000
    </IfModule>

The Virtual Host of my site:

    <VirtualHost *:80>
        ServerName blabla.bla.bla
        ServerAdmin bla@bla.com
        DocumentRoot /l/disk0/site/public_html

        <Directory />
            AllowOverride None
        </Directory>

        <Directory /l/disk0/site/public_html>
            Options MultiViews Indexes Includes FollowSymLinks ExecCGI
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>

        LogLevel warn
        ErrorLog "/l/disk0/site/logs/apache/site/error.log"
        CustomLog "/l/disk0/site/logs/apache/sit/access.log" combined
        SSLProxyEngine on
        RewriteEngine   on
        RewriteLog     logs/rewrite_www_log
        RewriteLogLevel        0

        Include rewrites-www.conf
</VirtualHost>

Drupal Modules:

  • ACL 7.x-1.0
  • APC - Alternative PHP Cache 7.x-1.0-beta4
  • Boost 7.x-1.0-beta2
  • Cache Expiration 7.x-2.0-beta2
  • CAPTCHA 7.x-1.0
  • Chaos tool suite (ctools) 7.x-1.3
  • Date 7.x-2.6
  • Domain Access 7.x-3.10
  • Domain Blocks 7.x-2.0
  • Domain CTools 7.x-1.3
  • Domain Locale 7.x-1.0-beta3
  • Domain Taxonomy 7.x-3.x-dev (2012-abr-29)
  • Domain Views 7.x-1.5
  • Embed Views Display 7.x-1.2
  • Entity API 7.x-1.2
  • Entity reference 7.x-1.0
  • IMCE 7.x-1.7
  • IMCE Mkdir 7.x-1.0
  • Internationalization 7.x-1.10
  • Link 7.x-1.1
  • Localization update 7.x-1.0-beta3
  • Media 7.x-1.3
  • Meta tags quick 7.x-2.7
  • Newsletter 7.x-1.0-beta9
  • Options Element 7.x-1.9
  • Page Style 7.x-1.0
  • Panels 7.x-3.3
  • Pathauto 7.x-1.2
  • pathologic 7.x-2.11
  • profile2 7.x-1.3+0-dev (2013-mai-24)
  • select_or_other 7.x-2.19
  • sheetnode 7.x-1.0-beta4+3-dev (2013-mai-25)
  • SMTP Authentication Support 7.x-1.0
  • Token 7.x-1.5
  • Transliteration 7.x-3.1
  • Variable 7.x-2.3
  • Views 7.x-3.7
  • Vocabulary Permissions Per Role 7.x-1.0
  • Webform 7.x-3.19
  • Webform Validation 7.x-1.2
  • workbench 7.x-1.2
  • workbench_access 7.x-1.2
  • workbench_media 7.x-1.1
  • workbench_profile 7.x-1.1
  • xmlsitemap 7.x-2.0-rc2

My site is simple and don't have many visitors. I am talking about 500 visitors a day maybe. Drupal can cause so much CPU loading? Or a module?

My problem is that CPU (all cores) have a high load. Most of time, hitting between 90% and 100% load! The offending process is the apache2. Memory is also consumed without pity. Of a 8GB total, the consumed memory is about 6.5GB to 7.5GB. I don't know if my apache configuration is wrong or if I'm really need more hardware (I guess not). Drupal can cause high CPU load?

When the CPU load hits 100%, the site goes down and we have to restart apache. I did a workaround solution with Drupal using APC and installing Boost. had some effectiveness, but CPU load still high. Very high.

If you need more information, like Drupal modules and PHP extensions. Please let me know.

Was it helpful?

Solution

I'm not a Server expert so I cannot point out the exact reason. Drupal consumes ~ 10MB of memory per call. Install Devel module and there is a checkbox that will put at each end of page the page load and memory usage line while calling a page.

As I see, you enabled the boost module. This one is creating a /cache/ folder in the root or your preset folder that holds the static files. This way the pages are not processed via SQL and PHP. There shouldn't be any such high load by Drupal.

Since this would be cleared, I would point out that you should work on the server settings. You definitively having any issue there. How did you measure those high loads? Top or "collectD" like peak? Run the $ top command and see if this load is permanent, load a page and see if it's shoots out. The $ top command is also showing the most resource consumers.

Is it a dedicated machine or a virtual machine?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top