My django application is running on apache+wsgi. Among the module during my django application must load a Java library via jpype which Java library takes very long time to initialize because of its application character.

The issue is that, for every http request handled by django in apache+wsgi setup, this Java library is re-loaded. However, this doesn't happen after i run my same application in development web server (python manager.py runserver 8000). In development web server, it only loads the Java library only one time.

Can there be in whatever way to alter apache or mod_wsgi configuration or my django application to ensure that it will not reload my Java library for each http request?

Thank you.

Andy

You're possibly just getting confused and therefore are really using as poor Apache/mod_wsgi configuration. Particularly, it is possible using embedded mode with Apache prefork MPM. That's bad because Apache uses plenty of single thread processes so the code needs to be loaded in most of these. That's the reason why you most likely believe it is happening on each request from the same process, whereby reality, each request is striking another process.

Make sure you are utilizing daemon mode of mod_wsgi which your code is thread safe and thus use single multithreaded process also it should not possess the problem.

Edit your question and add your Apache/mod_wsgi configuration clips from Apache configuration file and condition what Apache MPM you're using.