How to configure apache for optimal execution of python programs

How can the apache web server be configured for optimal execution of external python programs which include many libraries such as numpy and scipy and Gnuplot and home-grown python libs ?

Currently we simply use a CGI interface to launch the python programs in a bash shell script, but this is probably not optimal because it loads and initializes python and all the included python libs every time - unless apache somehow caches these things, I don't know.

Would it be enough to make sure the "mod_python" is linked in ? How can I do that? I am not the web sysadmin, but of course I can request info and changes.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

-Richard-Connect With a Mentor Commented:
It's not enough simply to make sure that mod_python is linked in.  Mod_python allows you to execute Python code in an extremely efficient manner that does not require reloading the interpreter on every call.  However, the Python code invoked has to follow all the usual conventions of Web programming.
In other words, it has to process a request and format a response.  I presume that your external programs do not do this in their current form.  As a result, some effort would be required to rewrite these programs so that they could be callable as methods from front end programs which you would have to write, that would be web-aware and would perform necessary request and response processing.

The following article gives a good brief overview of how to interface Python modules with the Web and use mod_python to do it:

So it would not be trivial to accomplish what you need, but I doubt the effort would be prohibitive either, and you would indeed end up with an efficient system that's way faster than CGI, which you have correctly recognized as being very slow.
Addendum: I said  << I presume your external prgrams do not do this in their current form... >>,   but that was probably not exactly true.  As CGI programs they do perform request and response processing of a sort, but to work under mod_python they would require modifications.   For more details, refer to the mod_python documentation here:
PhazzAuthor Commented:
Thanks for your helpful information.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.