2014-09-02 3 views
2

친절하고 친절하게 문제를 해결할 수 있습니까?아파치 + mod_wsgi - 동일한 브라우저에서의 병렬 요청

내가 WSGI가 제대로 나는 같은 브라우저에서 병렬 요청을 처리 할 필요가 다중 스레드 작업을하고 파이썬 을 사용하고 구성

내가 mod_wsgi에 아파치 2.2.22를 실행 해요,하지만 유일한 병렬 요청 WSGI가 될 수 있습니다 다른 브라우저 (또는 1 개의 브라우저 탭 + 시크릿 모드의 1 탭)에서 가져온 것입니다.

나는 임베디드 및 데몬 모두를 시도했다.

아파치 설정 :

import os, sys 
import time 
from datetime import datetime 

def application(environ, start_response): 

    sys.stderr.write("before wait time = %s\n" % str(datetime.now())) 
    sys.stderr.write("client= %s\n" % environ['REMOTE_ADDR']) 
    sys.stderr.write("waiting\n") 
    print >> sys.stderr, 'mod_wsgi.process_group = %s' % repr(environ['mod_wsgi.process_group']) 
    time.sleep(10) 
    sys.stderr.write("wait finished time = %s\n" % str(datetime.now())) 
    status = '200 OK' 
    output = 'Hello World!' 

    response_headers = [('Content-type', 'text/plain'), 
        ('Content-Length', str(len(output)))] 
    start_response(status, response_headers) 

    return [output] 

:

WSGIDaemonProcess appname processes=5 threads=25 display-name=%{GROUP} 
WSGIProcessGroup appname 

WSGIScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 

<Directory "/usr/lib/cgi-bin"> 
    AllowOverride None 
    AddHandler wsgi-script .py 
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
    #Require all granted 
</Directory> 

나는 wsgi.py의 755 모드

내용으로는/usr/lib 디렉토리/CGI-bin 디렉토리에 wsgi.py를 넣어 http://my.ip/cgi-bin/wsgi.py을 요청할 때 모두 괜찮아졌지만 단일 브라우저의 2 탭에서 병렬로 실행하면 두 번째 탭이 처음 완료 될 때까지 기다리는 중입니다 ... logs :

[Tue Sep 02 18:25:06 2014] [error] before wait time = 2014-09-02 18:25:06.365133 
[Tue Sep 02 18:25:06 2014] [error] client= 192.168.113.35 
[Tue Sep 02 18:25:06 2014] [error] waiting 
[Tue Sep 02 18:25:06 2014] [error] mod_wsgi.process_group = 'appname' 
[Tue Sep 02 18:25:16 2014] [error] wait finished time = 2014-09-02 18:25:16.371944 
[Tue Sep 02 18:25:16 2014] [error] before wait time = 2014-09-02 18:25:16.390348 
[Tue Sep 02 18:25:16 2014] [error] client= 192.168.113.35 
[Tue Sep 02 18:25:16 2014] [error] waiting 
[Tue Sep 02 18:25:16 2014] [error] mod_wsgi.process_group = 'appname' 
[Tue Sep 02 18:25:26 2014] [error] wait finished time = 2014-09-02 18:25:26.400464 

답변

0

후속 요청을 보내기 위해 브라우저와 열린 연결을 재활용하는 브라우저와 관련이 있다면 놀랄 일이 아닙니다. 시크릿 탭에서 전송 된 요청에 대한 새 연결이 열리면 서버의 별도 스레드가이를 처리 할 수 ​​있습니다. 제대로 작동한다는 것은 WSGI 설정이 기본적으로 괜찮음을 보여줍니다.