Apache / Server ausgelastet :(

Debian macht sich hervorragend als Web- und Mailserver. Schau auch in den " Tipps und Tricks"-Bereich.
Antworten
MrSpoocy
Beiträge: 11
Registriert: 13.01.2008 20:12:13

Apache / Server ausgelastet :(

Beitrag von MrSpoocy » 13.01.2008 20:39:55

Hi,

ich hab derzeit das Problem das der Apache immer aussetzt wenn zu viele User auf der Seite sind. Auch Putty ist dann sehr langsam und es dauert ewig bis ich mich als root einloggen kann.

Hier mal infos:

Server:
CPU:
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 39
model name : AMD Opteron(tm) Processor 146
stepping : 1
cpu MHz : 2000.000
cache size : 1024 KB
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 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow up pni lahf_lm
bogomips : 4021.00
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
Speicher:
1 GB
Netzwerk:
eth0: negotiated 100baseTx-FD, link ok
Linux:
Linux version 2.6.18-4-amd64 (Debian 2.6.18.dfsg.1-12etch2) (dannf@debian.org) (gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)) #1 SMP Fri May 4 00:37:33 UTC 2007

Habe Apache2.2 mpm-worker, php5-fcgid (mod_fcgid), MySQL 5.x installiert (mit "aptitude install") also nichts selber compeliert.

Bei php noch APC installiert.

Kurz vor dem absturz und auch wherend es so langsam ist, zeigt "top" an das der CPU(s) - wa wert bei 80%.
Es sind zu dem zeitpunkt ca. 400 User on.

Einer Ideen Vorschläge ?



Hier Configs:

Apache:
ServerRoot "/etc/apache2"

#<IfModule !mpm_winnt.c>
#<IfModule !mpm_netware.c>
LockFile /var/lock/apache2/accept.lock
#</IfModule>
#</IfModule>

PidFile /var/run/apache2.pid

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 15

<IfModule mpm_worker_module>
ThreadLimit 60
ServerLimit 30
StartServers 2
MaxClients 1800
MinSpareThreads 30
MaxSpareThreads 60
ThreadsPerChild 60
MaxRequestsPerChild 0
</IfModule>

User www-data
Group www-data

AccessFileName .htaccess

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

TypesConfig /etc/mime.types

DefaultType text/plain

HostnameLookups Off

ErrorLog /var/log/apache2/error.log

LogLevel warn

Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

Include /etc/apache2/httpd.conf

Include /etc/apache2/ports.conf

Include /etc/apache2/conf.d/

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

ServerTokens Full

ServerSignature Off

Include /etc/apache2/sites-enabled/

MySQL:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
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/german
skip-external-locking

key_buffer = 128M
max_allowed_packet = 16M
thread_stack = 128K
thread_cache_size = 8
max_connections = 2500
table_cache = 512
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 8M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
#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
#long_query_time = 2
#log-queries-not-using-indexes
#
# 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

# WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!
#expire_logs_days = 10
#max_binlog_size = 100M

#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * BerkeleyDB
#
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
skip-bdb


[mysqldump]
quick
quote-names
max_allowed_packet = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = 16M

!includedir /etc/mysql/conf.d/
"pstree" kurz nach ausfall des Apache
init-+-acpid
|-apache2-+-apache2
| |-apache2-+-apache2
| | `-89*[php5-cgi]
| |-2*[apache2---2*[{apache2}]]
| |-apache2---{apache2}
| |-3*[apache2---61*[{apache2}]]
| `-apache2---18*[{apache2}]
|-atd
|-courierlogger---authdaemond---5*[authdaemond]
|-courierlogger---couriertcpd
|-cron
|-dbus-daemon
|-dccifd---2*[{dccifd}]
|-dhcpcd-bin
|-events/0
|-famd
|-2*[getty]
|-khelper
|-klogd
|-ksoftirqd/0
|-kthread-+-aio/0
| |-ata/0
| |-ata_aux
| |-kacpid
| |-kblockd/0
| |-khubd
| |-kjournald
| |-kmirrord
| |-kpsmoused
| |-kseriod
| |-kswapd0
| |-md0_raid1
| |-md1_raid1
| |-2*[pdflush]
| |-scsi_eh_0
| |-scsi_eh_1
| |-scsi_eh_2
| `-scsi_eh_3
|-master-+-2*[cleanup]
| |-pickup
| |-qmgr
| |-2*[smtp]
| |-tlsmgr
| `-trivial-rewrite
|-mdadm
|-migration/0
|-mysqld_safe-+-logger
| `-mysqld---82*[{mysqld}]
|-2*[perl]
|-portmap
|-powernowd
|-saslauthd---4*[saslauthd]
|-server_linux---8*[{server_linux}]
|-server_linux---23*[{server_linux}]
|-spamd---2*[spamd]
|-sshd-+-sshd---bash---pstree
| `-sshd
|-syslogd
|-udevd
`-watchdog/0
Bei: "netstat -nt | grep ':80' | wc -l" sind es ca. 250-300 die ausgeben wird.

dawidhunter
Beiträge: 55
Registriert: 02.01.2008 20:04:00

Beitrag von dawidhunter » 13.01.2008 22:58:34

Hallo,

was ist das denn für eine Homepage die du betreibst, wenn das ein Forum ist (phpbb) dann würde ich warscheinlich die lösung auf dein Problem kennen.

TIPP:

Ich würde in der apache2.conf folgende werte umstellen;

ServerTokens Prod
Timeout 50

http://www.debianhowto.de/doku.php/de:h ... 2_security

MrSpoocy
Beiträge: 11
Registriert: 13.01.2008 20:12:13

Beitrag von MrSpoocy » 13.01.2008 23:25:33

Es läuft vBulletin und noch nee kleinigkeit.

dawidhunter
Beiträge: 55
Registriert: 02.01.2008 20:04:00

Beitrag von dawidhunter » 13.01.2008 23:54:45

kannst du deine php.ini mal posten?!

MrSpoocy
Beiträge: 11
Registriert: 13.01.2008 20:12:13

Beitrag von MrSpoocy » 14.01.2008 03:59:58

PHP.ini:

http://nopaste.debianforum.de/7295

extension=apc.so
apc.enabled=1
apc.file_update_protection=2
apc.optimization=0
apc.shm_size=32
apc.shm_segments=1
apc.gc_ttl=7200
apc.ttl=7200
apc.num_files_hint=1024
apc.enable_cli=0

Benutzeravatar
Simmel
Beiträge: 698
Registriert: 08.03.2004 14:43:43
Lizenz eigener Beiträge: MIT Lizenz
Wohnort: Düsseldorf
Kontaktdaten:

Beitrag von Simmel » 14.01.2008 08:27:14

Mach mal mehr Server auf.

StartServers 4 bis 8

Es wäre auch nicht schlecht wenn du mal deinen Top hier reinkopierst
Damit man mal die Serverlast generell sehen kann.
you've got to know how far to go in going too far

perl -le'print+(split//,"schaeuble")[6,8,7,3,5,0..2,4]'

http://creativecommons.org/licenses/by-nc-sa/2.0/

dawidhunter
Beiträge: 55
Registriert: 02.01.2008 20:04:00

Beitrag von dawidhunter » 14.01.2008 15:28:47

memory_limit = 32M auf memory_limit = 500M
stellen ... vill gehts ja dann^^

ps: /etc/init.d/apache2 restart nicht vergessen ;D also apache2 neustarten^^

MrSpoocy
Beiträge: 11
Registriert: 13.01.2008 20:12:13

Beitrag von MrSpoocy » 14.01.2008 17:30:13

top - 17:26:54 up 29 days, 7:12, 1 user, load average: 8.33, 7.97, 7.07
Tasks: 97 total, 2 running, 95 sleeping, 0 stopped, 0 zombie
Cpu(s): 37.0%us, 9.3%sy, 0.3%ni, 50.0%id, 3.0%wa, 0.0%hi, 0.3%si, 0.0%st
Mem: 1027656k total, 956492k used, 71164k free, 14028k buffers
Swap: 2104496k total, 283476k used, 1821020k free, 655896k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
18390 mysql 15 0 349m 119m 3832 S 19.6 11.9 5655:00 mysqld
9524 lexxus 16 0 97044 43m 38m S 19.0 4.3 0:44.65 php5-cgi
5743 lexxus 16 0 102m 47m 33m S 5.0 4.7 2:22.70 php5-cgi
12747 www-data 18 0 567m 11m 1820 S 1.0 1.2 0:01.22 apache2
2977 teamspea 34 19 209m 2672 984 S 0.7 0.3 99:22.15 server_linux
13454 root 15 0 10600 1308 956 R 0.7 0.1 0:00.02 top
13390 www-data 18 0 559m 4244 1800 S 0.3 0.4 0:00.04 apache2
1 root 15 0 6120 448 416 S 0.0 0.0 0:04.66 init
2 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
3 root 34 19 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/0
4 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
5 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/0
6 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khelper
7 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kthread
11 root 10 -5 0 0 0 S 0.0 0.0 0:05.77 kblockd/0
12 root 20 -5 0 0 0 S 0.0 0.0 0:00.00 kacpid
139 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khubd
php5-cgi und mysql schwanken ununterbrochen, mal brauchen sie zusammen 100% mal nur 10%.

Benutzeravatar
Simmel
Beiträge: 698
Registriert: 08.03.2004 14:43:43
Lizenz eigener Beiträge: MIT Lizenz
Wohnort: Düsseldorf
Kontaktdaten:

Beitrag von Simmel » 15.01.2008 05:04:15

MrSpoocy hat geschrieben:
top - 17:26:54 up 29 days, 7:12, 1 user, load average: 8.33, 7.97, 7.07
Tasks: 97 total, 2 running, 95 sleeping, 0 stopped, 0 zombie
Cpu(s): 37.0%us, 9.3%sy, 0.3%ni, 50.0%id, 3.0%wa, 0.0%hi, 0.3%si, 0.0%st
Mem: 1027656k total, 956492k used, 71164k free, 14028k buffers
Swap: 2104496k total, 283476k used, 1821020k free, 655896k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
18390 mysql 15 0 349m 119m 3832 S 19.6 11.9 5655:00 mysqld
9524 lexxus 16 0 97044 43m 38m S 19.0 4.3 0:44.65 php5-cgi
5743 lexxus 16 0 102m 47m 33m S 5.0 4.7 2:22.70 php5-cgi
12747 www-data 18 0 567m 11m 1820 S 1.0 1.2 0:01.22 apache2
2977 teamspea 34 19 209m 2672 984 S 0.7 0.3 99:22.15 server_linux
13454 root 15 0 10600 1308 956 R 0.7 0.1 0:00.02 top
13390 www-data 18 0 559m 4244 1800 S 0.3 0.4 0:00.04 apache2
1 root 15 0 6120 448 416 S 0.0 0.0 0:04.66 init
2 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
3 root 34 19 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/0
4 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
5 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/0
6 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khelper
7 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kthread
11 root 10 -5 0 0 0 S 0.0 0.0 0:05.77 kblockd/0
12 root 20 -5 0 0 0 S 0.0 0.0 0:00.00 kacpid
139 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khubd
php5-cgi und mysql schwanken ununterbrochen, mal brauchen sie zusammen 100% mal nur 10%.
Hmh was ist das für Hardware? Ist das ein Root Server oder ein virtueller?

Die Systemlast sieht enorm aus, normal sit das jedenfalls nicht. Große Datenbank dahinter? PHP Skript was nicht 100%ig funktioniert?

Siehst so aus als würden deine Mysql-Anfragen den Server insgesamt so stark belasten das er dem Apache nicht genügend CPU-Zeit und Ram zur Verfügung stellt.

Ich würde mal versuchen im PHP-Forum anch Threads zu suchen um deine php.ini zu optimieren/vergleichen und vll die Zugriffe für die MYSQL-Datenbank zu tunen.

Sollte das nicht helfen nimm einen zweiten Server um die Datenbank auf diesen auszulagern.
you've got to know how far to go in going too far

perl -le'print+(split//,"schaeuble")[6,8,7,3,5,0..2,4]'

http://creativecommons.org/licenses/by-nc-sa/2.0/

Antworten