[newbie] Equivalent to PHP?

Christian Heimes lists at cheimes.de
Wed Jun 13 11:27:21 EDT 2012


Am 12.06.2012 11:39, schrieb Gilles:
> I notice that Python-based solutions are usually built as long-running
> processes with their own web server (or can run in the back with eg.
> Nginx and be reached through eg. FastCGI/WSGI ) while PHP is simply a
> language to write scripts and requires a web server (short running
> processes).

A long running process has lots of benefits that makes design and
development easier and makes your app faster.

* Don't underestimate the costs of process creation. It doesn't scale
unless you fork() childs which is more complex and still doesn't scale
as well as a long running process.

* you can do all costly and time consuming operations on startup like
loading all configuration files and databases like i18n stuff.

* performance tweaks like database connection pool works only with a
long running process.

* in-process caching is usually easier to implement and faster. In some
cases only in-process works.

* you can have background tasks without the requirement of an outside
service like cron + wget.

* async server based on a select()-like reactor are only possible when a
single process handles the incoming connections.


A long running process is more powerful and the 'enterprise' way of
doing it right. All important and large scale Python and Java solutions
are using long running processes instead of a CGI-like model.

PHP's way is a poor man's solution to compensate for bad design and
memory holes. PHP's ancestor PHTML still bleeds through and makes you
suffer for mistakes of the past.

Christian




More information about the Python-list mailing list