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.

Best Optimization for Apache?

Discussion in 'EasyApache' started by Secret Agent, Apr 10, 2005.

  1. Secret Agent

    Secret Agent Guest

    Figured it would be a good idea to start a new thread on this (although some already exists, perhaps we can cover all aspects of httpd.conf in a single thread).

    I changed Maxclientsperchild from 0 to 100 when I got the below

    [Sun Apr 10 19:45:58 2005] [error] server reached MaxClients setting, consider raising the MaxClients setting
    [Sun Apr 10 19:52:44 2005] [warn] VirtualHost xx.x.180.36:443 overlaps with VirtualHost xx.x.180.36:443, the first has precedence, perhaps you need a NameVirtualHost directive
    [Sun Apr 10 19:52:44 2005] [warn] NameVirtualHost xx.x.179.254:80 has no VirtualHosts


    I wanted to turn off KeepAlive but I know it at least processed sites / images faster. I'm leaving it on now to test.

    These are my settings:

    Timeout 450
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 15
    MinSpareServers 5
    MaxSpareServers 10
    StartServers 5
    MaxClients 300
    MaxRequestsPerChild 100

    ---


    note the error message about my IP not having a NameVirtualHost, oddly it does.

    it shows as this in httpd.conf (before any VirtualHost)

    </IfDefine>


    NameVirtualHost xx.x.179.254:80
    Alias /bandwidth/ /usr/local/bandmin/htdocs/



    So what are your optimization suggestions? I do have plenty of forums on the site, some so so, some intense. Its a dual Xeon, 2GB ECC memory as well.
     
  2. haze

    haze Well-Known Member

    Joined:
    Dec 21, 2001
    Messages:
    1,550
    Likes Received:
    3
    Trophy Points:
    38
    Well there's really not a cut and paste sort of solution to this problem. Its all trial and error to be quite honest, try, watch retry, rinse, repeat.

    A couple of suggestions, assuming your trying to free up resources here...

    Lower your KeepAliveTimeOut to about 8 - 10

    Switch:
    MaxKeepAliveRequests 100
    back to:
    MaxKeepAliveRequests 0
    - honestly I've never had any need to adjust this, though it may be necessary in your possition.

    Failing that, you can turn off keepalives completely and just tweak the config accordingly. I have been able to do this without a noticeable decrease in performance and its saved the load / memory of a few servers on many occasions.

    Also, at compile time, don't compile in modules for apache and php that you don't need. Things such as mod_gzip will increase resources, and loading modules just doesn't help.

    The best thing to do would be to monitor the setting at the servers peak times and make changes as necessary.
     
  3. Secret Agent

    Secret Agent Guest

    Thanks for your reply. So, do you suggest turning keepalive off?

    I'm debating like its no tomorrow :) I dont' want any more apache crashes like this and yet don't want to decrease performance.

    I also do not have mod_gzip enabled either ;)

    Also, turning it back from 100 to 0, did you really mean MaxKeepAliveRequests or MaxRequestsPerChild (this is what I originally changed from 0 to 100)
     
    #3 Secret Agent, Apr 10, 2005
    Last edited by a moderator: Apr 10, 2005
  4. haze

    haze Well-Known Member

    Joined:
    Dec 21, 2001
    Messages:
    1,550
    Likes Received:
    3
    Trophy Points:
    38
    Trial an error my friend, give it a shot, but also make sure to raise the startservers, and min/max spareservers by a couple as well.

    I was.. uh.. just testing you to make sure you were awake.. yeah thats it!

    Keep them default, IMHO. That is, unless you feel the need to adjust them to help with your performance issues.

    It may take a few days to get something that works. You may also want to consider using a more powerfull cpu or adding more ram if that is causing a bottleneck. Also, remember to optomize your my.cnf as that will use up a lot of resources or not enough if improperly configured.

    What are the specs of the cpu ? how much ram ? what does "mysqladmin status" show during peak usage time ? What about free ? Are you using any sort of caching software such as mmcache, zend, etc ? Whats the server load like at peak and beyond ? Whats your /etc/my.cnf look like currently, and what version of mysql ? What OS? All these and more will play a factor in what settings you might want to trial first. If you can provide the above info, and any other details you think might be worthy of pointing out, i'll see if i can't work something up to at least help get your foot in the door.
     
  5. Secret Agent

    Secret Agent Guest

    Thanks :)

    My Specs:
    Dual Xeon 2.4GHz HT
    2GB ECC Memory
    100MBps Port
    Fedora Core 2

    Installed:
    Mod Throttle
    Zend Optimizer 2.5.7
    MySQL 4.1.8standard
    APF / BFD
    Mod Security
    Spam Assassin (enabled - even though it does take up some load occassionally, people want it)

    /etc/my.cnf

    [mysqld]
    port = 3306
    skip-locking
    skip-innodb
    query_cache_limit=1M
    query_cache_size=32M
    query_cache_type=1
    max_connections=500
    interactive_timeout=100
    wait_timeout=100
    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_concurrency
    thread_concurrency=2
    myisam_sort_buffer_size=64M
    #log-bin
    server-id=1

    [mysqld_safe]
    open_files_limit = 8192
    err-log=/var/log/mysqld.log
    pid-file=/var/lib/mysql/mysql.pid

    [mysqldump]
    quick
    max_allowed_packet = 16M

    [myisamchk]
    key_buffer = 64M
    sort_buffer = 64M
    read_buffer = 16M
    write_buffer = 16M

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

    [isamchk]
    key_buffer = 64M
    sort_buffer_size = 64M
    read_buffer = 16M
    write_buffer = 16M

    [myisamchk]
    key_buffer = 64M
    sort_buffer = 64M
    read_buffer = 16M
    write_buffer = 16M

    [mysqlhotcopy]
    interactive-timeout


    When Apache crashed a couple hours ago, the memory load was normal, but cpu load hit nearly 20+, had to restart Apache and MySQL right away or else it would have kept going up.
     
  6. haze

    haze Well-Known Member

    Joined:
    Dec 21, 2001
    Messages:
    1,550
    Likes Received:
    3
    Trophy Points:
    38
    I also need at very least, output of:

    free

    mysqladmin status
     
  7. Secret Agent

    Secret Agent Guest

    Sorry, forgot that

    Code:
    root@server [~]# free
                 total       used       free     shared    buffers     cached
    Mem:       2075096    1962784     112312          0     278244     823064
    -/+ buffers/cache:     861476    1213620
    Swap:      1807304        572    1806732
    
    root@server [~]#
    root@server [~]# mysqladmin status
    Uptime: 302464  Threads: 3  Questions: 6465299  Slow queries: 13  Opens: 58507  Flush tables: 1  Open tables: 1023  Queries per second avg: 21.375
    
     
  8. Secret Agent

    Secret Agent Guest

    I was thining about eaccelerator too, with Zend. What do you say?
     
  9. haze

    haze Well-Known Member

    Joined:
    Dec 21, 2001
    Messages:
    1,550
    Likes Received:
    3
    Trophy Points:
    38
    How many sites do you have on the server ? Are they all or most using mysql ? Is this a general purpose web hosting server or is it dedicated to a few select web sites ?
     
  10. Secret Agent

    Secret Agent Guest

    Load just went up again to 10+, quickly ran TOP and saw alot of "exim <defunct>" lines
    and still seeing them now, although load went back down. This happens often.

    Its a general web host server with 80 estimate accounts / domains.

    I do have a lot of mysql databases, probably about 60, but cpu/memory/mysql usage never shows anything in red or yellow - for averages. If there were intense mysql usage, it normally shows.
     
  11. haze

    haze Well-Known Member

    Joined:
    Dec 21, 2001
    Messages:
    1,550
    Likes Received:
    3
    Trophy Points:
    38
    Ok, before implementing this, can you paste the output of "mysqladmin extend" and "mysqladmin variables".


    This should do you fine for now, but might need some further tweaking:
    Code:
     
    [mysqld]
    port = 3306
    skip-locking
    skip-innodb
    query_cache_limit=1M
    query_cache_size=32M
    query_cache_type=1
    max_connections=500
    interactive_timeout=100
    wait_timeout=100
    connect_timeout=10
    thread_cache_size=32
    key_buffer_size=128M
    join_buffer_size=1M
    max_allowed_packet=4M
    table_cache=2048
    #record_buffer=1M <- replaced with read_buffer_size
    sort_buffer_size=2M
    read_buffer_size=1M
    max_connect_errors=10
    # Try number of CPU's*2 for thread_concurrency
    thread_concurrency=4
    myisam_sort_buffer_size=32M
    #log-bin
    server-id=1
    
    [mysqld_safe]
    open_files_limit = 8192
    err-log=/var/log/mysqld.log
    pid-file=/var/lib/mysql/mysql.pid
    
    [mysqldump]
    quick
    max_allowed_packet = 16M
    
    [mysql]
    no-auto-rehash
    # Remove the next comment character if you are not familiar with SQL
    #safe-updates
    
    [isamchk]
    key_buffer_size = 64M
    sort_buffer_size = 64M
    read_buffer_size = 4M
    write_buffer_size = 4M
    
    [myisamchk]
    key_buffer_size = 64M
    sort_buffer_size = 64M
    read_buffer_size = 4M
    write_buffer_size = 4M
    
    [mysqlhotcopy]
    interactive-timeout
    
    Remember to backup your current config just incase, and restart mysql after you've made these changes.
     
  12. Secret Agent

    Secret Agent Guest

    Code:
    root@server [~]# mysqladmin extend
    +--------------------------+------------+
    | Variable_name            | Value      |
    +--------------------------+------------+
    | Aborted_clients          | 2408       |
    | Aborted_connects         | 12477      |
    | Binlog_cache_disk_use    | 0          |
    | Binlog_cache_use         | 0          |
    | Bytes_received           | 1160146819 |
    | Bytes_sent               | 1827326755 |
    | Com_admin_commands       | 6067       |
    | Com_alter_db             | 0          |
    | Com_alter_table          | 35         |
    | Com_analyze              | 0          |
    | Com_backup_table         | 0          |
    | Com_begin                | 180        |
    | Com_change_db            | 455231     |
    | Com_change_master        | 0          |
    | Com_check                | 560        |
    | Com_checksum             | 0          |
    | Com_commit               | 234        |
    | Com_create_db            | 31         |
    | Com_create_function      | 0          |
    | Com_create_index         | 654        |
    | Com_create_table         | 2162       |
    | Com_dealloc_sql          | 0          |
    | Com_delete               | 64691      |
    | Com_delete_multi         | 0          |
    | Com_do                   | 0          |
    | Com_drop_db              | 20         |
    | Com_drop_function        | 0          |
    | Com_drop_index           | 0          |
    | Com_drop_table           | 1536       |
    | Com_drop_user            | 0          |
    | Com_execute_sql          | 0          |
    | Com_flush                | 3840       |
    | Com_grant                | 2125       |
    | Com_ha_close             | 0          |
    | Com_ha_open              | 0          |
    | Com_ha_read              | 0          |
    | Com_help                 | 0          |
    | Com_insert               | 677335     |
    | Com_insert_select        | 1627       |
    | Com_kill                 | 0          |
    | Com_load                 | 0          |
    | Com_load_master_data     | 0          |
    | Com_load_master_table    | 0          |
    | Com_lock_tables          | 67851      |
    | Com_optimize             | 480        |
    | Com_preload_keys         | 0          |
    | Com_prepare_sql          | 0          |
    | Com_purge                | 0          |
    | Com_purge_before_date    | 0          |
    | Com_rename_table         | 0          |
    | Com_repair               | 0          |
    | Com_replace              | 15971      |
    | Com_replace_select       | 0          |
    | Com_reset                | 0          |
    | Com_restore_table        | 0          |
    | Com_revoke               | 2          |
    | Com_revoke_all           | 0          |
    | Com_rollback             | 0          |
    | Com_savepoint            | 0          |
    | Com_select               | 1226984    |
    | Com_set_option           | 49352      |
    | Com_show_binlog_events   | 0          |
    | Com_show_binlogs         | 24         |
    | Com_show_charsets        | 287        |
    | Com_show_collations      | 287        |
    | Com_show_column_types    | 0          |
    | Com_show_create_db       | 32         |
    | Com_show_create_table    | 20961      |
    | Com_show_databases       | 2840       |
    | Com_show_errors          | 0          |
    | Com_show_fields          | 22464      |
    | Com_show_grants          | 3673       |
    | Com_show_innodb_status   | 0          |
    | Com_show_keys            | 69         |
    | Com_show_logs            | 0          |
    | Com_show_master_status   | 0          |
    | Com_show_new_master      | 0          |
    | Com_show_open_tables     | 0          |
    | Com_show_privileges      | 0          |
    | Com_show_processlist     | 1027       |
    | Com_show_slave_hosts     | 0          |
    | Com_show_slave_status    | 0          |
    | Com_show_status          | 2          |
    | Com_show_storage_engines | 0          |
    | Com_show_tables          | 394763     |
    | Com_show_variables       | 2304       |
    | Com_show_warnings        | 0          |
    | Com_slave_start          | 0          |
    | Com_slave_stop           | 0          |
    | Com_truncate             | 6          |
    | Com_unlock_tables        | 68198      |
    | Com_update               | 231953     |
    | Com_update_multi         | 6232       |
    | Connections              | 254534     |
    | Created_tmp_disk_tables  | 11471      |
    | Created_tmp_files        | 8          |
    | Created_tmp_tables       | 78220      |
    | Delayed_errors           | 0          |
    | Delayed_insert_threads   | 0          |
    | Delayed_writes           | 129        |
    | Flush_commands           | 1          |
    | Handler_commit           | 0          |
    | Handler_delete           | 189270     |
    | Handler_discover         | 0          |
    | Handler_read_first       | 126057     |
    | Handler_read_key         | 20547157   |
    | Handler_read_next        | 29984638   |
    | Handler_read_prev        | 5795495    |
    | Handler_read_rnd         | 2331330    |
    | Handler_read_rnd_next    | 1375056889 |
    | Handler_rollback         | 0          |
    | Handler_update           | 3440890    |
    | Handler_write            | 3973292    |
    | Key_blocks_not_flushed   | 0          |
    | Key_blocks_unused        | 0          |
    | Key_blocks_used          | 14497      |
    | Key_read_requests        | 52603687   |
    | Key_reads                | 338074     |
    | Key_write_requests       | 3119306    |
    | Key_writes               | 2479492    |
    | Max_used_connections     | 152        |
    | Not_flushed_delayed_rows | 0          |
    | Open_files               | 1929       |
    | Open_streams             | 0          |
    | Open_tables              | 1024       |
    | Opened_tables            | 59058      |
    | Qcache_free_blocks       | 4167       |
    | Qcache_free_memory       | 14420440   |
    | Qcache_hits              | 2978187    |
    | Qcache_inserts           | 1115407    |
    | Qcache_lowmem_prunes     | 330071     |
    | Qcache_not_cached        | 104616     |
    | Qcache_queries_in_cache  | 13361      |
    | Qcache_total_blocks      | 32025      |
    | Questions                | 6551279    |
    | Rpl_status               | NULL       |
    | Select_full_join         | 11886      |
    | Select_full_range_join   | 0          |
    | Select_range             | 22492      |
    | Select_range_check       | 19         |
    | Select_scan              | 543818     |
    | Slave_open_temp_tables   | 0          |
    | Slave_running            | OFF        |
    | Slow_launch_threads      | 0          |
    | Slow_queries             | 13         |
    | Sort_merge_passes        | 4          |
    | Sort_range               | 36601      |
    | Sort_rows                | 4416707    |
    | Sort_scan                | 289984     |
    | Table_locks_immediate    | 2661895    |
    | Table_locks_waited       | 127622     |
    | Threads_cached           | 127        |
    | Threads_connected        | 2          |
    | Threads_created          | 3472       |
    | Threads_running          | 1          |
    | Uptime                   | 307215     |
    +--------------------------+------------+
    
    Thank you again
     
  13. Secret Agent

    Secret Agent Guest

    root@server [~]# mysqladmin variables
    file attached (too big to fit here)
     

    Attached Files:

Loading...

Share This Page