• This forum has a zero tolerance policy regarding spam. If you register here to publish advertising, your user account will be deleted without further questions.

PHP auf dezidierten Server langsam

hlaranexe

New Member
Hallo Ihr,

ich habe das Problem, das auf meinem Server das PHP langsam verarbeitet wird, es dauert 8 Sekunden bis eine Anfrage verarbeitet, aber nur bei .php-Dateien (auch wenn sich überhaupt kein Code in der PHP-Datei befindet). Wenn ich eine Bild- oder HTML-Datei aufrufe ist das Tempo normal.

Es handelt sich um einen SuSE-Apache-Server, der schon eine Weile läuft, die Umgegebung in der das PHP läuft, beinhaltet noch mod_suphp, mod_chroot und mod_suexec.

Irgendwelche Ideen, warum es plötzlich diese Verzögerungen gibt, als wäre das PHP plötzlich faul geworden?

thx

hauke
 
Sind die Skripte auch langsam wenn du sie auf der Konsole über den PHP-Interpreter direkt ausführst, oder nur via Apache?

Ich kenne mich mit Apache nicht mehr aus, aber sagt er ggf. etwas in den Logfiles?
 
PHP über Konsole normal

Nein über Konsole ist die Geschwindigkeit normal. Es ist auch so das auf dem Server zwei PHPs kompiliert sind (5.2 und 5.3) und bei beiden tritt dieser Effekt auf.

Es muss also irgendwo an der Übergabe von Apache liegen.

In den Log-Dateien hab ich auch noch nichts gefunden, ich hab den LogLevel auf Debug gestellt, das einzigeste was da auffällig ist ist die meldung

Code:
[Wed Nov 06 11:11:24 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 2 idle, and 22 total children
Kann es das sein, aber wie gesagt das Problem tritt nur bei php-Dateien auf. Interessant ist aus die gleichmäßigkeit der Verspätung, es sind immer 8 Sekunden mit Variationen im Millilsekundenbereich...
 
Hm,

hab die Werte jetzt hochgeschaubt, die Fehlermeldung kommt auch nicht mehr im Error.log, aber die 8 Sekunden sind immer noch pünktlich da... :(
 
Poste mal die komplette Config. Verschiedene Stichproben von der Auslastung CPU, RAM usw. wären auch von Nutzen.
 
Server-Konfiguration

Ich denke das hier sind die relevanten Sachen:

top
Code:
top - 13:03:45 up 57 min,  3 users,  load average: 0.11, 0.17, 0.17
Tasks: 133 total,   2 running, 131 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.5%us,  0.2%sy,  0.0%ni, 98.8%id,  0.2%wa,  0.4%hi,  0.0%si,  0.0%st
Mem:   4028400k total,  1604492k used,  2423908k free,     8272k buffers
Swap:  1959920k total,        0k used,  1959920k free,   588464k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 7637 piwik     20   0 94604  11m 5464 S    2  0.3   0:00.06 php_532
 5274 root      20   0 16932 1304  948 S    1  0.0   0:04.14 top
    1 root      20   0   864  332  272 S    0  0.0   0:01.96 init
    2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd
    3 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/0
    4 root      15  -5     0    0    0 S    0  0.0   0:00.00 ksoftirqd/0
    5 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/1
    6 root      15  -5     0    0    0 S    0  0.0   0:00.00 ksoftirqd/1
    7 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/2
    8 root      15  -5     0    0    0 S    0  0.0   0:00.00 ksoftirqd/2
    9 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/3
   10 root      15  -5     0    0    0 S    0  0.0   0:00.00 ksoftirqd/3
   11 root      15  -5     0    0    0 S    0  0.0   0:00.04 events/0
   12 root      15  -5     0    0    0 S    0  0.0   0:00.00 events/1
   13 root      15  -5     0    0    0 S    0  0.0   0:00.00 events/2
   14 root      15  -5     0    0    0 S    0  0.0   0:00.00 events/3

httpd.conf
Code:
### Global Environment ######################################################
Include /etc/apache2/uid.conf
Include /etc/apache2/server-tuning.conf
ErrorLog /var/log/apache2/error_log
Include /etc/apache2/sysconfig.d/loadmodule.conf
Include /etc/apache2/listen.conf
Include /etc/apache2/mod_log_config.conf

Include /etc/apache2/sysconfig.d/global.conf
ChrootDir /home/chroot

Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf
Include /etc/apache2/mod_usertrack.conf
Include /etc/apache2/mod_autoindex-defaults.conf
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
Include /etc/apache2/mod_mime-defaults.conf
Include /etc/apache2/errors.conf
Include /etc/apache2/ssl-global.conf
<Directory />
    Options None
    AllowOverride None
    #AllowOverride All
    Order deny,allow
    Deny from all
</Directory>
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>
DirectoryIndex index.html index.php

### 'Main' server configuration #############################################
#Include /etc/apache2/default-server.conf
Include /etc/apache2/sysconfig.d/include.conf

### Virtual server configuration ############################################
Include /etc/apache2/vhosts.d/*.conf

/etc/apache2/server-tuning.conf
Code:
# prefork MPM
<IfModule prefork.c>
        # number of server processes to start
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#startservers
        StartServers         30
        # minimum number of server processes which are kept spare
        # http://httpd.apache.org/docs/2.2/mod/prefork.html#minspareservers
        MinSpareServers      5
        # maximum number of server processes which are kept spare
        # http://httpd.apache.org/docs/2.2/mod/prefork.html#maxspareservers
        MaxSpareServers     20
        # highest possible MaxClients setting for the lifetime of the Apache process.
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#serverlimit
        ServerLimit        150
        # maximum number of server processes allowed to start
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxclients
        MaxClients         150
        # maximum number of requests a server process serves
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxrequestsperchild
        MaxRequestsPerChild  10000
</IfModule>

# worker MPM
<IfModule worker.c>
        # initial number of server processes to start
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#startservers
        StartServers         30
        # minimum number of worker threads which are kept spare
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#minsparethreads
        MinSpareThreads     25
        # maximum number of worker threads which are kept spare
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxsparethreads
        MaxSpareThreads     75
        # upper limit on the configurable number of threads per child process
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#threadlimit
        ThreadLimit         64
        # maximum number of simultaneous client connections
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxclients
        MaxClients         150
        # number of worker threads created by each child process
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#threadsperchild
        ThreadsPerChild     25
        # maximum number of requests a server process serves
        # http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxrequestsperchild
        MaxRequestsPerChild  10000
</IfModule>


HostNameLookups off
KeepAlive On
KeepAliveTimeout 2
MaxKeepAliveRequests 100
MaxKeepAliveRequests 10
MaxClients 150
MaxRequestsPerChild 1000

/etc/apache2/sysconfig.d/loadmodule.conf
Code:
LoadModule alias_module                   /usr/lib64/apache2-prefork/mod_alias.so
LoadModule auth_basic_module              /usr/lib64/apache2-prefork/mod_auth_basic.so
LoadModule authn_file_module              /usr/lib64/apache2-prefork/mod_authn_file.so
LoadModule authz_host_module              /usr/lib64/apache2-prefork/mod_authz_host.so
LoadModule authz_groupfile_module         /usr/lib64/apache2-prefork/mod_authz_groupfile.so
LoadModule authz_default_module           /usr/lib64/apache2-prefork/mod_authz_default.so
LoadModule authz_user_module              /usr/lib64/apache2-prefork/mod_authz_user.so
LoadModule authn_dbm_module               /usr/lib64/apache2-prefork/mod_authn_dbm.so
LoadModule dir_module                     /usr/lib64/apache2-prefork/mod_dir.so
LoadModule env_module                     /usr/lib64/apache2-prefork/mod_env.so
LoadModule expires_module                 /usr/lib64/apache2-prefork/mod_expires.so
LoadModule include_module                 /usr/lib64/apache2-prefork/mod_include.so
LoadModule log_config_module              /usr/lib64/apache2-prefork/mod_log_config.so
LoadModule mime_module                    /usr/lib64/apache2-prefork/mod_mime.so
LoadModule setenvif_module                /usr/lib64/apache2-prefork/mod_setenvif.so
LoadModule ssl_module                     /usr/lib64/apache2-prefork/mod_ssl.so
LoadModule suexec_module                  /usr/lib64/apache2-prefork/mod_suexec.so
LoadModule chroot_module                  /usr/lib64/apache2/mod_chroot.so
LoadModule rewrite_module                 /usr/lib64/apache2-prefork/mod_rewrite.so
LoadModule suphp_module                   /usr/lib64/apache2/mod_suphp.so

Und ein virtuelle Host der darauf läuft
piwik.conf
Code:
<VirtualHost *:80>
        ServerAdmin webmaster@aranex.de
        ServerName www.piwik.aranex-provider.de
        ServerAlias piwik.aranex-provider.de

        DocumentRoot /www/piwik/htdocs
        # if not specified, the global error log is used
        ErrorLog /www/piwik/log/error_log
        CustomLog /www/piwik/log/access_log combined

        Alias /log/ "/www/piwik/log/"
        <Directory "/www/piwik/log/">
                AuthUserFile /etc/apache2/webalizerpwd
                require user piwik
                AuthType Basic
                AuthName "Zugriffsstatistik"
        </Directory>
        # don't loose time with IP address lookups
        HostnameLookups Off
        # needed for named virtual hosts
        UseCanonicalName Off
        # configures the footer on server-generated documents
        ServerSignature On
        <Directory "/www/piwik">
                Options -Indexes FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
        suPHP_Engine on
        suPHP_UserGroup piwik piwik
        suPHP_ConfigPath /usr/local/suphp/etc/piwik
        AddHandler x-httpd-php532 .php
        <Directory /www/piwik/htdocs>
                # wichtig: damit php dateien geparst werden, gilt nur innerhalb von directory
                suPHP_AddHandler x-httpd-php532
        </Directory>
</VirtualHost>

many thanks schon mal für die Mühe
 
Hm,

hab die Werte jetzt hochgeschaubt, die Fehlermeldung kommt auch nicht mehr im Error.log, aber die 8 Sekunden sind immer noch pünktlich da... :(
Installiere mal mod_status und beobachte die Ausgabe, während Deine Seite aufgerufen wird. Gibt es eine bestimmte Situation wo das immer auftritt also lässt sich das sicher provozieren? Wenn ja, näher beschreiben.

Edit sagt: ist überholt - wir sollten uns die PHP-Umgebung näher anschauen. PHP-Error-Logging mal aktivieren mit maximalen Details.

Übrigens "StartServers 30" widerspricht "MaxSpareServers 20" ;) am besten StartServers auf den Wert von MinSpareServers setzen.
 
Last edited by a moderator:
So habe das php-Error-Log eingeschaltet, gibt es eine Möglichkeit da noch mehr raus zu holen?

php.ini
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
error_reporting = E_ALL
display_errors = Off
display_startup_errors = On
log_errors = On
error_log = /www/piwik/log/php_error_log

log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = On

Aber auftauchen tut leider nichts ausser:

Code:
PHP Warning:  phpinfo() [<a href='function.phpinfo'>function.phpinfo</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /www/piwik/htdocs/info.php on line 2

Ich hab mal des Modul mod_suexec ausgeschaltet, leider keine Änderung, so bleiben meiner Meinung nach nur noch suPHP und PHP übrig, aber was sich da geändert haben soll, ist mehr echt ein Rätsel.
 
Bzgl. der Warning solltest Du die entsprechende Einstellung in der zutreffenden php.ini vornehmen. Ich glaube allerdings nicht, dass dies Dein Problem löst. Du sagtest, dass Problem tritt generell beim Parsen von PHP-Dateien auf? Also auch bei:

<?php phpinfo(); ?>
 
Last edited by a moderator:
Ja auch bei

<?php phpinfo(); ?>

Aber auch, wenn ich eine Datei erstelle die heißt test.php und enthält gar nichts, also nicht einmal "<?php ?>" sind drin. :confused:

echt verflickt...
 
Und in den error.logs des Apachen steht wirklich nix brauchbares, nach dem Aufruf einer Seite. Dann wäre ich bei suPHP mit meinem Latein am Ende. Ich persönlich bevorzuge die Kombi Apache (mpm-worker) mit PHP-FPM oder FastCGI.
 
Back
Top