2008/8/22 Olive <[EMAIL PROTECTED]>:
>
>
> After further testing I've noticed this:
>
> Just after restarting Apache:
> mod_python: 2.52s
> mod_wsgi: 2.08s
>
> subsequent requests give more or less the same results.
>
> After 9 requests or so:
> mod_python: 5.28s
> mod_wsgi: 4.5s
>
> ... and so on.
>
> Finally, mod_wsgi seems to be faster but could you explain why every 9
> requests cPcikle takes 2 more seconds to load an object while it is
> more or constant in between ?
>
> For me 2s would be acceptable (and it seems that I could cut that by
> two by moving to a more recent box under Fedora 9 and Python 2.5.1).
>
> I'm timing around cPickle this way:
>
> import cPickle, time
> def elapsed(): return str(round(time.clock(),4))
> start = time.clock()
> index = cPickle.load(open('index.db'))
> return 'Index loaded: %' % elapsed()
>
> The index is a dictionary with a string (an English word) as key and a
> set() of strings (14 characters max) as value.
> There are around 18000 entries in it and the pickle object is 6MB.
>
> By the way, is their a mean to load this dictionary once in memory
> with mod_wsgi and use it in subsequent requests, or do I need to run a
> separate Python process and communicate with it using sockets ?

Any code executed as a side effect of code file imported, ie., at
global scope in module, is done only once.

In other words, don't do it on each request, just do it once when code
file it is needed by is imported. Store the subsequent data in a
global variable within the module.

Preloading at process start can be done with mod_wsgi using
WSGIImportScript directive:

  http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIImportScript

This is akin to the PythonImport directive in mod_python.

Graham

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to modwsgi@googlegroups.com
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