2008/10/23 roberto <[EMAIL PROTECTED]>: > > hello graham, > > thank you for your response, your work and help is seriously > appreciated! let me rephrase my question. > > i have a main python class that has some relevant processing power > when it is initialized. from then on, individual operations are > consistently faster. i need to use this class to provide a REST-like > web-based application. > > please do correct me if i'm wrong, but basically it seems to me that i > have three choices: > > 1. use apache + mod_wsgi, which would mean that my main python class > is re-initialized on every http request;
It shouldn't be getting re-initialised on every request unless that is how you code it. The WSGI script file is effectively only read the once per process and any objects in are cached, so provided that initialisation is done when script loaded it should not be done on every request. Can you post an example of your code from WSGI script file which you say is resulting in it being loaded every time. Also be aware that on UNIX, Apache is a multi process web server. Thus what you may see as it being loaded on every request may be that request is going to a different process. The only other thing I can think of which may cause initialisation on every request is that you are relying on 'threading.local'. There are some known issues with that not preserving data across requests even for the same thread. Anyway, need to clarify why you think it is reloading on every request before commenting further. Graham > 2. use apache + mod_wsgi + cherrypy, so that my main python class is > initialized on cherrypy application launch and used thereafter [using > the hook application = cherrypy.Application(Root(), None)]; > 3. use apache as a proxy which only redirects traffic to a cherrypy > instance. > > my question is therefore: which choice do you believe can better > optimize performance? i am trying here to find out the architecture > which could better perform under considerable load, also re > multithreading and multiprocessing issues. > > not sure if this adds relevant information, but my main python class > does perform database operations using psycopg2. > > thank you in advance, > > r. > > On 22 Ott, 23:59, "Graham Dumpleton" <[EMAIL PROTECTED]> > wrote: >> Can you perhaps rephrase or explain what you mean by: >> >> """ >> for this reason, instead of having apache with >> mod_wsgi launching my application on every http request, i have >> integrated cherrypy with mod_wsgi. >> """ >> >> When using Apache/mod_wsgi, your CherryPy instance would not be >> launching on very HTTP request. >> >> Did you really mean to say 'mod_wsgi' in that first instance? >> >> Graham >> >> 2008/10/23 roberto <[EMAIL PROTECTED]>: >> >> >> >> > hi carl, >> >> > and thank you for your response. i am not sure i do understand, i do >> > use the cherrypy integration recommended with wsgi, hooking cherrypy >> > from wsgi with: >> >> > application = cherrypy.Application(Root(), None) >> >> > ..is this what you meant? and if so, is this the best way to go? i'm >> > asking since i'm not sure about which is the optimization i can look >> > for in multithreading and multiprocessing. >> >> > again, thank you, >> >> > r. >> >> > On 22 Ott, 23:19, "Carl Nobile" <[EMAIL PROTECTED]> wrote: >> >> It is always better to run frameworks by themselves and just have a small >> >> hook *.wsgi script to connect you to the framework. I'm surprised there >> >> isn't some sort of hook script already with cherrypy, I know Django has >> >> one >> >> and many other have one also. >> >> >> Graham correct me if I'm wrong, but mod_wsgi imports all the *pyc files >> >> that >> >> the hook script calls, so subsequent requests will all be much faster >> >> anyway, but I still wouldn't advise depending on this with a large >> >> framework. >> >> >> -Carl >> >> >> On Wed, Oct 22, 2008 at 1:46 PM, roberto <[EMAIL PROTECTED]> wrote: >> >> >> > hi all, >> >> >> > hopefully not a question answered here, i couldn't find anything >> >> > relevant in my searches. otherwise i do apologize. >> >> >> > i have an http python application that has some relevant processing >> >> > power on start up. for this reason, instead of having apache with >> >> > mod_wsgi launching my application on every http request, i have >> >> > integrated cherrypy with mod_wsgi. >> >> >> > my question is: would i be better off using cherrypy directly [and >> >> > apache only for proxying]? or is this the best way to go? i am >> >> > expecting consistent load and trying to maximize answered simultaneous >> >> > connections. >> >> >> > thank you, >> >> >> > 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 -~----------~----~----~----~------~----~------~--~---
