2012-07-05 2 views
0

나는 약 40 개의 개별 PHP 스크립트 (같은 서버에 위치 함)를 동시에 호출하는 스크립트를 가지고있다. 각 개별 PHP 스크립트의 시작 부분에 최대 5 초 지연이 있음을 알 수 있습니다. 서버 부하 CPU와 메모리가 좋은 것, 더 스와핑, top 명령을 볼 수 없습니다 :왜 multi_curl을 사용하여 동시에 많은 PHP 스크립트를 호출 할 때 스크립트 실행이 지연됩니까?

top - 22:32:36 up 1:06, 1 user, load average: 0.18, 0.05, 0.01 
Tasks: 181 total, 1 running, 179 sleeping, 0 stopped, 1 zombie 
Cpu(s): 0.0%us, 0.5%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st 
Mem: 1048576k total, 1024144k used, 24432k free, 20160k buffers 
Swap: 2097144k total,  0k used, 2097144k free, 352520k cached 

multi_curl에 대한 모든 요청을 결합 루프의 마지막 스크립트는 일반적으로 가장 큰 지연을 가지고있다. 각 스크립트의 맨 처음에 지연을 측정했습니다.

지연을 방지하려면 어떻게해야합니까?

다음은 내 httpd.conf에

# 
# This is the main Apache HTTP server configuration file. It contains the 
# configuration directives that give the server its instructions. 
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information. 
# In particular, see 
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html> 
# for a discussion of each configuration directive. 
# 
# Do NOT simply read the instructions in here without understanding 
# what they do. They're here only as hints or reminders. If you are unsure 
# consult the online docs. You have been warned. 

ServerRoot "/etc/httpd" 
Listen 80 

#LoadModule dummy_module /usr/lib/apache/mod_dummy.so 
#LoadModule php5_module  /usr/lib/apache/libphp5.so 
Include /etc/httpd/conf/extra/httpd-phpmodules.conf 

User apache 
Group apache 

KeepAlive On 
KeepAliveTimeout 30 

ServerAdmin [email protected] 
DocumentRoot "/var/www/html" 

MaxClients 800 
MaxRequestsPerChild 800 

<Directory /home/*> 
    AllowOverride All 
    Options -MultiViews -Indexes FollowSymlinks IncludesNoExec +Includes 
<Limit GET POST OPTIONS PROPFIND> 
    Order allow,deny 
    Allow from all 
</Limit> 
<LimitExcept GET POST OPTIONS PROPFIND> 
    Order deny,allow 
    Deny from all 
</LimitExcept> 
</Directory> 

<Directory /> 
    Options All 
    AllowOverride All 
</Directory> 

<Directory "/var/www/html"> 
    Options Indexes FollowSymLinks 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
    <IfModule mod_suphp.c> 
     suPHP_Engine On 
     suPHP_UserGroup webapps webapps 
    SetEnv PHP_INI_SCAN_DIR 
    </IfModule> 
</Directory> 

<IfModule mod_dir.c> 
    DirectoryIndex index.html index.htm index.shtml index.php index.php5 index.php4 index.php3 index.phtml index.cgi 
</IfModule> 

<FilesMatch "^\.ht"> 
    Order allow,deny 
    Deny from all 
    Satisfy All 
</FilesMatch> 

ErrorLog /var/log/httpd/error_log 
LogLevel warn 

#replace %b with %O for more accurate logging 
<IfModule mod_logio.c> 
    LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined 
    LogFormat "%h %l %u %t \"%r\" %>s %O" common 
    LogFormat "%O %I" bytes 
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio 
</IfModule> 

    CustomLog /var/log/httpd/access_log common 

<IfModule mod_alias.c> 
    # Include some DirectAdmin alias 
    Include conf/extra/httpd-alias.conf 
</IfModule> 

<Directory "/var/www/cgi-bin"> 
    AllowOverride None 
    Options None 
    Order allow,deny 
    Allow from all 
</Directory> 

DefaultType text/plain 

<IfModule mod_mime.c> 
    TypesConfig conf/mime.types 
    AddType application/x-gzip .tgz 
    AddEncoding x-compress .Z 
    AddEncoding x-gzip .gz .tgz 
    AddType application/x-compress .Z 
    AddType application/x-gzip .gz .tgz 
    AddHandler cgi-script .cgi 
    AddHandler type-map var 
    AddType text/html .shtml 
    AddOutputFilter INCLUDES .shtml 
    AddType video/x-ms-asf .avi 
    AddType video/mpeg .mpg 
    AddType video/mpeg .mpeg 
    AddType video/quicktime .mov 
    AddType video/x-ms-wmv .wmv 
</IfModule> 

#EnableMMAP off 
#EnableSendfile off 

####################################################################################### 
# Do not change anything in included files, because they are rewritten by DirectAdmin # 
####################################################################################### 

# This is needed for PHP 
Include conf/extra/httpd-php-handlers.conf 

# Server-pool management (MPM specific) 
Include conf/extra/httpd-mpm.conf 

# Multi-language error messages 
Include conf/extra/httpd-multilang-errordoc.conf 

# Fancy directory listings 
Include conf/extra/httpd-autoindex.conf 

# Language settings 
Include conf/extra/httpd-languages.conf 

# User home directories 
#Include conf/extra/httpd-userdir.conf 

# Real-time info on requests and configuration 
Include conf/extra/httpd-info.conf 

# Virtual hosts 
Include conf/extra/httpd-vhosts.conf 

# Local access to the Apache HTTP Server Manual 
#Include conf/extra/httpd-manual.conf 

# Distributed authoring and versioning (WebDAV) 
Include conf/extra/httpd-dav.conf 

# Various default settings 
Include conf/extra/httpd-default.conf 

# Secure (SSL/TLS) connections 
Include conf/extra/httpd-ssl.conf 

# Deflate module settings 
Include conf/extra/httpd-deflate.conf 

# All the DirectAdmin vhosts 
Include conf/extra/directadmin-vhosts.conf 

# All suPHP directives 
Include conf/extra/httpd-suphp.conf 

# For user configurations not maintained by DirectAdmin. Empty by default. 
Include conf/extra/httpd-includes.conf 

####################################################################################### 
# End of included files that are rewritten by DirectAdmin        # 
####################################################################################### 

<IfModule mod_ssl.c> 
SSLRandomSeed startup builtin 
SSLRandomSeed connect builtin 
</IfModule> 

답변

0

스크립트를 호출하는 동안이 가장 일반적인 이유는, 뭔가가 차단된다.

이것은 PHP가 session-handler에서 빌드 한 것으로, 동일한 세션 ID (키워드 : race-conditions)에 대한 동시 요청을 차단할 수 있습니다. 이것이 문제가되고 이에 대한 해결책이 필요한 경우 세션 데이터를 처리하는 고유 한 세션 처리기를 구현할 수 있습니다.

또 다른 이유는 flock 된 파일이거나 시스템 IO (예 : 느린 디스크)를 강조한 것일 수 있습니다.

+0

각 요청이 http://www.domain.com/phpscript.php와 함께 호출 될 때 session-handler가 요청을 차단할 수 있습니까? 외부 요청처럼 보이지 않습니까? – BastiaanWW

+0

이 기사 읽기 : http://konrness.com/php5/how-to-prevent-blocking-php-requests/ – Ron

관련 문제