Results 1 to 13 of 13

Thread: Apache overload

  1. #1
    Join Date
    Nov 2009
    Location
    Cyber Space
    Posts
    64

    Apache overload

    Hello,

    I have a virtual machine in one hosting company that will use to host my site. Since the installation do everything alone. OS is Ubuntu Hardy, Kernel 2.6.24-25-virtual, VMware tools the last version, the host machine is a VMware ESX 4 with processors Intel (R) Xeon (R) CPU [email protected] For my virtual machine are allocated 256MB of RAM, restricted to use up to 450 Mhz processor during a Xeon and I have a 100Mbit-flat channel to the Internet. My problem is the following when I decide to test the performance of Apacha and from my laptop run ab-c 10-n 100 http://mysite.com/ or ab-c 20-n 20 in http://mysite.com/ get console response:
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking mysite.com (be patient)...apr_poll: The timeout specified has expired (70007)
    Load of my server is just over 20, CPU-it is almost 100 percent all the time. top show about memory following thing:
    Mem 255764k total, 231156k used, 24608k free, 12432k buffers
    Swap: 401400k total, 100K used, 401300k free, 110376k cached
    In the first 20-21 lines shows apache2. I watched the top around, 40 minutes, values remain almost unchanged. Execute /etc/init.d/apache2 stop waiting 4-5 min but nothing happen. For that reason execute killall -9 apache2 and loading the machine decrease.

    My question is what is the reason for this overload of apache.I guess something fundamentally wrong.

    Here is what I changed from the default settings. In /etc/apache2/apache2.conf:
    <IfModule mpm_prefork_module>
    StartServers 5
    MinSpareServers 5
    MaxSpareServers 10
    MaxClients 20
    MaxRequestsPerChild 1024
    </IfModule>
    Overrideis prohibited anywhere. Instead .htaccess files use the directives in /etc/apache2/httpd.conf for the specific directory where it should have .htaccess file.

    In /etc/php5/apache2/php.ini I change:
    post_max_size = 256M
    upload_max_filesize = 200M
    max_execution_time = 300 ; Maximum execution time of each script, in seconds
    max_input_time = 600 ; Maximum amount of time each script may spend parsing request data
    memory_limit = 128M ; Maximum amount of memory a script may consume (16MB default)
    I installed eAccelerator according to the instructions here My configuration in /etc/php5/conf.d/eaccelerator.ini is as follows:
    extension="eaccelerator.so"
    eaccelerator.shm_size="16"
    eaccelerator.cache_dir="/var/cache/eaccelerator"
    eaccelerator.enable="1"
    eaccelerator.optimizer="1"
    eaccelerator.check_mtime="0"
    eaccelerator.debug="0"
    eaccelerator.filter=""
    eaccelerator.shm_max="0"
    eaccelerator.shm_ttl="10"
    eaccelerator.shm_prune_period="10"
    eaccelerator.shm_only="1"
    eaccelerator.compress="1"
    eaccelerator.compress_level="9"
    In /etc/mysql/my.cnf I change this:
    max_allowed_packet = 128M
    My file system is reiserfs mounted with the following options relatime,noatime,notail

    Thanks in advance!

  2. #2
    Join Date
    Feb 2006
    Location
    Buffalo NY
    Posts
    1,348
    If you're using prefork (which you're implying you are) you might want to simply try switching to the worker MPM (threaded) + FCGI. I have a sneaking suspicion it might not be so much Apache as Apache+PHP (your main site is utilizing PHP)? Try running ab on just a static HTML page and see what happens - it'll likely wiz through it and not really lag (depending on if how many requests you do).

    *EDIT*

    I didn't address the configuration settings as much simply because I believe the issue is simply the way you're serving PHP / MPM - tweaking and optimizing always helps, though it's better to get to the root of the problem, then tweak
    Cody R.
    Hawk Host Inc. Proudly Serving websites since 2004.
    Let's Encrypt Sponsor.

  3. #3
    Hi,

    Recompile apache on all server with following options. This will
    decrease load and increase performance.

    -------
    apache 2 or 2.2
    modules : cache, deflate, disk cache, file cache, memcache, headers,
    expire

    Shiju S Thomas
    Admin -Ahead

  4. #4
    Join Date
    Nov 2009
    Location
    Cyber Space
    Posts
    64
    Quote Originally Posted by CodyRo View Post
    If you're using prefork (which you're implying you are) you might want to simply try switching to the worker MPM (threaded) + FCGI. I have a sneaking suspicion it might not be so much Apache as Apache+PHP (your main site is utilizing PHP)? Try running ab on just a static HTML page and see what happens - it'll likely wiz through it and not really lag (depending on if how many requests you do).

    *EDIT*

    I didn't address the configuration settings as much simply because I believe the issue is simply the way you're serving PHP / MPM - tweaking and optimizing always helps, though it's better to get to the root of the problem, then tweak
    I try with ab -c 100 -n 1000 http://mysite:8080/phpMyAdmin/Documentation.html and receive 1955.41 requests per second without problems. I think this is maximum for my server, because this performance fill all 100Mbits who have like a connection to internet.

    I test and with ab -c 1000 -n 10000 http://mysite:8080/phpMyAdmin/Documentation.html and receive 476.91 requests per second without problems.

    Note: Port of Apache is 8080 because now Nginx is binded to port 80. I try to use Nginx like as a reverse proxy for Apache. Set up Nginx as a server for static content and a dynamic content to be redirected to a Apache server behind. On port 8080 I connect direct to Apache.
    Last edited by Abadon; 11-17-2009 at 10:00 AM.

  5. #5
    Join Date
    Nov 2009
    Location
    Cyber Space
    Posts
    64
    Quote Originally Posted by shijusthomas View Post
    Hi,

    Recompile apache on all server with following options. This will
    decrease load and increase performance.

    -------
    apache 2 or 2.2
    modules : cache, deflate, disk cache, file cache, memcache, headers,
    expire

    Shiju S Thomas
    Admin -Ahead
    I using Ubuntu and I don't know how to do this. If you explain how to do it, I'll try. These modules require additional configuration after recompile or I can use my old configuration?

  6. #6
    Join Date
    Nov 2009
    Location
    Nasik,India
    Posts
    252
    Hi
    for this do following changes in ur my.cnf

    delete all lines in it and then paste following

    ------------------------------------------------------

    [mysqld]

    datadir=/var/lib/mysql

    socket=/var/lib/mysql/mysql.sock

    max_user_connections=25

    max_connections=500

    interactive_timeout=10

    wait_timeout=10

    connect_timeout=10

    thread_cache_size=128

    key_buffer=16M

    join_buffer=1M

    max_allowed_packet=16M

    table_cache=1024

    record_buffer=1M

    sort_buffer_size=2M

    read_buffer_size=2M

    max_connect_errors=10# Try number of CPU's*2 for thread_concurrencythread_concurrency=8

    myisam_sort_buffer_size=64M

    #log-binserver-id=1

    old-passwords = 1

    [mysql.server]

    user=mysqlbasedir=/var/lib

    [safe_mysqld]

    err-log=/var/log/mysqld.log

    pid-file=/var/lib/mysql/mysql.pid

    open_files_limit=8192

    [mysqldump]

    quickmax_allowed_packet=16M

    [mysql]

    no-auto-rehash

    #safe-updates

    [isamchk]

    key_buffer=64M

    sort_buffer=64M

    read_buffer=16M

    write_buffer=16M

    [myisamchk]

    key_buffer=64M

    sort_buffer=64M

    read_buffer=16M

    write_buffer=16M

    [mysqlhotcopy]

    interactive-timeout


    Enjoy...............

  7. #7
    Join Date
    Feb 2006
    Location
    Buffalo NY
    Posts
    1,348
    Quote Originally Posted by Abadon View Post
    I try with ab -c 100 -n 1000 http://mysite:8080/phpMyAdmin/Documentation.html and receive 1955.41 requests per second without problems. I think this is maximum for my server, because this performance fill all 100Mbits who have like a connection to internet.

    I test and with ab -c 1000 -n 10000 http://mysite:8080/phpMyAdmin/Documentation.html and receive 476.91 requests per second without problems.

    Note: Port of Apache is 8080 because now Nginx is binded to port 80. I try to use Nginx like as a reverse proxy for Apache. Set up Nginx as a server for static content and a dynamic content to be redirected to a Apache server behind. On port 8080 I connect direct to Apache.
    Then simply put it's Apache prefork + PHP DSO that's killing you. Try the Worker / FCGI method (Google how to setup FCGI, I believe the Worker MPM is already in the Ubuntu repositories if memory serves).
    Cody R.
    Hawk Host Inc. Proudly Serving websites since 2004.
    Let's Encrypt Sponsor.

  8. #8
    Join Date
    Nov 2009
    Location
    Cyber Space
    Posts
    64

    Thumbs up

    Quote Originally Posted by ksv2nash View Post
    Hi
    for this do following changes in ur my.cnf

    delete all lines in it and then paste following

    ------------------------------------------------------

    [mysqld]

    datadir=/var/lib/mysql

    socket=/var/lib/mysql/mysql.sock

    max_user_connections=25

    max_connections=500

    interactive_timeout=10

    wait_timeout=10

    connect_timeout=10

    thread_cache_size=128

    key_buffer=16M

    join_buffer=1M

    max_allowed_packet=16M

    table_cache=1024

    record_buffer=1M

    sort_buffer_size=2M

    read_buffer_size=2M

    max_connect_errors=10# Try number of CPU's*2 for thread_concurrencythread_concurrency=8

    myisam_sort_buffer_size=64M

    #log-binserver-id=1

    old-passwords = 1

    [mysql.server]

    user=mysqlbasedir=/var/lib

    [safe_mysqld]

    err-log=/var/log/mysqld.log

    pid-file=/var/lib/mysql/mysql.pid

    open_files_limit=8192

    [mysqldump]

    quickmax_allowed_packet=16M

    [mysql]

    no-auto-rehash

    #safe-updates

    [isamchk]

    key_buffer=64M

    sort_buffer=64M

    read_buffer=16M

    write_buffer=16M

    [myisamchk]

    key_buffer=64M

    sort_buffer=64M

    read_buffer=16M

    write_buffer=16M

    [mysqlhotcopy]

    interactive-timeout


    Enjoy...............
    Wow thanks a lot man Now I haven't problem even ab -c 10 -n 1000 http://mysite:8080/. In this test I make 66.33 requests per second.
    I have only one question table_cache=1024 what does mean? Because I have only 256MB RAM.

  9. #9
    Join Date
    Nov 2009
    Location
    Nasik,India
    Posts
    252
    Hi
    U just set ur my.cnf file with this configuration n then c ur apache.....
    also i have some other ways to make server stable 99%......

    and table_cache dont have any problem wt ur hardware memory it is just work like virtually n dont change in this script

    Enjoy..........

  10. #10
    Join Date
    Nov 2009
    Location
    Cyber Space
    Posts
    64
    Something very very strange happen with my Apache. Last night when I written my previous post. My Apache running on the port 8080, because Nginx is binded to port 80. I try to use Nginx like as a reverse proxy for Apache. It is getting late and I left. This morning I decided to stop Nginx and to use only Apache on port 80 and test again the performance. And what I saw, making the following test ab -c 10 -n 1000 http://mysite.com/ ?
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking mysite.com (be patient)
    Completed 100 requests
    apr_poll: The timeout specified has expired (70007)
    Total of 169 requests completed
    Apache overload again eating my CPU of 100% with 10 processes apache2. I killall processes of apache2. Change port from 80 to 8080 and start apache again. Then I did the following test ab -c 10 -n 1000 http://mysite.com:8080/ and receive this:
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking mysite.com (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Completed 500 requests
    Completed 600 requests
    Completed 700 requests
    Completed 800 requests
    Completed 900 requests
    Completed 1000 requests
    Finished 1000 requests


    Server Software: Apache
    Server Hostname: mysite.com
    Server Port: 8080

    Document Path: /
    Document Length: 0 bytes

    Concurrency Level: 10
    Time taken for tests: 14.628 seconds
    Complete requests: 1000
    Failed requests: 0
    Write errors: 0
    Non-2xx responses: 1000
    Total transferred: 214000 bytes
    HTML transferred: 0 bytes
    Requests per second: 68.36 [#/sec] (mean)
    Time per request: 146.284 [ms] (mean)
    Time per request: 14.628 [ms] (mean, across all concurrent requests)
    Transfer rate: 14.29 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 1 3 37.1 1 624
    Processing: 8 142 247.0 34 1616
    Waiting: 8 142 247.0 34 1616
    Total: 9 145 248.8 34 1617

    Percentage of the requests served within a certain time (ms)
    50% 34
    66% 39
    75% 44
    80% 55
    90% 659
    95% 672
    98% 696
    99% 721
    100% 1617 (longest request)
    I can not explain why my performance fall so dramatically when Apache works on the port 80. Any suggestions ?

  11. #11
    May be try to use nginx for output static content?

  12. #12
    Join Date
    Nov 2009
    Location
    Cyber Space
    Posts
    64
    No not trying to use it, because I have not started it. When I made these tests nginx was stopped.

  13. #13
    Join Date
    Nov 2009
    Location
    Cyber Space
    Posts
    64
    Quote Originally Posted by CodyRo View Post
    Then simply put it's Apache prefork + PHP DSO that's killing you. Try the Worker / FCGI method (Google how to setup FCGI, I believe the Worker MPM is already in the Ubuntu repositories if memory serves).
    I install apache2-mpm-worker and libapache2-mod-fcgid It is indeed faster. But I have this stupid problem. When apache run on port 80 I have 100 times less productivity if apache run on port 8080. I can not explain why my performance fall so dramatically when Apache works on the port 80.

Similar Threads

  1. apache overload and down
    By maketop in forum Hosting Security and Technology
    Replies: 4
    Last Post: 10-17-2009, 12:46 AM
  2. Apache overload?
    By gyro in forum Hosting Security and Technology
    Replies: 9
    Last Post: 03-06-2008, 03:32 AM
  3. Apache Overload
    By Servers4me in forum Dedicated Server
    Replies: 9
    Last Post: 03-12-2006, 03:30 PM
  4. Apache Overload
    By haunted_hits in forum Hosting Security and Technology
    Replies: 1
    Last Post: 03-29-2005, 09:28 PM
  5. apache overload, please help...
    By evilek in forum Hosting Security and Technology
    Replies: 17
    Last Post: 05-12-2004, 11:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •