limneos

Member
Mar 21, 2004
20
0
151
I have this strange problem I can't understand.

I have about 5-6 user accounts on my server, one of them is quite....busy account.
However, I don't think the server load should be that high.
I get a 40% Cpu usage, and 80% Memory usage from time to time, meaning that CPU is always at RED lights and memory and Yellow.

I have made some optimizations on the /etc/my.cnf file , which I found in a thread in this site, but still I get huge server loads.

Is there any way I can find what exactly is causing it? like....which page, which user , etc?
I'm posting my system configuration below:

Code:
Processor #1 Vendor: GenuineIntel
Processor #1 Name: Intel(R) Pentium(R) 4 CPU 2.40GHz
Processor #1 speed: 2394.202 MHz
Processor #1 cache size: 512 KB

Memory Information:
Memory: 494412k/507068k available (1359k kernel code, 10092k reserved, 1004k data, 132k init, 0k highmem)

hda: MDT MD800BB-00JHA0, ATA DISK drive
hda: attached ide-disk driver.
hda: host protected area => 1
hda: 156301488 sectors (80026 MB) w/2048KiB Cache, CHS=155061/16/63, UDMA(100)


                 total       used       free     shared    buffers     cached
Mem:        496868     491428       5440          0       3644     127436
-/+ buffers/cache:     360348     136520
Swap:      1012084     358568     653516
Total:     1508952     849996     658956

My current server load as we talk is 15.55 (1 cpu).

I also get these:

Code:
User Domain %CPU %MEM Mysql Processes 
mysql  3.80 67.68 0.0 
Top Process %CPU 99.9 /usr/sbin/mysqld --basedir/ --datadir/var/lib/mysql --usermysql --pid-file/var/lib/mysql/server2.mtvgr.com.pid --skip-locking 
Top Process %CPU 79.0 /usr/sbin/mysqld --basedir/ --datadir/var/lib/mysql --usermysql --pid-file/var/lib/mysql/server2.mtvgr.com.pid --skip-locking 
Top Process %CPU 78.0 /usr/sbin/mysqld --basedir/ --datadir/var/lib/mysql --usermysql --pid-file/var/lib/mysql/server2.mtvgr.com.pid --skip-locking
Any help? Please?
Or, in general, an optimization advice?

Thank you all in advance.
 

aby

Well-Known Member
May 31, 2005
638
0
166
India
limneos said:
I have this strange problem I can't understand.

I have about 5-6 user accounts on my server, one of them is quite....busy account.
However, I don't think the server load should be that high.
I get a 40% Cpu usage, and 80% Memory usage from time to time, meaning that CPU is always at RED lights and memory and Yellow.

I have made some optimizations on the /etc/my.cnf file , which I found in a thread in this site, but still I get huge server loads.

Is there any way I can find what exactly is causing it? like....which page, which user , etc?
I'm posting my system configuration below:

Code:
Processor #1 Vendor: GenuineIntel
Processor #1 Name: Intel(R) Pentium(R) 4 CPU 2.40GHz
Processor #1 speed: 2394.202 MHz
Processor #1 cache size: 512 KB

Memory Information:



Memory: 494412k/507068k available (1359k kernel code, 10092k reserved, 1004k data, 132k init, 0k highmem)

hda: MDT MD800BB-00JHA0, ATA DISK drive
hda: attached ide-disk driver.
hda: host protected area => 1
hda: 156301488 sectors (80026 MB) w/2048KiB Cache, CHS=155061/16/63, UDMA(100)


                 total       used       free     shared    buffers     cached
Mem:        496868     491428       5440          0       3644     127436
-/+ buffers/cache:     360348     136520
Swap:      1012084     358568     653516
Total:     1508952     849996     658956

My current server load as we talk is 15.55




(1 cpu).

I also get these:

Code:
User Domain %CPU %MEM Mysql Processes 
mysql  3.80 67.68 0.0 
Top Process %CPU 99.9 /usr/sbin/mysqld --basedir/ --datadir/var/lib/mysql --usermysql --pid-file/var/lib/mysql/server2.mtvgr.com.pid --skip-locking 
Top Process %CPU 79.0 /usr/sbin/mysqld --basedir/ --datadir/var/lib/mysql --usermysql --pid-file/var/lib/mysql/server2.mtvgr.com.pid --skip-locking 
Top Process %CPU 78.0 /usr/sbin/mysqld --basedir/ --datadir/var/lib/mysql --usermysql --pid-file/var/lib/mysql/server2.mtvgr.com.pid --skip-locking
Any help? Please?
Or, in general, an optimization advice?

Thank you all in advance.
You will get some idea from the WHM --- CPU/Memory/MySQL Usage

Also make sure the keep alive option in the httpd.conf is kept off.
KeepAlive Off

Also please monitor which all are the processes running that is taking a quite heavy resources.
 

limneos

Member
Mar 21, 2004
20
0
151
my.cnf is as follows:

Code:
[mysqld]
datadir=/var/lib/mysql
skip-locking
skip-innodb
skip-networking
safe-show-database
query_cache_limit=1M
query_cache_size=16M ## 32MB for every 1GB of RAM
query_cache_type=1
max_user_connections=200
max_connections=500
interactive_timeout=10
wait_timeout=20
connect_timeout=20
thread_cache_size=128
key_buffer=16M ## 32MB for every 1GB of RAM
join_buffer=1M
max_connect_errors=20
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=1M ## 1MB for every 1GB of RAM
read_buffer_size=1M ## 1MB for every 1GB of RAM
read_rnd_buffer_size=1M  ## 1MB for every 1GB of RAM
thread_concurrency=2 ## Number of CPUs x 2
myisam_sort_buffer_size=64M
server-id=1

[mysql.server]
user=mysql
basedir=/var/lib

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

[mysqldump]
quick
max_allowed_packet=16M

[mysql]
no-auto-rehash


httpd.conf is as follows:



Code:
##
Alias /bandwidth/ /usr/local/bandmin/htdocs/
ServerType standalone

ServerRoot "/usr/local/apache"

#LockFile /usr/local/apache/logs/httpd.lock

PidFile /usr/local/apache/logs/httpd.pid

ScoreBoardFile /usr/local/apache/logs/httpd.scoreboard

#ResourceConfig /usr/local/apache/conf/srm.conf
#AccessConfig /usr/local/apache/conf/access.conf

Timeout 300

#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100


KeepAliveTimeout 15


MinSpareServers 5
MaxSpareServers 10


StartServers 5


MaxClients 150


MaxRequestsPerChild 0


#Listen 3000
#Listen 12.34.56.78:80


#BindAddress *


# LoadModule foo_module libexec/mod_foo.so
LoadModule rewrite_module     libexec/mod_rewrite.so
LoadModule expires_module     libexec/mod_expires.so
LoadModule php4_module        libexec/libphp4.so


ClearModuleList
AddModule mod_env.c
AddModule mod_log_config.c
AddModule mod_mime.c
AddModule mod_negotiation.c
AddModule mod_status.c
AddModule mod_include.c
AddModule mod_autoindex.c
AddModule mod_dir.c
AddModule mod_cgi.c
AddModule mod_asis.c
AddModule mod_imap.c
AddModule mod_actions.c
AddModule mod_userdir.c
AddModule mod_alias.c
AddModule mod_rewrite.c
AddModule mod_access.c
AddModule mod_auth.c
AddModule mod_expires.c
AddModule mod_so.c
AddModule mod_setenvif.c
<IfDefine SSL>
AddModule mod_ssl.c
</IfDefine>
AddModule mod_frontpage.c
AddModule mod_php4.c

Port 80


<IfDefine SSL>
Listen 80
Listen 443
</IfDefine>


User nobody
Group nobody


ServerAdmin [email protected]


#ServerName www.example.com


DocumentRoot "/usr/local/apache/htdocs"


<Directory />
Options All
AllowOverride All
</Directory>


<Directory "/usr/local/apache/htdocs">


    Options Indexes FollowSymLinks MultiViews


    AllowOverride None


    Order allow,deny
    Allow from all
</Directory>


<IfModule mod_userdir.c>
    UserDir public_html
</IfModule>



<IfModule mod_dir.c>
DirectoryIndex index.html index.wml index.cgi index.shtml index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml index.htm default.htm default.html home.htm
</IfModule>


AccessFileName .htaccess


<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>



UseCanonicalName On


<IfModule mod_mime.c>
    TypesConfig /usr/local/apache/conf/mime.types
</IfModule>


DefaultType text/plain


<IfModule mod_mime_magic.c>
    MIMEMagicFile /usr/local/apache/conf/magic
</IfModule>


HostnameLookups Off


ErrorLog /usr/local/apache/logs/error_log


LogLevel warn


LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent


CustomLog /usr/local/apache/logs/access_log common



ServerSignature On




<IfModule mod_alias.c>

 
    Alias /icons/ "/usr/local/apache/icons/"

    <Directory "/usr/local/apache/icons">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    
    Alias /manual/ "/usr/local/apache/htdocs/manual/"

    <Directory "/usr/local/apache/htdocs/manual">
        Options Indexes FollowSymlinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

 
    ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

  
    <Directory "/usr/local/apache/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

</IfModule>



<IfModule mod_autoindex.c>


    AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

    AddIconByType (TXT,/icons/text.gif) text/*
    AddIconByType (IMG,/icons/image2.gif) image/*
    AddIconByType (SND,/icons/sound2.gif) audio/*
    AddIconByType (VID,/icons/movie.gif) video/*

    AddIcon /icons/binary.gif .bin .exe
    AddIcon /icons/binhex.gif .hqx
    AddIcon /icons/tar.gif .tar
    AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
    AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
    AddIcon /icons/a.gif .ps .ai .eps
    AddIcon /icons/layout.gif .html .shtml .htm .pdf
    AddIcon /icons/text.gif .txt
    AddIcon /icons/c.gif .c
    AddIcon /icons/p.gif .pl .py
    AddIcon /icons/f.gif .for
    AddIcon /icons/dvi.gif .dvi
    AddIcon /icons/uuencoded.gif .uu
    AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
    AddIcon /icons/tex.gif .tex
    AddIcon /icons/bomb.gif core

    AddIcon /icons/back.gif ..
    AddIcon /icons/hand.right.gif README
    AddIcon /icons/folder.gif ^^DIRECTORY^^
    AddIcon /icons/blank.gif ^^BLANKICON^^

 
    DefaultIcon /icons/unknown.gif

    ReadmeName README.html
    HeaderName HEADER.html


    IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

</IfModule>



<IfModule mod_mime.c>

    AddLanguage da .dk
    AddLanguage nl .nl
    AddLanguage en .en
    AddLanguage et .ee
    AddLanguage fr .fr
    AddLanguage de .de
    AddLanguage el .el
    AddLanguage he .he
    AddCharset ISO-8859-8 .iso8859-8
    AddLanguage it .it
    AddLanguage ja .ja
    AddCharset ISO-2022-JP .jis
    AddLanguage kr .kr
    AddCharset ISO-2022-KR .iso-kr
    AddLanguage nn .nn
    AddLanguage no .no
    AddLanguage pl .po
    AddCharset ISO-8859-2 .iso-pl
    AddLanguage pt .pt
    AddLanguage pt-br .pt-br
    AddLanguage ltz .lu
    AddLanguage ca .ca
    AddLanguage es .es
    AddLanguage sv .sv
    AddLanguage cs .cz .cs
    AddLanguage ru .ru
    AddLanguage zh-TW .zh-tw
    AddCharset Big5         .Big5    .big5
    AddCharset WINDOWS-1251 .cp-1251
    AddCharset CP866        .cp866
    AddCharset ISO-8859-5   .iso-ru
    AddCharset KOI8-R       .koi8-r
    AddCharset UCS-2        .ucs2
    AddCharset UCS-4        .ucs4
    AddCharset UTF-8        .utf8

   
    <IfModule mod_negotiation.c>
        LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
    </IfModule>


    AddType application/x-tar .tgz

    AddEncoding x-compress .Z
    AddEncoding x-gzip .gz .tgz

AddType application/x-httpd-php .php
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php3
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .phtml
AddHandler cgi-script .cgi .pl
AddType text/html .shtml
AddType application/x-tar .tgz
AddType text/vnd.wap.wml .wml
AddType image/vnd.wap.wbmp .wbmp
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlc .wmlc
AddType application/vnd.wap.wmlscriptc .wmlsc


AddHandler server-parsed .shtml



</IfModule>

<IfModule mod_setenvif.c>


    BrowserMatch "Mozilla/2" nokeepalive
    BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

    BrowserMatch "RealPlayer 4\.0" force-response-1.0
    BrowserMatch "Java/1\.0" force-response-1.0
    BrowserMatch "JDK/1\.0" force-response-1.0

</IfModule>

<IfDefine SSL>
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl
</IfDefine>

<IfModule mod_ssl.c>

SSLPassPhraseDialog  builtin

SSLSessionCache         dbm:/usr/local/apache/logs/ssl_scache
SSLSessionCacheTimeout  300
SSLMutex  file:/usr/local/apache/logs/ssl_mutex


SSLRandomSeed startup builtin
SSLRandomSeed connect builtin

SSLLog      /usr/local/apache/logs/ssl_engine_log
SSLLogLevel info

</IfModule>

<IfDefine SSL>




</IfDefine>

As for the php cacheing software, do you mean something like Zend Optimizer?
If not, could you give me an example?

Thank you
 

jester.ro

Well-Known Member
PartnerNOC
Feb 6, 2004
303
0
166
Bucharest, Romania
cPanel Access Level
DataCenter Provider
first of all, set KeepAlive to Off

second, install eaccelerator, and give it 16 MB for caching, cose you only have 512 megs of ram.

You could also try upgrading to 1 Gb ram, 512 is too little for a cpanel server.
 

panayot

Well-Known Member
Nov 18, 2004
127
0
166
table_cache=1024

this seems too high to me. On a 1 GB ram server I use 700. Here is from mysql recommendation (my-large.cnf)

# Example MySQL config file for large systems.
#
# This is for a large system with memory = 512M where the system runs mainly
# MySQL

key_buffer = 256M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache = 8
query_cache_size= 16M


Actually on my server I decreased key_buffer to 100M and this did not reduce the percentage of cached keys (99.96%) so you can experiment and calculate the ratio by looking at

mysqladmin extended-status