ok, my wsgi environment key/value pairs are:

wsgi.multithread        True
wsgi.multiprocess       False

i have used no WSGIDaemonProcess/WSGIProcessGroup configuration, just
WSGIScriptAlias to point to my script.


On 24 Ott, 00:42, "Graham Dumpleton" <[EMAIL PROTECTED]>
wrote:
> 2008/10/24 roberto <[EMAIL PROTECTED]>:
>
>
>
> > hello graham,
>
> > i am using mod_wsgi embedded mode. not sure how to check out mpm,
> > prefork or worker since i haven't compiled apache myself.. any clues
> > on how to find out?
>
> If you are using embedded mode, what Apache MPM is used doesn't matter
> as Python code running in mod_wsgi managed daemon processes.
>
> To find out anyway, run 'httpd -V'. See:
>
>  http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
>
> for a further explanation.
>
> Can you post what configuration you have for WSGIDaemonProcess and
> WSGIProcessGroup so can
> see how many processes/threads used as this can influence how database
> connections are used.
>
> Graham
>
> > On 24 Ott, 00:16, "Graham Dumpleton" <[EMAIL PROTECTED]>
> > wrote:
> >> Because of how mod_wsgi currently works, threading.local() stuff will
> >> only work in main interpreter. Ie.,
>
> >>   WSGIApplicationGroup %{GLOBAL}
>
> >> In sub interpreters, the threading.local() object will be destroyed at
> >> end of request.
>
> >> To help provide any feedback on everything else, need to know how
> >> Apache is configured.
>
> >> That is, are you using mod_wsgi embedded mode or daemon mode. If
> >> embedded mode, which Apache MPM, prefork (single threaded) or worker
> >> (multithreaded).
>
> >> Similarly, for daemon mode, how many processes and threads configured
> >> for WSGIDaemonProcess.
>
> >> As I don't have the database experience, hopefully others have tread
> >> this path can comment as well.
>
> >> Graham
>
> >> 2008/10/24 roberto <[EMAIL PROTECTED]>:
>
> >> > dear all,
>
> >> > i'm currently having a hard time in trying to optimize database
> >> > operations called from an apache/mod_wsgi script. i am using
> >> > postgresql.
>
> >> > to give you some background: i have first performed some load testings
> >> > without database operations, and basically my application starts to
> >> > experience performance issues at around 650 simultaneous connections,
> >> > but before that, no errors are reported and everything works fine.
>
> >> > i have then added database operations using a single persistant
> >> > connection, i.e. declared global at module level, and at this point
> >> > after 75 simultaneous connections apache would report a '500 internal
> >> > server' or an unidentified '0' error.
>
> >> > in the apache log i see that the errors raised are:
>
> >> > OperationalError: internal error in 'SELECT * FROM entries...
> >> > AttributeError: 'NoneType' object has no attribute 'dictresult'
> >> > ValueError on return self.db.query(qstr)
>
> >> > which basically mean that either the db connection generated internal
> >> > errors, or it had not been created [NoneType], or the query returned a
> >> > value error response from the postgresql server.
>
> >> > let me clarify immediately that these database operations are not
> >> > heavy ones: i'm talking about a single basic SQL INSERT statement.
>
> >> > the steps i have taken:
>
> >> > 1. tried psycopg2/pygresql
> >> > results do not differ.
>
> >> > 2. tried pygresql with dbutils
> >> > results do not differ.
>
> >> > 3. used threading.local() to store a new connection when necessary
> >> > there were improvements, 120 maximum simultaneous connections handled
> >> > correctly.
>
> >> > 4. like 3. but added forcing the creation of a connection before every
> >> > db operation
> >> > significant improvements, i am currenlty having 5 errors over 400
> >> > simultaneous connections.
>
> >> > basically my code now looks something like this:
>
> >> > ###### local threading
> >> > LT = threading.local()
>
> >> > ###### request handler
> >> > class RequestHandler():
> >> >    def __init__(self):
> >> >        self.SQLconn = None
> >> >        def try_db(self):
> >> >                try:
> >> >                        self.SQLconn = LT.SQLconn
> >> >                except:
> >> >                        self.SQLconn = LT.SQLconn = DB(dbname=DB_NAME, 
> >> > host=DB_HOST,
> >> > port=int(DB_PORT), user=DB_USER, passwd=DB_PASS)
> >> >    def handle(self):
> >> >                # force creation of a db connection
> >> >                self.try_db()
> >> >        self.SQLconn.query("INSERT INTO entries (value) VALUES
> >> > (10);" )
>
> >> > # create object
> >> > r = RequestHandler()
>
> >> > ###### application
> >> > def application(environ, start_response):
> >> >    output = r.handle()
> >> >    response_headers = [('Content-type', 'text/plain'),
> >> >                        ('Content-Length', str(len(output)))]
> >> >    start_response('200 OK', response_headers)
> >> >    return [output]
>
> >> > i'm sure i'm missing out something, or doing something wrong. anyone
> >> > would lend a kind hand to me to get out of this? i can scarcely
> >> > believe that forcing connections all the time is a 'clean' way to go.
>
> >> > thank you in advance,
>
> >> > r.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to