Lange Antwortzeit beim ersten Aufruf der Seite

Apache, Lighttpd, nginx, Cherokee
Post Reply
Anonymous
 

Lange Antwortzeit beim ersten Aufruf der Seite

Post by Anonymous »

Hallo Leute.

Ich hab' mich ein wenig durchs Forum gewühlt, aber bislang passt noch kein Thema zu meinem Problem.

Folgendes: Mein Server (Strato Highend XPro) hostet größtenteils eine Community mit 13.000 Mitgliedern. Mir ist klar, dass da einiges vom System verlangt wird.

Zu manchen Zeiten am Tag liegt die Antwortzeit des Servers bei bis zu 3 Sekunden. Aber immer nur, wenn ich die Startseite aufrufe (also Browser geöffnet und http://www.seite.de aufgerufen). Sobald ich auf der Seite "drauf" bin und Unterseiten aufrufe, ist die Seite wunderbar schnell. Der Server hat 4 GB RAM und laut top werden selten mehr als 2,5 GB RAM davon benötigt. Speicher ist also immer genug frei. Ich hab auch schon alle MySQL-Statements von der Startseite genommen, daran liegts nicht. Und Antwortzeiten des Strato-Nameservers habe ich mit dig auch schon abgefragt. Geht ebenfalls schnell.

Ich verwalte den Server mit Plesk, habe aber ausser der php.ini und der my.cnf und der Installation des Zend-Optimizers nichts verändert.

Kennt jemand dieses Problem?

Gruss,
Jan
flo
Posts: 2223
Joined: 2002-07-28 13:02
Location: Berlin
 

Re: Lange Antwortzeit beim ersten Aufruf der Seite

Post by flo »

versuch das mal mit der IP oder "per Hand/telnet" - eventuell ist das auch nur ein DNS-Problem.

Ansonsten kann es auch sein, daß der Server "voll" ist (jeder Prozeß wird benutzt) - Apache forkt einen neuen Prozeß für Dich, der auch durch das keepalive erst einmal Deiner bleibt. Da würden die Servereinstellungen zum MPM weiterhelfen und vor allem, wieviel Prozesse in Lastzeiten wirklich laufen. Nachteil ist, daß man die nicht unbegrenzt erhöhen kann, aber ein bißchen tunen geht schon.

flo.
Anonymous
 

Re: Lange Antwortzeit beim ersten Aufruf der Seite

Post by Anonymous »

So, hab ein bisschen an der server-tuning.conf rumgeschraubt und ich glaube, es hat was gebracht. Einstellung ist folgende:

Code: Select all

Timeout 150

<IfModule prefork.c>
    # number of server processes to start
    StartServers         7
    # minimum number of server processes which are kept spare
    MinSpareServers      7
    # maximum number of server processes which are kept spare
    MaxSpareServers     15
    # highest possible MaxClients setting for the lifetime of the Apache process.
    ServerLimit        180
    # maximum number of server processes allowed to start
    MaxClients         180
    # maximum number of requests a server process serves
    MaxRequestsPerChild  260
</IfModule>


KeepAlive On
MaxKeepAliveRequests 230
KeepAliveTimeout 11
UseCanonicalName On
HostnameLookups Off
Ich glaube, am meisten hat MaxKeepAliveRequests 230 gebracht. Das Problem scheint gelöst, aber wenn da noch jemand Anmerkungen zu hat, kann er aber gerne noch was schreiben.
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: Lange Antwortzeit beim ersten Aufruf der Seite

Post by Joe User »

PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
flo
Posts: 2223
Joined: 2002-07-28 13:02
Location: Berlin
 

Re: Lange Antwortzeit beim ersten Aufruf der Seite

Post by flo »

flo wrote:... und vor allem, wieviel Prozesse in Lastzeiten wirklich laufen. ...
da zitier ich mich mal ... wär schon interessant :-)

Die "StartServers 7" sind sinnbefreit - damit sorgst Du nur dafür, daß Dein Server bis zum Limit seine verfügbaren Ressourcen aufbauen muß und nach einem Neustart mehr Zeit braucht, bis er alle benötigten Prozesse oben hat. Hier würde ich den untersten Durchschnitt Deiner laufenden Prozesse setzen, dann bitte, bitte: Wieviele laufen, swappt er, wieviel Speicher benötigt der Apache, wie ist das sonstige Setup.

Übrigens: Joe Users Links sind super! :-)

flo.
Anonymous
 

Re: Lange Antwortzeit beim ersten Aufruf der Seite

Post by Anonymous »

Hi.

Sorry, hat leider in bisschen gedauert. Hier ein top-Auszug während der beschrieben langsamen Antworzeit. Weiter unten ist die server-tuning.conf und die my.cnf.

top

Code: Select all

top - 21:24:28 up 7 days,  9:29,  1 user,  load average: 1.64, 1.38, 1.29
Tasks: 301 total,   1 running, 300 sleeping,   0 stopped,   0 zombie
Cpu(s): 22.8% us, 13.6% sy,  0.0% ni, 62.5% id,  0.2% wa,  0.0% hi,  1.0% si
Mem:   4151624k total,  4025020k used,   126604k free,    46616k buffers
Swap:  2096472k total,    11516k used,  2084956k free,  3165476k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
20142 mysql     15   0  493m 238m 4572 S 56.8  5.9   1093:49 mysqld
13794 wwwrun    15   0 23584  11m 6420 S  1.3  0.3   0:00.15 httpd2-prefork
13626 wwwrun    15   0 23264  11m 6400 S  1.0  0.3   0:00.13 httpd2-prefork
13683 wwwrun    15   0 23460  11m 6360 S  1.0  0.3   0:00.11 httpd2-prefork
13800 wwwrun    15   0 23436  11m 6416 S  1.0  0.3   0:00.19 httpd2-prefork
13613 wwwrun    15   0 23440  11m 6392 S  0.7  0.3   0:00.16 httpd2-prefork
13617 wwwrun    16   0 23664  11m 6396 S  0.7  0.3   0:00.15 httpd2-prefork
13638 wwwrun    15   0 23272  11m 6380 S  0.7  0.3   0:00.25 httpd2-prefork
13647 wwwrun    15   0 23484  11m 6432 S  0.7  0.3   0:00.14 httpd2-prefork
13688 wwwrun    16   0 23420  11m 6376 S  0.7  0.3   0:00.17 httpd2-prefork
13696 wwwrun    15   0 23472  11m 6408 S  0.7  0.3   0:00.14 httpd2-prefork
13711 wwwrun    15   0 23480  11m 6408 S  0.7  0.3   0:00.17 httpd2-prefork
13762 wwwrun    15   0 23516  11m 6444 S  0.7  0.3   0:00.12 httpd2-prefork
13784 wwwrun    15   0 23192  11m 6436 S  0.7  0.3   0:00.15 httpd2-prefork
13803 wwwrun    16   0 23272  11m 6384 S  0.7  0.3   0:00.13 httpd2-prefork
13826 wwwrun    15   0 23160  11m 6396 S  0.7  0.3   0:00.22 httpd2-prefork
13833 wwwrun    15   0 23252  11m 6364 S  0.7  0.3   0:00.12 httpd2-prefork
13845 wwwrun    15   0 23412  11m 6376 S  0.7  0.3   0:00.12 httpd2-prefork
 5198 root      16   0 20144 1580 1132 S  0.3  0.0   0:57.98 nscd
13634 wwwrun    15   0 23500  11m 6392 S  0.3  0.3   0:00.15 httpd2-prefork
13644 wwwrun    17   0 23384  11m 6388 S  0.3  0.3   0:00.38 httpd2-prefork
13655 wwwrun    15   0 23556  11m 6408 S  0.3  0.3   0:00.20 httpd2-prefork
13693 wwwrun    17   0 23456  11m 6424 S  0.3  0.3   0:00.23 httpd2-prefork
13694 wwwrun    15   0 23392  11m 6372 S  0.3  0.3   0:00.11 httpd2-prefork
13697 wwwrun    16   0 23208  11m 6400 S  0.3  0.3   0:00.18 httpd2-prefork
13704 wwwrun    15   0 23128  11m 6356 S  0.3  0.3   0:00.06 httpd2-prefork
13710 wwwrun    15   0 23652  11m 6412 S  0.3  0.3   0:00.21 httpd2-prefork
13742 wwwrun    15   0 23240  11m 6392 S  0.3  0.3   0:00.08 httpd2-prefork
13747 wwwrun    15   0 23264  11m 6412 S  0.3  0.3   0:00.14 httpd2-prefork
13766 wwwrun    15   0 23412  11m 6384 S  0.3  0.3   0:00.12 httpd2-prefork
13799 wwwrun    15   0 23480  11m 6412 S  0.3  0.3   0:00.17 httpd2-prefork
13824 wwwrun    15   0 23412  11m 6352 S  0.3  0.3   0:00.12 httpd2-prefork
13834 wwwrun    16   0 23320  11m 6380 S  0.3  0.3   0:00.08 httpd2-prefork
13841 wwwrun    15   0 23248  11m 6392 S  0.3  0.3   0:00.18 httpd2-prefork
13980 root      16   0  2240 1144  768 R  0.3  0.0   0:00.24 top
    1 root      16   0   688  260  224 S  0.0  0.0   0:01.70 init
    2 root      RT   0     0    0    0 S  0.0  0.0   0:00.19 migration/0
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    4 root      RT   0     0    0    0 S  0.0  0.0   0:00.05 migration/1
    5 root      34  19     0    0    0 S  0.0  0.0   0:00.01 ksoftirqd/1
    6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 events/0
    7 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 events/1
    8 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper
    9 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kthread
   20 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid
  458 root      10  -5     0    0    0 S  0.0  0.0   0:01.22 kblockd/0
servertuning.conf

Code: Select all

##
## Server-Pool Size Regulation (MPM specific)
##

# the MPM (multiprocessing module) is not a dynamically loadable module in the
# sense of other modules. It is a compile time decision which one is used. We
# provide different apache2 MPM packages, containing different httpd2 binaries
# compiled with the available MPMs. See APACHE_MPM in /etc/sysconfig/apache2.

# prefork MPM
Timeout 150

<IfModule prefork.c>
    # number of server processes to start
    StartServers         5
    # minimum number of server processes which are kept spare
    MinSpareServers      5
    # maximum number of server processes which are kept spare
    MaxSpareServers     15
    # highest possible MaxClients setting for the lifetime of the Apache process.
    ServerLimit        200
    # maximum number of server processes allowed to start
    MaxClients         200
    # maximum number of requests a server process serves
    MaxRequestsPerChild  280
</IfModule>

# worker MPM
<IfModule worker.c>
    # initial number of server processes to start
    StartServers         2
    # minimum number of worker threads which are kept spare
    MinSpareThreads     25
    # maximum number of worker threads which are kept spare
    MaxSpareThreads     75
    # maximum number of simultaneous client connections
    MaxClients         150
    # constant number of worker threads in each server process
    ThreadsPerChild     25
    # maximum number of requests a server process serves
    MaxRequestsPerChild  250
</IfModule>

# leader MPM
<IfModule leader.c>
    # initial number of server processes to start
    StartServers         2
    # minimum number of worker threads which are kept spare
    MinSpareThreads     25
    # maximum number of worker threads which are kept spare
    MaxSpareThreads     75
    # maximum number of simultaneous client connections
    MaxClients         150
    # constant number of worker threads in each server process
    ThreadsPerChild     25
    # maximum number of requests a server process serves
    MaxRequestsPerChild  0
</IfModule>

# perchild MPM
<IfModule perchild.c>
    # constant number of server processes
    NumServers           5
    # initial number of worker threads in each server process
    StartThreads         5
    # minimum number of worker threads which are kept spare
    MinSpareThreads      5
    # maximum number of worker threads which are kept spare
    MaxSpareThreads     10
    # maximum number of worker threads in each server process
    MaxThreadsPerChild  20
    # maximum number of connections per server process
    MaxRequestsPerChild  0

    AcceptMutex fcntl
</IfModule>

# metux MPM
<IfModule metuxmpm.c>
    # initial number of worker threads in each server process
    StartThreads          5
    # minimum number of worker threads which are kept spare
    MinSpareThreads       5
    # maximum number of worker threads which are kept spare
    MaxSpareThreads      10
    # maximum number of connections per server process
    MaxRequestsPerChild   0

    Multiplexer "wwwrun"    "www"

</IfModule>


#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
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 250

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 11

#
# EnableMMAP: Control whether memory-mapping is used to deliver
# files (assuming that the underlying OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems.  On some systems, turning it off (regardless of
# filesystem) can improve performance; for details, please see
# http://httpd.apache.org/docs-2.0/mod/core.html#enablemmap
#
#EnableMMAP off

#
# EnableSendfile: Control whether the sendfile kernel support is
# used  to deliver files (assuming that the OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems.  Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#enablesendfile
#
#EnableSendfile off


UseCanonicalName On
HostnameLookups Off

my.cnf

Code: Select all


# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /var/lib/mysql) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password   = your_password
port        = 3306
socket      = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port        = 3306
socket      = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 256M
max_allowed_packet = 1M
table_cache = 2000
sort_buffer_size = 16M
read_buffer_size = 16M
join_buffer_size = 16M
read_rnd_buffer_size = 16M
myisam_sort_buffer_size = 16M
thread_cache = 16
query_cache_size = 128M
query_cache_type = 1
connect_timeout = 6
query_cache_limit = 8M
set-variable = max_connections=500



# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
Anonymous
 

Re: Lange Antwortzeit beim ersten Aufruf der Seite

Post by Anonymous »

Zum Server noch:
AMD Opteronâ„¢ 185 (Dual-Core)
SUSE 10.0
4 GB RAM
2 x 250 GB Festplatte
Anonymous
 

Re: Lange Antwortzeit beim ersten Aufruf der Seite

Post by Anonymous »

Übrigens: Der Zugriff auf Plesk unter meiner Standard - Server-URL h9******.serverkompetenz.net ist superschnell, obwohl Plesk ja selbst auch auf dem Server liegt. Nur der Weg über meine richtigen Domains ist eben teilweise langsam.
flo
Posts: 2223
Joined: 2002-07-28 13:02
Location: Berlin
 

Re: Lange Antwortzeit beim ersten Aufruf der Seite

Post by flo »

Ich tippe auf irgendeinen DNS-Mist ... entweder der Server möchte einen Reverse-Lookup fahren oder Deine Kiste braucht so ewig, um den Hostnamen rauszufinden.

Alternativ wäre immer noch ein Tuning anzuraten - bei 256MB Key Buffer für den MySQL schätze ich, daß da was gehen wird auf Deiner Maschine. Die initialen Server passen dazu aber nicht - Apacheperformance ist ein Thema für sich und nicht ganz trivial.

Schuß ins Blaue:

Code: Select all

    StartServers         100 
    MinSpareServers      100 
    MaxSpareServers     120 
    ServerLimit        300 
    MaxClients         500 
    MaxRequestsPerChild  250
Die Werte sind wesentlich erhöht, es stehen auch mehr Hosts zur Verfügung - aber eine Last von 1.x kann man nocht nicht wirklich als Last bezeichnen und die Speicherwerte geben auch noch viel mehr her, bis die Kiste langsam werden sollte.

flo.
braindead
Posts: 250
Joined: 2002-10-22 09:49
Location: vorm Rechner
 

Re: Lange Antwortzeit beim ersten Aufruf der Seite

Post by braindead »

Code: Select all

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
20142 mysql     15   0  493m 238m 4572 S 56.8  5.9   1093:49 mysqld 
hallo, was zum teufel treibt dein MySql server da? Ich meine 50% CPU Last ist ja wohl der Hammer. Schalte doch aus Spaß mal den Slow Query Cache ein und guck dir an was da so verdammt schief läuft.
Post Reply