0

I have server with 2x2 GHz core

but php works very slow on it, I am write syntetic test

for($i=0;$i<10000000;$i++) {
    $x = sqrt($i);
}

generate ~ 30 sec

but on local machine with 2x2Ghz core its generate 2,8 sec

also I try this script at shared hosting - 2,8 sec too

Where power is lost?

processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 65
model name      : Dual-Core AMD Opteron(tm) Processor 2210 HE
stepping        : 2
cpu MHz         : 1749.990
cache size      : 1024 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
apicid          : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips        : 3591.16
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc

processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 65
model name      : Dual-Core AMD Opteron(tm) Processor 2210 HE
stepping        : 2
cpu MHz         : 1749.990
cache size      : 1024 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
apicid          : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips        : 3518.67
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc

 total       used       free     shared    buffers     cached
Mem:          4000       2980       1019          0          0          0
-/+ buffers/cache:       2980       1019
Swap:            0          0          0

top - 14:05:28 up 5 days,  2:45,  2 users,  load average: 2.88, 1.85, 1.43
Tasks:  54 total,   2 running,  52 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.7%us,  1.0%sy,  0.0%ni, 81.4%id, 15.9%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   4096000k total,  3056176k used,  1039824k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
30426 mysql     15   0 2747m 229m 4948 S  3.7  5.7 391:16.83 mysqld
23823 apache    15   0 47212  15m 8920 S  0.7  0.4   0:12.25 httpd
15799 root      15   0  2284 1036  812 R  0.3  0.0   0:00.01 top
    1 root      15   0  2152  660  572 S  0.0  0.0   0:03.43 init
 5150 dovecot   18   0  4988 1828 1512 S  0.0  0.0   0:01.25 pop3-login
 5196 dovecot   18   0  4988 1828 1512 S  0.0  0.0   0:01.24 pop3-login
 9801 dovecot   18   0  4988 1828 1512 S  0.0  0.0   0:01.40 pop3-login
14105 root      15   0 10028 2924 2380 S  0.0  0.1   0:00.03 sshd
14209 root      15   0  3840 1544 1260 S  0.0  0.0   0:00.02 bash
15917 root      18   0  1748  520  448 S  0.0  0.0   0:00.00 vmstat
16086 apache    15   0 49304  20m  11m S  0.0  0.5   0:02.59 httpd
17444 apache    15   0 46964  13m 7232 S  0.0  0.3   0:00.82 httpd
17455 apache    15   0 47172  13m 7008 S  0.0  0.3   0:00.86 httpd
17456 apache    15   0 48912  18m  10m S  0.0  0.5   0:01.97 httpd
17677 apache    15   0 47732  16m   9m S  0.0  0.4   0:01.53 httpd
22489 nginx     18   0  9020 2800  912 D  0.0  0.1   0:09.67 nginx
23602 root      18   0 45960  10m 6092 S  0.0  0.3   0:00.82 httpd
23652 root      15   0 10188 3260 2684 R  0.0  0.1   0:00.15 sshd
23787 apache    15   0 47096  14m 8696 S  0.0  0.4   0:02.66 httpd
23789 apache    17   0 47156  14m 8648 S  0.0  0.4   0:02.76 httpd
23791 apache    15   0 49616  21m  12m S  0.0  0.5   0:03.69 httpd
23802 apache    15   0 47368  15m 8892 S  0.0  0.4   0:03.63 httpd
23818 apache    18   0 47184  14m 7876 S  0.0  0.4   0:03.78 httpd
23827 apache    16   0 47060  13m 7752 S  0.0  0.3   0:02.17 httpd
23840 apache    15   0 46984  14m 7980 S  0.0  0.4   0:02.77 httpd
23850 apache    15   0 47100  14m 8132 S  0.0  0.4   0:03.06 httpd
23871 apache    16   0 50248  21m  11m S  0.0  0.5   0:03.78 httpd
23873 apache    15   0 49548  20m  12m S  0.0  0.5   0:04.11 httpd
23880 apache    16   0 47076  14m 8272 S  0.0  0.4   0:03.39 httpd
24258 root      16   0  3840 1580 1284 S  0.0  0.0   0:00.07 bash
27938 apache    17   0 46252 9200 3524 S  0.0  0.2   0:00.12 httpd
27939 apache    15   0 46952  11m 5880 S  0.0  0.3   0:00.20 httpd
27940 apache    15   0 46944  12m 6380 S  0.0  0.3   0:00.29 httpd
29952 root      15  -4  2244  544  340 S  0.0  0.0   0:00.00 udevd
30273 root      16   0  1808  568  480 D  0.0  0.0   0:01.93 syslogd
30297 named     25   0 49404 3700 2060 S  0.0  0.1   0:00.74 named
30340 root      15   0  7192 1064  664 S  0.0  0.0   0:00.92 sshd

ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Nov11 ?        00:00:03 init [3]
dovecot   5150 30465  0 Nov15 ?        00:00:01 pop3-login
dovecot   5196 30465  0 Nov15 ?        00:00:01 pop3-login
dovecot   9801 30465  0 Nov15 ?        00:00:01 pop3-login
root     14105 30340  0 14:04 ?        00:00:00 sshd: root@pts/1
root     14209 14105  0 14:04 pts/1    00:00:00 -bash
apache   16086 23602  0 13:02 ?        00:00:02 /usr/sbin/httpd -k start
root     16186 24258  0 14:05 pts/0    00:00:00 ps -ef
apache   17444 23602  0 13:37 ?        00:00:00 /usr/sbin/httpd -k start
apache   17455 23602  0 13:37 ?        00:00:00 /usr/sbin/httpd -k start
apache   17456 23602  0 13:37 ?        00:00:01 /usr/sbin/httpd -k start
apache   17677 23602  0 13:26 ?        00:00:01 /usr/sbin/httpd -k start
nginx    22489 30643  0 12:52 ?        00:00:09 nginx: worker process
root     23602     1  0 12:52 ?        00:00:00 /usr/sbin/httpd -k start
root     23652 30340  0 11:53 ?        00:00:00 sshd: root@pts/0
apache   23787 23602  0 12:53 ?        00:00:02 /usr/sbin/httpd -k start
apache   23789 23602  0 12:53 ?        00:00:02 /usr/sbin/httpd -k start
apache   23791 23602  0 12:53 ?        00:00:03 /usr/sbin/httpd -k start
apache   23802 23602  0 12:53 ?        00:00:03 /usr/sbin/httpd -k start
apache   23818 23602  0 12:53 ?        00:00:03 /usr/sbin/httpd -k start
apache   23823 23602  0 12:53 ?        00:00:12 /usr/sbin/httpd -k start
apache   23827 23602  0 12:53 ?        00:00:02 /usr/sbin/httpd -k start
apache   23840 23602  0 12:53 ?        00:00:02 /usr/sbin/httpd -k start
apache   23850 23602  0 12:53 ?        00:00:03 /usr/sbin/httpd -k start
apache   23871 23602  0 12:53 ?        00:00:03 /usr/sbin/httpd -k start
apache   23873 23602  0 12:53 ?        00:00:04 /usr/sbin/httpd -k start
apache   23880 23602  0 12:53 ?        00:00:03 /usr/sbin/httpd -k start
root     24258 23652  0 11:54 pts/0    00:00:00 -bash
apache   27938 23602  0 13:56 ?        00:00:00 /usr/sbin/httpd -k start
apache   27939 23602  0 13:56 ?        00:00:00 /usr/sbin/httpd -k start
apache   27940 23602  0 13:56 ?        00:00:00 /usr/sbin/httpd -k start
root     29952     1  0 Nov11 ?        00:00:00 /sbin/udevd -d
root     30273     1  0 Nov11 ?        00:00:01 syslogd -m 0
named    30297     1  0 Nov11 ?        00:00:00 /usr/sbin/named -u named
root     30340     1  0 Nov11 ?        00:00:00 /usr/sbin/sshd
root     30350     1  0 Nov11 ?        00:00:00 xinetd -stayalive -pidfile /var/run/xinetd.pid
root     30384     1  0 Nov11 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log
mysql    30426 30384  5 Nov11 ?        06:31:17 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-ex
root     30465     1  0 Nov11 ?        00:00:11 /usr/sbin/dovecot
root     30466 30465  0 Nov11 ?        00:00:11 dovecot-auth
nobody   30478     1  0 Nov11 ?        00:00:20 memcached -d -p 11211 -u nobody -c 1024 -m 256 -l 127.0.0.1
dovecot  30503 30465  0 Nov11 ?        00:00:07 imap-login
dovecot  30504 30465  0 Nov11 ?        00:00:07 imap-login
dovecot  30505 30465  0 Nov11 ?        00:00:07 imap-login
nobody   30519     1  0 Nov11 ?        00:00:03 proftpd: (accepting connections)
root     30582     1  0 Nov11 ?        00:00:05 sendmail: accepting connections
smmsp    30594     1  0 Nov11 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root     30643     1  0 Nov11 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
root     30657     1  0 Nov11 ?        00:00:00 crond
xfs      30715     1  0 Nov11 ?        00:00:00 xfs -droppriv -daemon
root     31757     1  0 Nov11 ?        00:00:00 /usr/sbin/atd
root     31773     1  0 Nov11 ?        00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
root     31778 31773  0 Nov11 ?        00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2

UPDATE

Problem was with Zend Optimizer + eaccelerator. I replace it with Xcache and speed up to ~20 times

1 Answers1

4

Right. Now we've got lots more information.

You're running 3 sites, on 2 cores at 1.7GHz each. You've got 4GB of RAM, and about 3GB free (that's good).

MySQL and Apache on the same server.

About 20 httpd processes. A bunch of other stuff like nginx and named running.

Is this server deliberately the jack of all trades?

I think you need to scale out a bit, split the database server off onto a separate box. Currently that's using a fair old chunk of the server's "power".
Your IOWait is a bit high.. Which indicates that processes are waiting for data from, the disks. Probably MySQL.

I prefer Intel chips with HyperThreading for this kind of thing, that way you get a bit more performance per socket for some applications.

Recommendations: Get a second server. Put decent SAS or 7200RPM SATA Disks in it. Stop trying to shove everything onto one (slightly old and decrepid) server. Make that into your dedicated MySQL host.

Your PHP benchmark sucks. Unless you're doing something that actually squareroots lots of numbers, then your benchmark isn't indicative of anything.

I'm willing to wager that a part of the problem is poorly optimised databases. Lack of indexes, use of full-text searching. Possibly poor tuning. Download mysqltuner.pl and see whether that makes any sensible recommendations.

There's still a lot I haven't covered. If you really want to get it sorted, it's gonna cost you money, either in hardware upgrades, or a consultant linux geek, or probably (read: definitely) Both.

Tom O'Connor
  • 27,480
  • 10
  • 73
  • 148