|
Optimisation help needed
|
Posts: 3
Group: Registered
Joined: Oct 2006
Status:
Offline
Reputation: 0
|
Optimisation help needed
Hi all,
as all other questions, I need assistance in the tuning of our dedicated server.
The box:
Dell™ SC430 Server
Intel Pentium 4 D 2.8 Ghz (Dual Core)
1024MB DDR2 RAM PC 4300 ECC (Dual Channel)
80GB 7200 RPM S-ATA II
100 Mbit
Debian Sarge
Programs:
Apache/2.0.54 (Debian GNU/Linux) PHP/4.3.10-16 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_perl/1.999.21 Perl/v5.8.4
MySQL - 4.0.24
PHP Version 4.3.10-16
eAccelerator v0.9.5
Exim4
ps aux | head -1; ps aux | sort -rn +2 | head (output)
www-data 31649 0.9 1.5 415152 16336 ? S 10:34 0:01 /usr/sbin/apache2 -k start -DSSL
www-data 31659 0.8 1.6 415100 17220 ? S 10:34 0:01 /usr/sbin/apache2 -k start -DSSL
www-data 31627 0.7 1.6 415092 16680 ? S 10:33 0:01 /usr/sbin/apache2 -k start -DSSL
www-data 31533 0.6 1.7 415248 17848 ? S 10:29 0:02 /usr/sbin/apache2 -k start -DSSL
www-data 31303 0.5 2.0 415140 20864 ? S 10:17 0:06 /usr/sbin/apache2 -k start -DSSL
www-data 31706 0.3 1.0 412848 10884 ? S 10:35 0:00 /usr/sbin/apache2 -k start -DSSL
www-data 31676 0.2 1.1 412732 11572 ? S 10:34 0:00 /usr/sbin/apache2 -k start -DSSL
www-data 31529 0.2 1.5 415016 16224 ? S 10:29 0:01 /usr/sbin/apache2 -k start -DSSL
www-data 31418 0.2 1.6 415044 17368 ? S 10:22 0:01 /usr/sbin/apache2 -k start -DSSL
ps aux | head -1; ps aux | sort -rn +3 | head (output)
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
mysql 23299 29.6 4.6 119320 48568 ? S Nov05 580:39 /usr/sbin/mysqld --basedir=/usr --datadir= /var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/va r/run/mysqld/mysqld.sock
root 20079 0.0 2.3 26740 24116 ? Ss Nov04 0:00 /usr/sbin/spamd --create-prefs --max-child ren 5 --helper-home-dir -d --pidfile=/var/run/spamd.pid
root 20142 0.0 2.1 26740 22664 ? S Nov04 0:00 spamd child
root 20141 0.0 2.1 26740 22664 ? S Nov04 0:00 spamd child
root 20099 0.0 2.1 26740 22664 ? S Nov04 0:00 spamd child
root 20098 0.0 2.1 26740 22664 ? S Nov04 0:00 spamd child
root 20097 0.0 2.1 26740 22764 ? S Nov04 0:00 spamd child
www-data 31303 0.5 2.0 415140 20864 ? S 10:17 0:06 /usr/sbin/apache2 -k start -DSSL
www-data 31533 0.6 1.7 415248 17848 ? S 10:29 0:02 /usr/sbin/apache2 -k start -DSSL
www-data 31659 0.6 1.6 415100 17220 ? S 10:34 0:01 /usr/sbin/apache2 -k start -DSSL
/etc/mysql# free -m
total used free shared buffers cached
Mem: 1011 888 122 0 14 726
-/+ buffers/cache: 147 863
Swap: 2588 4 2583
TOP
top - 10:43:15 up 3 days, 18 min, 2 users, load average: 0.70, 0.58, 0.58
Tasks: 64 total, 1 running, 63 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3% us, 0.0% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 1035436k total, 911052k used, 124384k free, 14784k buffers
Swap: 2650684k total, 4832k used, 2645852k free, 745024k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 16 0 1584 516 452 S 0.0 0.0 0:02.13 init
2 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
4 root 10 -5 0 0 0 S 0.0 0.0 0:00.02 events/0
5 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 khelper
6 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kthread
8 root 10 -5 0 0 0 S 0.0 0.0 0:05.78 kblockd/0
9 root 19 -5 0 0 0 S 0.0 0.0 0:00.00 kacpid
114 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 aio/0
113 root 15 0 0 0 0 S 0.0 0.0 0:11.45 kswapd0
712 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kseriod
1042 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khubd
1059 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 ata/0
1992 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0
1995 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_1
3805 root 15 0 0 0 0 S 0.0 0.0 0:09.47 kjournald
3911 root 16 -4 2208 496 320 S 0.0 0.0 0:00.10 udevd
sysctl.conf
# /etc/sysctl.conf - Configuration file for setting system variables
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
#net/ipv4/icmp_echo_ignore_broadcasts=1
I raised the entry in the PHP.ini from 8M -> 20M because of the large scripts we handle..
the performance sucks atm: http://www.diversetrade.com/core
11-06-2006 09:55 AM
|
|
|
 |
Posts: 214
Group: Administrators
Joined: May 2006
Status:
Offline
Reputation: 0
|
RE: Optimisation help needed
The load seems to be fine. If your scripts are running slow, then all you can do is optimize the scripts to run faster. Do they rely on MySQL? And what are they supposed to do.
It's surely the bad code in the PHP scripts you're using. What do the scripts do?
If they rely heavily on MySQL, you can do a few optimizations to speed it up. In that case, post your my.cnf content. Installing APC cache will help a little. But the main thing is the poor code or too much being done at the same time.
11-07-2006 12:24 PM
|
|
|
 |
Posts: 3
Group: Registered
Joined: Oct 2006
Status:
Offline
Reputation: 0
|
RE: Optimisation help needed
The load seems to be fine. If your scripts are running slow, then all you can do is optimize the scripts to run faster. Do they rely on MySQL? And what are they supposed to do.
It's surely the bad code in the PHP scripts you're using. What do the scripts do?
If they rely heavily on MySQL, you can do a few optimizations to speed it up. In that case, post your my.cnf content. Installing APC cache will help a little. But the main thing is the poor code or too much being done at the same time.
I forgot the MySQL config file, my bad. the scripts rely heavily on the mysql server, but moving the mysql to it's own server causes too much latency. We are rewriting the code, but for now, we just need an optimized environment.
this is the my.cnf:
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "/var/lib/mysql/my.cnf" to set server-specific options or
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server...ables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 128K
#
# * Query Cache Configuration
#
query_cache_limit = 1048576
query_cache_size = 16777216
query_cache_type = 1
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
#log = /var/log/mysql.log
#log = /var/log/mysql/mysql.log
#
# Error logging goes to syslog. This is a Debian improvement 
#
# Here you can see queries with especially long duration
#log-slow-queries = /var/log/mysql/mysql-slow.log
#
# The following can be used as easy to replay backup logs or for replication.
#server-id = 1
log-bin = /var/log/mysql/mysql-bin.log
# See /etc/mysql/debian-log-rotate.conf for the number of files kept.
max_binlog_size = 104857600
#binlog-do-db = include_database_name
#binlog-ignore-db = include_database_name
#
# * BerkeleyDB
#
# The use of BerkeleyDB is now discouraged and support for it will probably
# cease in the next versions.
skip-bdb
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Feature
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# If you want to enable SSL support (recommended) read the manual or my
# HOWTO in /usr/share/doc/mysql-server/SSL-MINI-HOWTO.txt.gz
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 16M
11-07-2006 05:01 PM
|
|
|
 |
Posts: 214
Group: Administrators
Joined: May 2006
Status:
Offline
Reputation: 0
|
RE: Optimisation help needed
Can you give a few example mysql queries that you use? Or just give me a general idea of what kind of queries do you use? Have you implemented indexes on your tables?
Try to make these changes (replace mysqld section as specified below) though nothing is going to help you a lot, unless you optimize your queries, PHP code and implement good coding techniques. You should also use mysql indexes if you aren't already using them.
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = 128M
max_allowed_packet = 16M
sort_buffer_size = 2M
join_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size=32M
thread_cache_size = 8
query_cache_size = 64M
query_cache_limit = 1048576
query_cache_type = 1
Watch out for memory usage, it may exhaust real quick and you may need more physical ram. Check if it helps the performance using execution timers (for queries) and then increase physical ram.
The above will only help mysql. For faster php processing, try using APC cache to speed up PHP a bit. (it's a cache software, so while testing don't expect it to be faster on the first visit..)
11-08-2006 01:36 PM
|
|
|
 |
Posts: 3
Group: Registered
Joined: Oct 2006
Status:
Offline
Reputation: 0
|
RE: Optimisation help needed
Thank you:
-I will test this for a while
- what do you mean by " use indexes " ?
- we already use eAccelarator 0.9.5 for PHP caching.
11-09-2006 07:38 AM
|
|
|
 |
Posts: 214
Group: Administrators
Joined: May 2006
Status:
Offline
Reputation: 0
|
RE: Optimisation help needed
11-09-2006 08:40 AM
|
|
|
 |