Solved

How to configure apache for optimal execution of python programs

Posted on 2011-03-21
4
371 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 500 total points
Comment Utility
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-
Comment Utility
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-
Comment Utility
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
Comment Utility
Thanks for your helpful information.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
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 …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now