Solved

How to configure apache for optimal execution of python programs

Posted on 2011-03-21
4
372 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
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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…

910 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

24 Experts available now in Live!

Get 1:1 Help Now