The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Apache Optimisation during Backup

Discussion in 'Workarounds and Optimization' started by micxnet, Jan 18, 2011.

  1. micxnet

    micxnet Registered

    Joined:
    Jan 5, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Our server is running WHM 11.26.20 and experiences a high server load during the cPanel backup. Usually if the backup is successful, the server load will not go above 8.00 (2 CPU's). However, occasionally the amount of apache processes will multiply into the hundreds and will cause the memory usage and server load to skyrocket and the backup will not complete to keep our websites online I need to reboot the server to reduce the load.

    We run a full backup 3 times a week, and usually one of these days, the server load will go up to between 26.00 and as high as 365.00 and I will be forced to reboot the server to get the websites back online. Our server is currently fitted with only 1GB of RAM, however attached is a sample process list when the server starts to crawl and I would need to initiate a reboot.

    View attachment ps-example.txt

    Here is also the corresponding vmstat infromation:

    Output from vmstat:
    Code:
    procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
      r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
      0 21 1365716  22384   7684  38808    1    1   126   107   11    17  9  1 86  4
    My query is how can I stop Apache from creating so many processes during the cPanel backup, which causes the issue. Or is the problem related to the lack of RAM available for the server.
     
  2. boonjackmedia

    boonjackmedia Active Member

    Joined:
    Apr 28, 2010
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Cincinnati, OH USA
    If I'm reading that right, your swap is really high.

    Post these:
    1) etc>my.cnf
    2) root# top -c
    3) What version of PHP/Apache?
    4) In WHM> Apache Config>Global Conf (start servers, min spare, etc.)

    We'll taker a look and see what's out of wack.
     
  3. micxnet

    micxnet Registered

    Joined:
    Jan 5, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for your reply.

    1)
    Code:
    [mysqld]
    set-variable = max_connections=500
    safe-show-database
    local-infile=0
    2)
    Code:
    top - 12:56:53 up 1 day,  6:24,  1 user,  load average: 1.27, 1.36, 1.05
    Tasks: 187 total,   1 running, 184 sleeping,   0 stopped,   2 zombie
    Cpu(s): 13.7% us,  1.3% sy,  0.0% ni, 81.4% id,  3.5% wa,  0.0% hi,  0.0% si
    Mem:   1033240k total,   921396k used,   111844k free,    59280k buffers
    Swap:  2096472k total,      224k used,  2096248k free,   507000k cached
    
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
      635 nobody    16   0 44420  25m 4728 S 28.9  2.5   0:03.06 /usr/local/apache/bin/httpd -k start -DSSL
     4210 mysql     15   0  129m  32m 5012 S 12.6  3.2 107:33.24 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/******.pid --skip-external-locking
     7258 root      16   0 39764  33m 2152 S 11.0  3.3   0:26.78 spamd child
      584 nobody    15   0 38864  19m 4116 S  2.7  1.9   0:00.64 /usr/local/apache/bin/httpd -k start -DSSL
      596 nobody    15   0 38732  19m 4112 S  2.3  1.9   0:00.63 /usr/local/apache/bin/httpd -k start -DSSL
    32651 nobody    16   0 38804  20m 4988 S  1.0  2.0   0:01.90 /usr/local/apache/bin/httpd -k start -DSSL
      752 mailnull  16   0  8504 3756 2640 S  0.7  0.4   0:00.02 /usr/sbin/exim -bd -q60m
     5657 root      15   0  6476 2812 1320 S  0.3  0.3   0:44.79 hald
     9690 root      16   0 28880  24m 2116 S  0.3  2.4   0:02.72 /usr/bin/spamd -d --allowed-ips=127.0.0.1 --pidfile=/var/run/spamd.pid --max-children=5
    23399 root      16   0  2620 1124  780 R  0.3  0.1   0:05.69 top -c
        1 root      16   0  2316  544  468 S  0.0  0.1   0:00.85 init [3]
        2 root      RT   0     0    0    0 S  0.0  0.0   0:00.32 [migration/0]
        3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 [ksoftirqd/0]
        4 root      RT   0     0    0    0 S  0.0  0.0   0:00.08 [migration/1]
        5 root      34  19     0    0    0 S  0.0  0.0   0:00.00 [ksoftirqd/1]
        6 root      RT   0     0    0    0 S  0.0  0.0   0:00.04 [migration/2]
        7 root      34  19     0    0    0 S  0.0  0.0   0:00.00 [ksoftirqd/2]
        8 root      RT   0     0    0    0 S  0.0  0.0   0:00.02 [migration/3]
        9 root      34  19     0    0    0 S  0.0  0.0   0:00.00 [ksoftirqd/3]
       10 root       5 -10     0    0    0 S  0.0  0.0   0:00.06 [events/0]
       11 root       5 -10     0    0    0 S  0.0  0.0   0:00.01 [events/1]
       12 root       5 -10     0    0    0 S  0.0  0.0   0:00.02 [events/2]
       13 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 [events/3]
       14 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 [khelper]
       15 root      15 -10     0    0    0 S  0.0  0.0   0:00.00 [kacpid]
       45 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 [kblockd/0]
       46 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 [kblockd/1]
       47 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 [kblockd/2]
       48 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 [kblockd/3]
       49 root      15   0     0    0    0 S  0.0  0.0   0:00.06 [khubd]
       66 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [pdflush]
       67 root      15   0     0    0    0 S  0.0  0.0   0:07.66 [pdflush]
       68 root      15   0     0    0    0 S  0.0  0.0   0:06.84 [kswapd0]
       69 root      13 -10     0    0    0 S  0.0  0.0   0:00.00 [aio/0]
       70 root      13 -10     0    0    0 S  0.0  0.0   0:00.00 [aio/1]
       71 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 [aio/2]
       72 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 [aio/3]
      216 root      25   0     0    0    0 S  0.0  0.0   0:00.00 [kseriod]
      415 nobody    16   0 38784  19m 4124 S  0.0  1.9   0:00.80 /usr/local/apache/bin/httpd -k start -DSSL
      453 root       5 -10     0    0    0 S  0.0  0.0   0:00.71 [ata/0]
      454 root       5 -10     0    0    0 S  0.0  0.0   0:07.44 [ata/1]
      455 root       5 -10     0    0    0 S  0.0  0.0   0:10.27 [ata/2]
      456 root       5 -10     0    0    0 S  0.0  0.0   0:00.81 [ata/3]
      457 root       7 -10     0    0    0 S  0.0  0.0   0:00.00 [ata_aux]
      463 root      15   0     0    0    0 S  0.0  0.0   0:30.69 [scsi_eh_0]
      464 root      15   0     0    0    0 S  0.0  0.0   0:00.00 [scsi_eh_1]
      479 nobody    16   0 38856  19m 4152 S  0.0  1.9   0:00.88 /usr/local/apache/bin/httpd -k start -DSSL
      490 nobody    16   0 38712  19m 4096 S  0.0  1.9   0:00.38 /usr/local/apache/bin/httpd -k start -DSSL
      491 nobody    16   0 38748  19m 4096 S  0.0  1.9   0:00.48 /usr/local/apache/bin/httpd -k start -DSSL
      492 root      15   0     0    0    0 S  0.0  0.0   0:33.39 [kjournald]
      546 nobody    16   0     0    0    0 Z  0.0  0.0   0:01.22 [httpd] <defunct>
      559 nobody    15   0 38756  19m 4096 S  0.0  1.9   0:00.93 /usr/local/apache/bin/httpd -k start -DSSL
      567 nobody    15   0 38924  19m 4152 S  0.0  1.9   0:01.09 /usr/local/apache/bin/httpd -k start -DSSL
      568 nobody    15   0 38900  19m 4152 S  0.0  1.9   0:01.23 /usr/local/apache/bin/httpd -k start -DSSL
      612 nobody    16   0 38764  19m 4096 S  0.0  1.9   0:00.65 /usr/local/apache/bin/httpd -k start -DSSL
      613 nobody    16   0 38904  19m 4148 S  0.0  1.9   0:00.44 /usr/local/apache/bin/httpd -k start -DSSL
      615 nobody    16   0 38732  19m 4124 S  0.0  1.9   0:00.14 /usr/local/apache/bin/httpd -k start -DSSL
    3) Apache = 2.0.63, PHP = 5.2.13

    4) Apache Config.
    Start Servers = 5
    MinSpare Servers = 5
    MaxSpareServers=10
    MaxClients=150
    MaxRequestsPerChild=10000
     
  4. boonjackmedia

    boonjackmedia Active Member

    Joined:
    Apr 28, 2010
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Cincinnati, OH USA
    Looks like everything is fine except your max-clients on etc>my.cnf - thats set pretty high @ 500, making your swap out of control causing slow speed. You've got 1GB memory and twice that on swap.

    Knock that down to 150 for max clients to start.

    Now, go to this site or search on this forum for: MySQL Tuner
    Install it, run it, and then post your results here.
    This will help you tweak your settings over time for the best performance. Keep in mind it's a guide only, not the holy grail of DB tuning.
    Another good one you can search here is: Tuning Primer MySQL - Lots of good advice on this board with this, and another nice utility for tweaking MySQL, great to use in tandem with the above (optional).

    Next, your MySQL my.cnf settings are limited - you might need some more control.
    Get your MySQl variables via root and save them to take a look at.
    I'd be interested to know what your settings are for:
    sort_buffer_size, read_buffer_size, read_rnd_buffer_size, and join_buffer_size

    Root# mysqladmin variables
    (then copy/save to check the settings and compare to the sample my.cnf below)

    Here's a nice starting point for a my.cnf - taken straight from the MySQL Docs for a server between 1-2GB Memory w/ basic instructs.
    I've highlighted the basic settings in red:
    ---Start---
    # Example MySQL config file for very large systems.
    #
    # This is for a large system with memory of 1G-2G where the system runs mainly
    # MySQL.
    #
    # You can copy this file to
    # /etc/my.cnf to set global options,
    # mysql-data-dir/my.cnf to set server-specific options (in this
    # installation this directory is /usr/local/mysql/data) or
    # ~/.my.cnf to set user-specific options.
    #
    # In this file, you can use all long options that a program supports.
    # If you want to know which options a program supports, run the program
    # with the "--help" option.

    # The following options will be passed to all MySQL clients
    [client]
    #password = your_password
    port = 3306
    socket = /tmp/mysql.sock

    # Here follows entries for some specific programs

    # The MySQL server
    [mysqld]
    port = 3306
    socket = /tmp/mysql.sock
    skip-locking
    key_buffer_size = 384M
    max_allowed_packet = 1M
    table_open_cache = 512
    sort_buffer_size = 2M
    read_buffer_size = 2M
    read_rnd_buffer_size = 8M
    myisam_sort_buffer_size = 64M
    thread_cache_size = 8
    query_cache_size = 32M

    # Try number of CPU's*2 for thread_concurrency
    thread_concurrency = 8

    # Don't listen on a TCP/IP port at all. This can be a security enhancement,
    # if all processes that need to connect to mysqld run on the same host.
    # All interaction with mysqld must be made via Unix sockets or named pipes.
    # Note that using this option without enabling named pipes on Windows
    # (via the "enable-named-pipe" option) will render mysqld useless!
    #
    #skip-networking

    # Replication Master Server (default)
    # binary logging is required for replication
    log-bin=mysql-bin

    # required unique id between 1 and 2^32 - 1
    # defaults to 1 if master-host is not set
    # but will not function as a master if omitted
    server-id = 1

    # Replication Slave (comment out master section to use this)
    #
    # To configure this host as a replication slave, you can choose between
    # two methods :
    #
    # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
    # the syntax is:
    #
    # CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
    # MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
    #
    # where you replace <host>, <user>, <password> by quoted strings and
    # <port> by the master's port number (3306 by default).
    #
    # Example:
    #
    # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
    # MASTER_USER='joe', MASTER_PASSWORD='secret';
    #
    # OR
    #
    # 2) Set the variables below. However, in case you choose this method, then
    # start replication for the first time (even unsuccessfully, for example
    # if you mistyped the password in master-password and the slave fails to
    # connect), the slave will create a master.info file, and any later
    # change in this file to the variables' values below will be ignored and
    # overridden by the content of the master.info file, unless you shutdown
    # the slave server, delete master.info and restart the slaver server.
    # For that reason, you may want to leave the lines below untouched
    # (commented) and instead use CHANGE MASTER TO (see above)
    #
    # required unique id between 2 and 2^32 - 1
    # (and different from the master)
    # defaults to 2 if master-host is set
    # but will not function as a slave if omitted
    #server-id = 2
    #
    # The replication master for this slave - required
    #master-host = <hostname>
    #
    # The username the slave will use for authentication when connecting
    # to the master - required
    #master-user = <username>
    #
    # The password the slave will authenticate with when connecting to
    # the master - required
    #master-password = <password>
    #
    # The port the master is listening on.
    # optional - defaults to 3306
    #master-port = <port>
    #
    # binary logging - not required for slaves, but recommended
    #log-bin=mysql-bin
    #
    # binary logging format - mixed recommended
    #binlog_format=mixed

    # Point the following paths to different dedicated disks
    #tmpdir = /tmp/
    #log-update = /path-to-dedicated-directory/hostname

    # Uncomment the following if you are using InnoDB tables
    #innodb_data_home_dir = /usr/local/mysql/data/
    #innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
    #innodb_log_group_home_dir = /usr/local/mysql/data/
    # You can set .._buffer_pool_size up to 50 - 80 %
    # of RAM but beware of setting memory usage too high
    #innodb_buffer_pool_size = 384M
    #innodb_additional_mem_pool_size = 20M
    # Set .._log_file_size to 25 % of buffer pool size
    #innodb_log_file_size = 100M
    #innodb_log_buffer_size = 8M
    #innodb_flush_log_at_trx_commit = 1
    #innodb_lock_wait_timeout = 50

    [mysqldump]
    quick
    max_allowed_packet = 16M

    [mysql]
    no-auto-rehash
    # Remove the next comment character if you are not familiar with SQL
    #safe-updates

    [myisamchk]
    key_buffer_size = 256M
    sort_buffer_size = 256M
    read_buffer = 2M
    write_buffer = 2M

    [mysqlhotcopy]
    interactive-timeout
    ---End---

    Keep in mind these are suggestions and guides only. I'd recommend searching on the forums here for Mysql optimization, mysql tuning, etc.
    There's an abundance of good stuff to learn and use.
     
  5. micxnet

    micxnet Registered

    Joined:
    Jan 5, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Cheers Mike for your input and putting me onto the right track.
     
Loading...

Share This Page