On Fri, Mar 06, 2009 at 09:31:43PM +1100, Graham Dumpleton wrote:
>
> What Apache MPM are you running, prefork or worker MPM?
prefork, I guess...
load:/home/jinty# apache2 -V
...
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
...
> What are the MPM settings you are using for Apache for that MPM?
<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 3
MaxClients 5
MaxRequestsPerChild 0
</IfModule>
> Are you running the WSGI application in embedded mode or daemon mode?
Daemon mode.
This is the virtual server config:
WSGIDaemonProcess nobody processes=1 threads=1 maximum-requests=1000000
display-name=wsgitest user=nobody home=/
WSGIReloadMechanism Process
<VirtualHost *:80>
WSGIProcessGroup nobody
Servername wsgi.example.com
ServerAdmin [email protected]
ServerSignature On
WSGIScriptAlias / /etc/apache2/wsgi/wsgitest.wsgi
<Directory /etc/apache2/wsgi/wsgitest.wsgi>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
>
> Graham
>
> 2009/3/6 Brian Sutherland <[email protected]>:
> >
> > Hi,
> >
> > I've managed to make a minimal wsgi application that shows off a
> > problem we encountered in production. It looks like mod_wsgi is
> > leaking the temporary files we give to it. Perhaps we are doing
> > something wrong, but I couldn't find any docs against passing
> > tempfile.mkstemp files to mod_wsgi. Curiously, creating the file with
> > tempfile.TemporaryFile rather than tempfile.mkstemp has allowed us to
> > work around the issue.
> >
> > Basically running ab against this application:
> >
> > #!/usr/bin/python
> > import tempfile
> > import os
> >
> > def application(environ, start_response):
> > status = '200 OK'
> > output = 'Hello World!'
> >
> > response_headers = [('Content-type', 'text/plain'),
> > ('Content-Length', str(len(output)))]
> >
> > start_response(status, response_headers)
> >
> > # Make a temporary file and write data to it
> > _, filename = tempfile.mkstemp()
> > f = open(filename, 'wb')
> > f.write(output)
> > f.close()
> >
> > # Make a deleted read-only file to pass to mod_wsgi
> > readf = open(filename, 'rb')
> > os.remove(filename)
> >
> > wrapper = environ.get('wsgi.file_wrapper')
> > return wrapper(readf)
> >
> > Causes these errors:
> >
> > [Fri Mar 06 09:50:16 2009] [error] [client 62.57.1.12] mod_wsgi
> > (pid=18665): Exception occurred processing WSGI script '/etc/apache2/
> > wsgi/wsgitest.wsgi'.
> > [Fri Mar 06 09:50:16 2009] [error] Traceback (most recent call last):
> > [Fri Mar 06 09:50:16 2009] [error] File "/etc/apache2/wsgi/
> > wsgitest.wsgi", line 15, in application
> > [Fri Mar 06 09:50:16 2009] [error] File "tempfile.py", line 302, in
> > mkstemp
> > [Fri Mar 06 09:50:16 2009] [error] File "tempfile.py", line 236, in
> > _mkstemp_inner
> > [Fri Mar 06 09:50:16 2009] [error] OSError: [Errno 24] Too many open
> > files: '/tmp/tmp3zONgs'
> >
> > Because you very quickly get to the per-process file limit:
> >
> > load:/etc/apache2/wsgi# ls /proc/18665/fd | wc -l
> > 1023
> >
> > We're running python 2.4.4, apache 2.2.3-4+etch6 on Debian Etch and
> > have seen this with mod_wsgi 2.1 and 2.3.
> >
> > Many Thanks,
> > Brian
> >
> > >
> >
>
> >
--
Brian Sutherland
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---