473,750 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python as a Server vs Running Under Apache



I am starting the design phase of a large project (ERP) where the
backend will mostly be Python (or Ruby) providing web services.

In this type of usage, is there any benenfit to running under Apache
as opposed to a pure Python solution using Medusa, TwistedMatrix, or
the like?

Thanks,
Matt
Dec 29 '05 #1
9 3761
Matt Helm wrote:
I am starting the design phase of a large project (ERP) where the
backend will mostly be Python (or Ruby) providing web services.

In this type of usage, is there any benenfit to running under Apache
as opposed to a pure Python solution using Medusa, TwistedMatrix, or
the like?


Running under Apache is nice if you need other apache services like
proxying, mod_rewrite, some of the accelerated static file serving
plugins, etc. Many of those now have replacements in Twisted (and
presumably other systems), but if you're coordinating with other parts
of the system running under Apache then it may be a reasonable choice.
Also, there may be some political/marketing gain (easier to pitch your
proposal if it's running under Apache).

But basically, if you're doing a pure-python system from scratch then
there's not much gained by running under Apache.

Dec 29 '05 #2

<sj*******@yaho o.com> writes:
Running under Apache is nice if you need other apache services like
proxying, mod_rewrite, some of the accelerated static file serving
plugins, etc.
Not needed, this is web services only. That is, Apache is needed, but
only to handle the PHP consumers of the web services.

Also, there may be some political/marketing gain (easier to pitch your
proposal if it's running under Apache).
Not a problem. I get the final say-so on the design, platform, and
languages we use.

But basically, if you're doing a pure-python system from scratch then
there's not much gained by running under Apache.


Thanks, that is exactly what I was needing to know.

Matt
Dec 29 '05 #3
Matt Helm wrote:

I am starting the design phase of a large project (ERP) where the
backend will mostly be Python (or Ruby) providing web services.

In this type of usage, is there any benenfit to running under Apache
as opposed to a pure Python solution using Medusa, TwistedMatrix, or
the like?

Thanks,
Matt

If it is a large project and you like Python as back end be sure
to evaluate using Zope (which can use Apache as a front end for
serving up static info and for SSL, etc.). With Zope you get a
lot of "free" stuff like XMPRPC, DAV, FTP, that can take quite
a lot of time to implement from scratch. It may not be for you,
but you owe it to yourself to take a look.

-Larry Bates
Dec 30 '05 #4
as great as mod_python is, there are lots of restrictions and
limitations to what youc an do with it because of limitations of apache
itself, and I am refereing to apache 2.x as well as 1.x, like others
are saying if you don't need apache specific things it will just be one
more thing to work around the design constraints it causes, twisted
will be you best bet

Dec 30 '05 #5
> as great as mod_python is, there are lots of restrictions and
limitations to what youc an do with it because of limitations of apache
itself, and I am refereing to apache 2.x as well as 1.x, like others
are saying if you don't need apache specific things it will just be one
more thing to work around the design constraints it causes, twisted
will be you best bet


I don't recollect that anyone had actually mentioned mod_python.
Certainly, mod_python isn't the only way of doing things via Apache
with Python.

Now, I am not trying to defend mod_python, as I probably better than
most understand many of the bugs/issues that the current version of
mod_python has, but what are the restrictions and limitations in it
that you see it has based on it being built on Apache.

Anyway, just curious to see what is behind your comment and how
deeply you truly understand the inner workings of mod_python, its
relationship to Apache and thus its problems.

Look forward to you answer.

Graham

Dec 31 '05 #6
I guess I'm a little confused, and this certainly comes from not yet
having tried to do anything with Python on a web server.

I remarked once to a Python programmer that it appeared to me that if I
had a web page that called a Python program, that the server would:
1. Load Python
2. Run the program
3. Unload Python

Then the next time it has to serve up that page, it would have to
repeat the process. This seems inefficient, and it would slow the site
down. The programmer confirmed this. He said that's why I should use
mod_python. It stays resident.

Is this advice accurate? Are there other things to consider? Isn't
there just some way (short of running something like Zope) that would
keep Python resident in the server's RAM? This is a shared server, so
the web host probably doesn't like stuff sitting around in RAM.

Right now, I only need small programs to run. E.g., I'm thinking of
embedding a Live Journal blog in my web page. Live Journal gives you
several ways of doing this, one of which is three lines of Python code.

Ron Britton

(This email address will be deleted in a couple of days, once it starts
receiving spam from this posting. Please reply to the group!)

Jan 1 '06 #7
"mojosam" <zj*******@snea kemail.com> writes:
Is this advice accurate? Are there other things to consider? Isn't
there just some way (short of running something like Zope) that would
keep Python resident in the server's RAM? This is a shared server, so
the web host probably doesn't like stuff sitting around in RAM.
Jean-Paul Calderone has already answered most of these, so I'll get
the last one.

Stuff "sitting around in RAM" unusued on a busy server leaves RAM
pretty quickly on a modern system. The executable pages will just be
tossed, and reloaded from the executable file when they are needed
again. Data pages will be written out to disk in the swap area, and
read back in when they are needed. Unless your program's behavior is
very strange, this will generally be quicker than recreating the
program state from scratch. The end result is that your program loads
faster, and the real RAM used to support this is negligible.
Right now, I only need small programs to run. E.g., I'm thinking of
embedding a Live Journal blog in my web page. Live Journal gives you
several ways of doing this, one of which is three lines of Python code.


Trying to make your dynamic HTML content "fast" before you need to is
a premature optimization. Yes, CGI is slow compared to some of the
alternatives. But forks on Unix are still cheap, and you can handle
quite a bit of traffic with it on a modern system before you run into
a wall. Do it with CGI first, and fix it later if you need to.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 2 '06 #8
there are lots of things you can't do or can't do easily or can't do at
efficiently in Apache using python as cgi or as anyone would more
likely assume mod_python. anything that requires any shared state or
shared resources in Apache is next to impossible. Doing similar things
in an app server or network application framework like twisted is
trivial.

Jan 4 '06 #9
fuzzylollipop wrote:
there are lots of things you can't do or can't do easily or can't do at
efficiently in Apache using python as cgi or as anyone would more
likely assume mod_python. anything that requires any shared state or
shared resources in Apache is next to impossible. Doing similar things
in an app server or network application framework like twisted is
trivial.


What one really should be identifying here is that different tools are
better for different jobs.

Apache is a web server, and it isn't necessarily practical or sensible
to try and shoe horn it into service as a full blown application server
by and in itself. At the same time though, I would suggest that
something like Twisted is in itself not always the best solution
either, ie., to take an application server, and try and bolt on to it a
web server. Yes Twisted can perform as a web server, but when compared
to the functionality and configurability that Apache provides as a web
server, it is always going to be a lessor cousin in that role. If you
do not need the full power that Apache can provide and can live with
the lessor abilities inherent from running the web server as a
component within the application server, then great, but this isn't
necessarily going to suit everyone either.

Thus one is still faced with the question of whether you should embed
the application in the web server, or wrap a web server around the
application. Unfortunately from what I have seen, often the decision is
made based on the narrow focus of expertise of the developers involved.
A web developer will be dismissive of the application developer and
vice versus. Each will say that it is trivial if done in the system
which embodies their area of expertise, although usually that is said
without them really knowing how they will achieve the part they don't
know too much about. The strongest personalities thus will win as to
how the system is built.

The alternative is to accept that both Apache and application
frameworks such as Twisted are each good in their own space and use
both, bridging between the two as necessary. This could be done using
simple protocols like XML-RPC or more sophisticated messaging system
protocols where persistent connections can exist between the Apache
child processes and the backend application server thus avoiding the
creation of socket connections on every request. The use of messaging
systems also means that presence information can extend into the realm
of the web server and it can be easier to deal with failure or
unavailability of components of the backed system.

Keeping a split like this means you also have the added benefit that
you don't end up with application server code which is somehow
inherently dependent on or knowing that it is being used purely within
the context of a particular web server. You don't end up with
application server code being tied to the use of a specific means of
rendering web pages. With this sort of split it doesn't matter whether
you use CGI, mod_python, mod_perl or PHP for web page generation.
Provided that the interfaces between the two are well defined, you can
change the application server code structure as much as you like and
the web page generation code doesn't need to change. The opposite also
applies in as much as changes to the web page generation code shouldn't
affect the application server code.

Overall I would have to say that you are both right and wrong. Where
the state is served purely by the use of the database, there is nothing
wrong with Apache/mod_python in itself being used. Where the state also
embodies the need to have active agents which operate on that data,
possibly independent of web requests, then a back end application
server which embeds the core functionality of the application would be
better. In doing that though, it doesn't mean that Apache has to be
discarded as the web server, and a web server embeded in the
application server be adopted. Depending on the requirements, you will
get a more flexible, more easily maintained system if a combination of
the two technologies is used.

Anyway, that statisifies my daily need for a good rant. ;-)

Graham

Jan 5 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
3660
by: Erik Johnson | last post by:
This is somewhat a NEWBIE question... My company maintains a small RDBS driven website. We currently generate HTML using PHP. I've hacked a bit in Python, and generally think it is a rather cool language. I've done Perl and like it, there are a few features of PHP I like but overall am not too excited about it. I have found PHP's strtotime() function to be quite flexible and handy and we make liberal use of it. I have not yet really...
10
3690
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. Andrew dalke@dalkescientific.com
1
2789
by: neha | last post by:
hi, i m trying to integrate python with apache on linux.For this i m using mod_python. I dont see any problem with the versions of python,apache and mod_python i m using. the versions i m using are apache version2. mod_python v3.1.14 python2.4 The problem is,when i m running my python script,after starting apache
122
7890
by: seberino | last post by:
I'm interested in knowing which Python web framework is most like Ruby on Rails. I've heard of Subway and Django. Are there other Rails clones in Python land I don't know about? Which one has largest community/buzz about it?
7
1821
by: Ben Finney | last post by:
Howdy all, I'm working on a web application that is starting to gain a lot of back-end code written in Python. However, all the current interface code is written in legacy PHP. I'd like to slowly introduce new features as Python WSGI programs. Is it possible to write a Python WSGI program that talks to a PHP program as its "back end"? Where can I find out how to do this, preferably with examples?
852
28564
by: Mark Tarver | last post by:
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for my general education. Mark
113
5300
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside the Python world, you're fine. But once you do, things go downhill. MySQLdb has version and platform compatibility problems. So does M2Crypto. The built-in SSL support is weak. Even basic sockets don't quite work right; the socket module...
3
8510
by: falloutphil | last post by:
Hi, First of all sorry for the double post - this is on the Python page too, but as far as I can see this is an Apache issue now. Mods - feel free to delete the similar titled posts from me on Python, if this is the case (can't seem to do it myself!). Anyway, I'm running a CGI script written in python that tars up the photos in user selected directories (via a form). It's running on Apache 1.3.31.1 on Solaris 5.8. It works well for a...
5
1641
by: walterbyrd | last post by:
I don't know much php either, but running a php app seems straight forward enough. Python seems to always use some sort of development environment vs production environment scheme. For development, you are supposed to run a local browser and load 127.0.0.1:5000 - or something like that. Then to run the same thing in a development environment, I have to configure some files, or touch all the files, restart the web-server, or something....
0
9000
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9396
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9339
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6804
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.