
Ich habe einen Server mit 2x2 GHz Kern
aber php läuft sehr langsam darauf, ich schreibe einen synthetischen Test
for($i=0;$i<10000000;$i++) {
$x = sqrt($i);
}
generieren ~ 30 Sek
aber auf einem lokalen Rechner mit 2x2GHz-Kern werden 2,8 Sekunden generiert
auch ich versuche dieses Skript bei Shared Hosting - 2,8 Sek. auch
Wo geht Leistung verloren?
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
AKTUALISIEREN
Das Problem war mit Zend Optimizer + eaccelerator. Ich habe es durch Xcache ersetzt und es hat sich um das ~20-fache beschleunigt
Antwort1
Richtig. Jetzt haben wir viel mehr Informationen.
Du rennst3 Standorte, An2 KernebeiJeweils 1,7 GHz. Du hast4 GB RAM, und über3GB frei(Das ist gut).
MySQL und Apache auf demselben Server.
Um20 httpdProzesse. Eine Menge anderer Sachen wienginxUndgenanntläuft.
Ist dieser Server bewusst ein Alleskönner?
Ich denke, Sie müssen etwas skalieren und den Datenbankserver auf eine separate Box auslagern. Derzeit verbraucht das einen ziemlich großen Teil der „Leistung“ des Servers.
Ihr IOWait ist etwas hoch. Das zeigt an, dass Prozesse auf Daten von den Festplatten warten. Wahrscheinlich MySQL.
Ich bevorzuge für solche Dinge Intel-Chips mit HyperThreading, so erhält man für manche Anwendungen etwas mehr Leistung pro Sockel.
Empfehlungen: Besorgen Sie sich einen zweiten Server. Bauen Sie dort anständige SAS- oder 7200-RPM-SATA-Festplatten ein. Versuchen Sie nicht, alles auf einen (etwas alten und heruntergekommenen) Server zu schieben. Machen Sie diesen zu Ihrem dedizierten MySQL-Host.
Ihr PHP-Benchmark ist Mist. Sofern Sie nichts tun, was tatsächlich viele Zahlen quadriert, ist Ihr Benchmark für nichts aussagekräftig.
Ich bin bereit zu wetten, dass ein Teil des Problems schlecht optimierte Datenbanken sind. Fehlende Indizes, Verwendung von Volltextsuche. Möglicherweise schlechte Abstimmung. Downloadmysqltuner.plund sehen Sie, ob es sinnvolle Empfehlungen gibt.
Es gibt noch vieles, was ich nicht behandelt habe. Wenn Sie das Problem wirklich lösen möchten, wird es Sie Geld kosten, entweder für Hardware-Upgrades oder einen Linux-Experten als Berater oder wahrscheinlich (lies: definitiv) beides.