Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to configure apache for optimal execution of python programs

Posted on 2011-03-21
4
Medium Priority
?
382 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:Phazz
  • 3
4 Comments
 
LVL 5

Accepted Solution

by:
-Richard- earned 2000 total points
ID: 35180072
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.
0
 
LVL 5

Expert Comment

by:-Richard-
ID: 35180117
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:  http://onlamp.com/pub/a/python/2003/10/02/mod_python.html.

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.
0
 
LVL 5

Expert Comment

by:-Richard-
ID: 35180165
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:  http://www.modpython.org/live/current/doc-html/
0
 

Author Closing Comment

by:Phazz
ID: 35180740
Thanks for your helpful information.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing Python 2.7.3 version on Windows operating system For installing Python first we need to download Python's latest version from URL" www.python.org " You can also get information on Python scripting language from the above mentioned we…
Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question