Tuning httpd

Discussion in 'Apache' started by web@master24, Aug 26, 2009.

  1. #1
    Hi, i need some help modifying the httpd.conf, because my server always is overload and have 3gb ram and consume all. Here are some values:

    My server:
    Intel(R) Pentium(R) CPU E5400 @ 2.70GHz
    3gb ram
    320gb HD

    TOP:

    top - 05:57:05 up 3 days, 10:52, 1 user, load average: 0.29, 0.42, 0.42
    Tasks: 220 total, 3 running, 217 sleeping, 0 stopped, 0 zombie
    Cpu(s): 14.8%us, 3.9%sy, 0.0%ni, 81.0%id, 0.0%wa, 0.2%hi, 0.2%si, 0.0%st
    Mem: 3085240k total, 2520452k used, 564788k free, 373528k buffers
    Swap: 2048276k total, 18236k used, 2030040k free, 1622376k cached

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    20139 apache 15 0 26696 13m 3576 S 3.3 0.4 0:00.96 httpd
    20177 apache 15 0 25876 12m 3588 S 2.7 0.4 0:00.96 httpd
    20182 apache 15 0 26220 12m 3324 S 2.7 0.4 0:00.55 httpd
    20163 apache 15 0 25916 12m 3564 S 2.3 0.4 0:00.52 httpd
    5613 mysql 5 -10 555m 162m 4088 S 2.0 5.4 4:20.33 mysqld
    7219 mysql 5 -10 555m 162m 4088 S 2.0 5.4 3:48.84 mysqld
    10098 mysql 6 -10 555m 162m 4088 S 2.0 5.4 2:48.63 mysqld
    5617 mysql 6 -10 555m 162m 4088 S 1.7 5.4 4:21.51 mysqld
    5611 mysql 5 -10 555m 162m 4088 S 1.0 5.4 4:23.46 mysqld
    16325 mysql 5 -10 555m 162m 4088 S 1.0 5.4 1:12.34 mysqld
    20140 apache 16 0 26444 12m 3544 S 1.0 0.4 0:00.57 httpd
    4021 mysql 5 -10 555m 162m 4088 S 0.7 5.4 4:53.29 mysqld
    20019 apache 15 0 26472 12m 3560 S 0.7 0.4 0:00.75 httpd
    20096 apache 15 0 27036 13m 3596 S 0.7 0.4 0:02.13 httpd
    20109 apache 15 0 26448 12m 3620 S 0.7 0.4 0:00.88 httpd
    20159 apache 16 0 26168 12m 3552 S 0.7 0.4 0:00.45 httpd
    20166 apache 15 0 26132 12m 3544 S 0.7 0.4 0:00.30 httpd
    20186 apache 15 0 26896 13m 3536 S 0.7 0.4 0:00.34 httpd
    20202 apache 15 0 26140 12m 3348 S 0.7 0.4 0:00.02 httpd
    20207 apache 15 0 25860 11m 3500 S 0.7 0.4 0:00.02 httpd
    20210 apache 15 0 25996 12m 3516 S 0.7 0.4 0:00.02 httpd
    20211 root 15 0 2328 1088 796 R 0.7 0.0 0:00.03 top
    19573 mysql 5 -10 555m 162m 4088 S 0.3 5.4 3:05.55 mysqld
    19848 apache 15 0 26896 13m 3636 S 0.3 0.4 0:02.13 httpd
    19938 apache 15 0 26388 12m 3832 S 0.3 0.4 0:01.71 httpd
    20084 apache 16 0 26728 13m 3864 S 0.3 0.4 0:01.10 httpd
    20117 apache 15 0 26692 12m 3596 S 0.3 0.4 0:01.17 httpd
    20124 apache 16 0 25908 12m 3560 S 0.3 0.4 0:00.82 httpd
    20125 apache 16 0 26004 12m 3516 S 0.3 0.4 0:00.17 httpd
    20133 apache 15 0 26428 12m 3552 S 0.3 0.4 0:00.41 httpd
    20149 apache 15 0 26120 12m 3564 S 0.3 0.4 0:00.49 httpd
    20171 apache 15 0 26148 12m 3564 S 0.3 0.4 0:00.33 httpd
    20187 apache 16 0 26132 12m 3564 S 0.3 0.4 0:00.38 httpd
    20199 apache 15 0 26696 12m 3532 S 0.3 0.4 0:00.13 httpd
    20200 apache 15 0 26672 12m 3552 S 0.3 0.4 0:00.15 httpd
    20201 apache 15 0 25604 11m 3512 S 0.3 0.4 0:00.03 httpd
    1 root 15 0 2064 556 524 S 0.0 0.0 0:01.92 init
    2 root RT -5 0 0 0 S 0.0 0.0 0:00.07 migration/0
    3 root 39 19 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/0

    FREE -M:

    total used free shared buffers cached
    Mem: 3012 2448 564 0 364 1584
    -/+ buffers/cache: 499 2513
    Swap: 2000 17 1982

    here are a sh tuning-primer.sh results:

    SLOW QUERIES
    The slow query log is NOT enabled.
    Current long_query_time = 10 sec.
    You have 2 out of 23847824 that take longer than 10 sec. to complete
    Your long_query_time may be too high, I typically set this under 5 sec.

    BINARY UPDATE LOG
    The binary update log is enabled
    The expire_logs_days is not set.
    The mysqld will retain the entire binary log until RESET MASTER or PURGE MASTER LOGS commands are run manually
    Setting expire_logs_days will allow you to remove old binary logs automatically
    See http://dev.mysql.com/doc/refman/5.0/en/purge-master-logs.html
    Binlog sync is not enabled, you could loose binlog records during a server crash

    WORKER THREADS
    Current thread_cache_size = 8
    Current threads_cached = 6
    Current threads_per_sec = 0
    Historic threads_per_sec = 0
    Your thread_cache_size is fine

    MAX CONNECTIONS
    Current max_connections = 100
    Current threads_connected = 1
    Historic max_used_connections = 47
    The number of used connections is 47% of the configured maximum.
    Your max_connections variable seems to be fine.

    MEMORY USAGE
    Max Memory Ever Allocated : 1.02 G
    Configured Max Per-thread Buffers : 1.10 G
    Configured Max Global Buffers : 522 M
    Configured Max Memory Limit : 1.61 G
    Physical Memory : 2.94 G
    Max memory limit seem to be within acceptable norms

    KEY BUFFER
    Current MyISAM index space = 23 M
    Current key_buffer_size = 256 M
    Key cache miss rate is 1 : 1522
    Key buffer free ratio = 87 %
    Your key_buffer_size seems to be fine

    QUERY CACHE
    Query cache is enabled
    Current query_cache_size = 256 M
    Current query_cache_used = 17 M
    Current query_cache_limit = 1 M
    Current Query cache Memory fill ratio = 6.99 %
    Current query_cache_min_res_unit = 4 K
    Your query_cache_size seems to be too high.
    Perhaps you can use these resources elsewhere
    MySQL won't cache query results that are larger than query_cache_limit in size

    SORT OPERATIONS
    Current sort_buffer_size = 2 M
    Current read_rnd_buffer_size = 8 M
    Sort buffer seems to be fine

    JOINS
    Current join_buffer_size = 132.00 K
    You have had 53 queries where a join could not use an index properly
    You should enable "log-queries-not-using-indexes"
    Then look for non indexed joins in the slow query log.
    If you are unable to optimize your queries you may want to increase your
    join_buffer_size to accommodate larger joins in one pass.

    Note! This script will still suggest raising the join_buffer_size when
    ANY joins not using indexes are found.

    OPEN FILES LIMIT
    Current open_files_limit = 5910 files
    The open_files_limit should typically be set to at least 2x-3x
    that of table_cache if you have heavy MyISAM usage.
    Your open_files_limit value seems to be fine

    TABLE CACHE
    Current table_cache value = 2900 tables
    You have a total of 461 tables
    You have 501 open tables.
    The table_cache value seems to be fine

    TEMP TABLES
    Current max_heap_table_size = 16 M
    Current tmp_table_size = 32 M
    Of 2953576 temp tables, 9% were created on disk
    Effective in-memory tmp_table_size is limited to max_heap_table_size.
    Created disk tmp tables ratio seems fine

    TABLE SCANS
    Current read_buffer_size = 1 M
    Current table scan ratio = 518 : 1
    read_buffer_size seems to be fine

    TABLE LOCKING
    Current Lock Wait ratio = 1 : 60
    You may benefit from selective use of InnoDB.
    If you have long running SELECT's against MyISAM tables and perform
    frequent updates consider setting 'low_priority_updates=1'
    If you have a high concurrency of inserts on Dynamic row-length tables
    consider setting 'concurrent_insert=2'.


    and here are some values of my httpd.conf:

    # Server-Pool Management (MPM specific)
    #

    #
    # PidFile: The file in which the server should record its process
    # identification number when it starts.
    #
    # Note that this is the default PidFile for most MPMs.
    #
    <IfModule !mpm_netware_module>
    PidFile "/var/run/httpd.pid"
    </IfModule>

    #
    # The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
    #
    <IfModule !mpm_winnt_module>
    <IfModule !mpm_netware_module>
    LockFile /var/logs/accept.lock
    </IfModule>
    </IfModule>

    #
    # Only one of the below sections will be relevant on your
    # installed httpd. Use "apachectl -l" to find out the
    # active mpm.
    #

    # prefork MPM
    # StartServers: number of server processes to start
    # MinSpareServers: minimum number of server processes which are kept spare
    # MaxSpareServers: maximum number of server processes which are kept spare
    # MaxClients: maximum number of server processes allowed to start
    # MaxRequestsPerChild: maximum number of requests a server process serves

    <IfModule mpm_prefork_module>
    StartServers 5
    MinSpareServers 5
    MaxSpareServers 10
    ServerLimit 450
    MaxClients 450
    MaxRequestsPerChild 10000
    </IfModule>

    # worker 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_worker_module>
    StartServers 2
    ServerLimit 450
    MaxClients 450
    MinSpareThreads 25
    MaxSpareThreads 75
    ThreadsPerChild 25
    MaxRequestsPerChild 10000
    </IfModule>

    # BeOS MPM
    # StartThreads: how many threads do we initially spawn?
    # MaxClients: max number of threads we can have (1 thread == 1 client)
    # MaxRequestsPerThread: maximum number of requests each thread will process
    <IfModule mpm_beos_module>
    StartThreads 10
    MaxClients 50
    MaxRequestsPerThread 10000
    </IfModule>

    # NetWare MPM
    # ThreadStackSize: Stack size allocated for each worker thread
    # StartThreads: Number of worker threads launched at server startup
    # MinSpareThreads: Minimum number of idle threads, to handle request spikes
    # MaxSpareThreads: Maximum number of idle threads
    # MaxThreads: Maximum number of worker threads alive at the same time
    # MaxRequestsPerChild: Maximum number of requests a thread serves. It is
    # recommended that the default value of 0 be set for this
    # directive on NetWare. This will allow the thread to
    # continue to service requests indefinitely.
    <IfModule mpm_netware_module>
    ThreadStackSize 65536
    StartThreads 250
    MinSpareThreads 25
    MaxSpareThreads 250
    MaxThreads 1000
    MaxRequestsPerChild 10000
    MaxMemFree 100
    </IfModule>

    # OS/2 MPM
    # StartServers: Number of server processes to maintain
    # MinSpareThreads: Minimum number of idle threads per process,
    # to handle request spikes
    # MaxSpareThreads: Maximum number of idle threads per process
    # MaxRequestsPerChild: Maximum number of connections per server process
    <IfModule mpm_mpmt_os2_module>
    StartServers 2
    MinSpareThreads 5
    MaxSpareThreads 10
    MaxRequestsPerChild 10000
    </IfModule>



    i hope somebody can help me because i dont know about dedicated, is my first and im learning. Thanks in advance
     
    Last edited: Aug 26, 2009
    web@master24, Aug 26, 2009 IP
  2. rathin

    rathin Peon

    Messages:
    1,377
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    why u need to tweek there is no load is server

    also come to ram usage in linux server all ram will be used under cached

    free -m here u can see the cached useage that the real useage of the ram
     
    rathin, Aug 26, 2009 IP
  3. web@master24

    web@master24 Active Member

    Messages:
    418
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    90
    #3
    The server oveload sometime to 100, yesterday overload and the users online was the same when no are overloas, here a top from was overload:

    top - 18:16:29 up 3 days, 23:11, 1 user, load average: 72.22, 83.54, 82.59
    Tasks: 420 total, 38 running, 381 sleeping, 0 stopped, 1 zombie
    Cpu(s): 85.0%us, 13.8%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.2%hi, 1.0%si, 0.0%st
    Mem: 3085240k total, 2972836k used, 112404k free, 361560k buffers
    Swap: 2048276k total, 17776k used, 2030500k free, 1590984k cached

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    30437 mysql 6 -10 563m 168m 4088 R 16.4 5.6 0:00.56 mysqld
    27682 apache 16 0 26472 13m 4260 R 16.1 0.4 0:04.22 httpd
    28173 apache 16 0 25884 12m 3844 S 6.0 0.4 0:02.60 httpd
    27713 apache 16 0 25884 12m 3856 S 5.0 0.4 0:03.21 httpd
    27259 apache 15 0 29952 14m 3880 S 4.4 0.5 0:03.66 httpd
    28118 apache 15 0 25884 12m 3844 S 4.4 0.4 0:01.67 httpd
    28615 apache 16 0 25960 12m 3788 S 4.4 0.4 0:02.56 httpd
    28614 apache 15 0 27228 13m 3796 S 4.1 0.5 0:01.31 httpd
    28754 apache 15 0 25744 12m 3816 S 4.1 0.4 0:02.16 httpd
    28769 apache 15 0 25884 12m 3860 S 4.1 0.4 0:02.01 httpd
    28676 apache 15 0 26036 12m 3796 S 3.8 0.4 0:02.15 httpd
    28193 apache 15 0 26044 12m 3844 S 3.5 0.4 0:03.19 httpd
    28208 apache 15 0 31896 18m 4268 S 3.5 0.6 0:02.56 httpd
    26936 apache 15 0 26496 13m 4200 S 3.2 0.4 0:03.93 httpd
    27730 apache 15 0 26428 13m 3860 S 3.2 0.4 0:02.79 httpd
    29898 apache 15 0 25884 12m 3796 S 3.2 0.4 0:00.47 httpd
    30382 apache 15 0 25724 12m 3544 S 3.2 0.4 0:00.22 httpd
    28590 apache 15 0 26396 12m 3584 R 2.8 0.4 0:03.32 httpd
    28755 apache 15 0 25948 12m 3832 S 2.8 0.4 0:01.81 httpd
    28767 apache 16 0 30736 15m 3840 R 2.8 0.5 0:01.81 httpd
    26341 apache 15 0 26516 13m 3868 S 2.5 0.4 0:04.22 httpd
    28206 apache 15 0 25732 12m 3820 S 2.5 0.4 0:02.93 httpd
    29571 apache 15 0 25884 12m 3556 S 2.5 0.4 0:00.45 httpd
    26579 apache 15 0 27196 13m 3816 S 2.2 0.4 0:04.58 httpd
    26596 apache 15 0 26028 12m 3852 S 2.2 0.4 0:04.34 httpd
    27727 apache 15 0 26716 13m 3812 S 2.2 0.4 0:03.05 httpd
    28596 apache 16 0 25884 12m 3840 S 2.2 0.4 0:01.78 httpd
    30491 mysql 5 -10 563m 168m 4088 S 2.2 5.6 0:00.07 mysqld
    26796 apache 15 0 26300 13m 4064 S 1.9 0.4 0:05.77 httpd
    27176 apache 15 0 25884 12m 3852 S 1.9 0.4 0:03.87 httpd
    28191 apache 15 0 28248 13m 4308 S 1.9 0.4 0:02.26 httpd
    29555 apache 15 0 27228 13m 3760 S 1.9 0.4 0:00.58 httpd
    27261 apache 15 0 26000 12m 3860 S 1.6 0.4 0:02.79 httpd
    28669 apache 15 0 26140 12m 3844 S 1.6 0.4 0:01.60 httpd
    28764 apache 15 0 25948 12m 3828 S 1.6 0.4 0:02.06 httpd
    26324 apache 15 0 28220 13m 4300 S 1.3 0.4 0:07.58 httpd
    26467 apache 15 0 28832 13m 3920 S 1.3 0.4 0:03.23 httpd
    27258 apache 15 0 25884 12m 3844 S 1.3 0.4 0:05.16 httpd
    28197 apache 15 0 30144 15m 4292 S 1.3 0.5 0:03.16 httpd
     
    web@master24, Aug 27, 2009 IP
  4. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #4
    RHS-Chris, Aug 27, 2009 IP
  5. SecureCP

    SecureCP Guest

    Messages:
    226
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You should also check out the output of netstat -nut and see if there's anything interesting going on there.
     
    SecureCP, Aug 30, 2009 IP