Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13047 > unrolled thread

using python in web applications

Started by"Littlefield, Tyler" <tyler@tysdomain.com>
First post2011-09-09 21:54 -0600
Last post2011-09-12 23:56 -0700
Articles 16 — 9 participants

Back to article view | Back to comp.lang.python


Contents

  using python in web applications "Littlefield, Tyler" <tyler@tysdomain.com> - 2011-09-09 21:54 -0600
    Re: using python in web applications Ben Finney <ben+python@benfinney.id.au> - 2011-09-10 14:19 +1000
      Re: using python in web applications "Littlefield, Tyler" <tyler@tysdomain.com> - 2011-09-10 14:53 -0600
    Re: using python in web applications Laurent <laurent.payot@gmail.com> - 2011-09-10 16:35 -0700
    Re: using python in web applications Laurent <laurent.payot@gmail.com> - 2011-09-10 16:35 -0700
      Re: using python in web applications "Littlefield, Tyler" <tyler@tysdomain.com> - 2011-09-10 18:50 -0600
      Re: using python in web applications Chris Angelico <rosuav@gmail.com> - 2011-09-11 13:53 +1000
      Re: using python in web applications Alan Plum <me@alanplum.com> - 2011-09-15 15:24 +0200
        Re: using python in web applications Roy Smith <roy@panix.com> - 2011-09-15 09:42 -0400
    Re: using python in web applications Laurent <laurent.payot@gmail.com> - 2011-09-10 20:21 -0700
    Re: using python in web applications Laurent <laurent.payot@gmail.com> - 2011-09-10 20:21 -0700
    Re: using python in web applications Tim Roberts <timr@probo.com> - 2011-09-11 11:48 -0700
      Re: using python in web applications hidura@gmail.com - 2011-09-11 19:53 +0000
    Re: using python in web applications Laurent <laurent.payot@gmail.com> - 2011-09-11 12:22 -0700
    Re: using python in web applications Laurent <laurent.payot@gmail.com> - 2011-09-11 12:22 -0700
    Re: using python in web applications alex23 <wuwei23@gmail.com> - 2011-09-12 23:56 -0700

#13047 — using python in web applications

From"Littlefield, Tyler" <tyler@tysdomain.com>
Date2011-09-09 21:54 -0600
Subjectusing python in web applications
Message-ID<mailman.924.1315626929.27778.python-list@python.org>
Hello all:
I'm curious if there are some good solutions for using Python in web 
applications.

I'm not feeling particularly masochistic, so I do not want to develop 
this project in PHP; essentially I'm looking to build a web-based MMO. I 
know that you can use nginx with Python with servers like Flask, but I'm 
not really sure how well all of those work. Since this will be a game, I 
can expect quite a few users; I've already got quite a lot of interest. 
I don't much care for PHP, but the thing that can be said for it is it's 
pretty quick. How does Python compare? Are there some solutions (I was 
told about PyPy today) that would be quicker that I could still use for 
the web app? I'm also curious what databases are suggested? I've always 
done most of my work in MYSql, but from what I understand postgresql is 
becoming more popular to.

Thanks all for the input,

-- 

Take care,
Ty
Web: http://tds-solutions.net
The Aspen project: a light-weight barebones mud engine
http://code.google.com/p/aspenmud

Sent from my toaster.

[toc] | [next] | [standalone]


#13048

FromBen Finney <ben+python@benfinney.id.au>
Date2011-09-10 14:19 +1000
Message-ID<87mxedm3lh.fsf@benfinney.id.au>
In reply to#13047
"Littlefield, Tyler" <tyler@tysdomain.com> writes:

> I'm curious if there are some good solutions for using Python in web
> applications.

Start with:

<URL:http://docs.python.org/howto/webservers.html#frameworks>
<URL:http://wiki.python.org/moin/WebFrameworks>

and try your criteria against what you find there.

-- 
 \     “As scarce as truth is, the supply has always been in excess of |
  `\                                       the demand.” —Josh Billings |
_o__)                                                                  |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#13084

From"Littlefield, Tyler" <tyler@tysdomain.com>
Date2011-09-10 14:53 -0600
Message-ID<mailman.951.1315688056.27778.python-list@python.org>
In reply to#13048
On 9/9/2011 10:19 PM, Ben Finney wrote:
> "Littlefield, Tyler"<tyler@tysdomain.com>  writes:
>
>> I'm curious if there are some good solutions for using Python in web
>> applications.
> Start with:
>
> <URL:http://docs.python.org/howto/webservers.html#frameworks>
> <URL:http://wiki.python.org/moin/WebFrameworks>
>

Awesome, will do, thanks.

> and try your criteria against what you find there.
>


-- 

Take care,
Ty
Web: http://tds-solutions.net
The Aspen project: a light-weight barebones mud engine
http://code.google.com/p/aspenmud

Sent from my toaster.

[toc] | [prev] | [next] | [standalone]


#13089

FromLaurent <laurent.payot@gmail.com>
Date2011-09-10 16:35 -0700
Message-ID<mailman.954.1315697736.27778.python-list@python.org>
In reply to#13047
[troll]
For a serious web based MMO you'd rather stick to low level and forget about bloated Object Relational Mapping java-like layered kind of frameworks that are made for Rapid Applications Development, not for efficiency.
[/troll]

"Eve Online", a well known MMORPG was developped with stackless python : http://highscalability.com/eve-online-architecture

You mentioned nginx so I can tell you I personally use Linux + nginx + mongodb (pymongo) + Python 3 version of cherrypy (with Mako templates) and it's working fine after some tuning.

[toc] | [prev] | [next] | [standalone]


#13092

FromLaurent <laurent.payot@gmail.com>
Date2011-09-10 16:35 -0700
Message-ID<53b67f0d-509a-46c4-83c8-7b9783ff1b5c@glegroupsg2000goo.googlegroups.com>
In reply to#13047
[troll]
For a serious web based MMO you'd rather stick to low level and forget about bloated Object Relational Mapping java-like layered kind of frameworks that are made for Rapid Applications Development, not for efficiency.
[/troll]

"Eve Online", a well known MMORPG was developped with stackless python : http://highscalability.com/eve-online-architecture

You mentioned nginx so I can tell you I personally use Linux + nginx + mongodb (pymongo) + Python 3 version of cherrypy (with Mako templates) and it's working fine after some tuning.

[toc] | [prev] | [next] | [standalone]


#13095

From"Littlefield, Tyler" <tyler@tysdomain.com>
Date2011-09-10 18:50 -0600
Message-ID<mailman.960.1315702295.27778.python-list@python.org>
In reply to#13092
On 9/10/2011 5:35 PM, Laurent wrote:
> [troll]
> For a serious web based MMO you'd rather stick to low level and forget about bloated Object Relational Mapping java-like layered kind of frameworks that are made for Rapid Applications Development, not for efficiency.
> [/troll]
>
I replied to that one off list I guess, but I figured Django was way 
more overhead than I wanted, doesn't really fit with solving the speed 
issue.

> "Eve Online", a well known MMORPG was developped with stackless python : http://highscalability.com/eve-online-architecture
>
> You mentioned nginx so I can tell you I personally use Linux + nginx + mongodb (pymongo) + Python 3 version of cherrypy (with Mako templates) and it's working fine after some tuning.

Awesome, thanks. I'm new to this, so some of that flew over my head, but 
I'll take a look at all of them. I'm not sure of the relevance of 
stackless in this case; I was looking into PyPy, but I'm not really sure 
whether that can be connected with nginx. I guess I could just write the 
web server in Python and use it from that point.

-- 

Take care,
Ty
Web: http://tds-solutions.net
The Aspen project: a light-weight barebones mud engine
http://code.google.com/p/aspenmud

Sent from my toaster.

[toc] | [prev] | [next] | [standalone]


#13107

FromChris Angelico <rosuav@gmail.com>
Date2011-09-11 13:53 +1000
Message-ID<mailman.968.1315713233.27778.python-list@python.org>
In reply to#13092
On Sun, Sep 11, 2011 at 9:35 AM, Laurent <laurent.payot@gmail.com> wrote:
> [troll]
> For a serious web based MMO you'd rather stick to low level and forget about bloated Object Relational Mapping java-like layered kind of frameworks that are made for Rapid Applications Development, not for efficiency.
> [/troll]

I have been trolled. :)

For any sort of web-based real-time game, here's two things to avoid:

1) Snoopability and modifiability of crucial data. Everything should
be stored on the server, so that if anyone fiddles, all they do is
break their own client so it has to reload from the server.
2) Massive waste of resources due to unnecessary frameworks/facilities.

I play a lot of Flash games, and right now I'm playing one that has
coped poorly with a miniature slashdotting. A spike in popularity
resulted in a spike in server lag. I fired up a little packet sniffer,
and discovered that every time you do anything in the game, the client
makes a new POST request to its server. Why?! It's not that hard to
hold a socket connection open!

In another context, a similar issue - not a problem as yet (that I
know of), but would be if the system were to be slashdotted. A server
whose sole purpose is to handle script-instigated requests (using HTTP
POST for its transport) sends back a Set-Cookie header with a session
id. This implies that the server is holding session data for all these
clients that are never going to send that cookie back. The server
appears to be IIS with ASP scripts, so presumably stateful sessions
are enabled by default, so it's costing memory and processing to hold,
then discard, all those useless (and probably empty) session state
tags. And presumably many MANY other servers have the same thing.

What's YOUR framework doing that you don't need, and how much is it costing you?

Yeah, I was trolled bad. :)

ChrisA

[toc] | [prev] | [next] | [standalone]


#13322

FromAlan Plum <me@alanplum.com>
Date2011-09-15 15:24 +0200
Message-ID<mailman.1164.1316093103.27778.python-list@python.org>
In reply to#13092
On 2011-09-11 02:50, Littlefield, Tyler wrote:
> I replied to that one off list I guess, but I figured Django was way 
> more overhead than I wanted, doesn't really fit with solving the speed 
> issue.

Depending on your needs, you may find something like bottle or Flask a 
better choice then.

Django can be scaled down a lot, but it's a full-featured framework at 
its heart. Bottle is pretty minimal (IIRC it doesn't even come with any 
templating). Flask is somewhere in between as it bundles Werkzeug (a 
pure WSGI framework) with Jinja (a template library) with some glue code.

I have used Flask in the past but often found myself implementing half 
of Django anyway, which is why I eventually switched. When I only need a 
bare API with no database and without templates, I usually go for Bottle 
these days.

If you feel like coding closer to the metal and care more about 
performance than readability, you might also find Twisted useful.

[toc] | [prev] | [next] | [standalone]


#13323

FromRoy Smith <roy@panix.com>
Date2011-09-15 09:42 -0400
Message-ID<roy-1C1F09.09423315092011@news.panix.com>
In reply to#13322
In article <mailman.1164.1316093103.27778.python-list@python.org>,
 Alan Plum <me@alanplum.com> wrote:

> Django can be scaled down a lot, but it's a full-featured framework at 
> its heart.

You can pick and chose which parts of django you want to use.  You don't 
need to use any of the Django model stuff.  You don't need to use any of 
the template system.  You can tear out all or most of the default 
middleware.  At that point, about all that's left is the route parser 
and dispatch code.  The nice thing about this is that as you 
incrementally discover which pieces of it you really do need, it's easy 
to pull them in.

That being said, we've made a lot of use of Tornado for small 
stand-alone web services with just a couple of routes.  In retrospect, 
it's unclear if there's any justifiable argument for why we use both 
Tornado and Django, other than hysterical raisins.

[toc] | [prev] | [next] | [standalone]


#13104

FromLaurent <laurent.payot@gmail.com>
Date2011-09-10 20:21 -0700
Message-ID<mailman.966.1315711316.27778.python-list@python.org>
In reply to#13047
Well PyPy is just an implementation of Python among many others (but limited to version 2.7). It is not a web server. If you want to make PyPy interact with a web server (such as nginx) you have to use a special protocol such as WSGI or Fast-CGI. For best performances you can for instance use uWSGI that integrates well with nginx but for this you have to recompile nginx. As you see it's a bit complex, you should read the wikis. May the Force be with you.

[toc] | [prev] | [next] | [standalone]


#13106

FromLaurent <laurent.payot@gmail.com>
Date2011-09-10 20:21 -0700
Message-ID<3c8c4056-aa89-4a7c-a22c-44baf97a02c1@glegroupsg2000goo.googlegroups.com>
In reply to#13047
Well PyPy is just an implementation of Python among many others (but limited to version 2.7). It is not a web server. If you want to make PyPy interact with a web server (such as nginx) you have to use a special protocol such as WSGI or Fast-CGI. For best performances you can for instance use uWSGI that integrates well with nginx but for this you have to recompile nginx. As you see it's a bit complex, you should read the wikis. May the Force be with you.

[toc] | [prev] | [next] | [standalone]


#13141

FromTim Roberts <timr@probo.com>
Date2011-09-11 11:48 -0700
Message-ID<re0q675ntaul3914kgkd1118f7tf5grq70@4ax.com>
In reply to#13047
"Littlefield, Tyler" <tyler@tysdomain.com> wrote:
>
>I don't much care for PHP, but the thing that can be said for it is it's 
>pretty quick. How does Python compare?

PHP is quick for development, in that you can slap together some schlock
and have it mostly work.  The result, however, is usually schlock.  The
performance of the language itself is almost entirely irrelevant; the
execution time is swamped by the network overhead.

>I'm also curious what databases are suggested? I've always 
>done most of my work in MYSql, but from what I understand postgresql is 
>becoming more popular to.

Well, that's a religious argument.  Personally, I've always been confused
by the draw of MySql.  From the very beginning, Postgres has always been
more powerful, more reliable, more standard-compliant, and more
professional.
-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

[toc] | [prev] | [next] | [standalone]


#13148

Fromhidura@gmail.com
Date2011-09-11 19:53 +0000
Message-ID<mailman.1006.1315770818.27778.python-list@python.org>
In reply to#13141
I am agree with postgresql i don' t have any problem, also is better for big applications. And Python is always better language than PHP if you' re going to create a web app.
Sent from my BlackBerry® wireless device

-----Original Message-----
From: Tim Roberts <timr@probo.com>
Sender: python-list-bounces+hidura=gmail.com@python.org
Date: Sun, 11 Sep 2011 11:48:01 
To: <python-list@python.org>
Subject: Re: using python in web applications

"Littlefield, Tyler" <tyler@tysdomain.com> wrote:
>
>I don't much care for PHP, but the thing that can be said for it is it's 
>pretty quick. How does Python compare?

PHP is quick for development, in that you can slap together some schlock
and have it mostly work.  The result, however, is usually schlock.  The
performance of the language itself is almost entirely irrelevant; the
execution time is swamped by the network overhead.

>I'm also curious what databases are suggested? I've always 
>done most of my work in MYSql, but from what I understand postgresql is 
>becoming more popular to.

Well, that's a religious argument.  Personally, I've always been confused
by the draw of MySql.  From the very beginning, Postgres has always been
more powerful, more reliable, more standard-compliant, and more
professional.
-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list

[toc] | [prev] | [next] | [standalone]


#13143

FromLaurent <laurent.payot@gmail.com>
Date2011-09-11 12:22 -0700
Message-ID<26428844-acd2-4c7b-bc6a-cf5a8a6259bc@glegroupsg2000goo.googlegroups.com>
In reply to#13047
+1 for PostgreSQL. It's faster than MySQL for years now, and is much more seriously featured.
If you don't need ACID properties (transactions stuff) you should also give Document-based databases like MongoDB a try. It changed my code life.

[toc] | [prev] | [next] | [standalone]


#13144

FromLaurent <laurent.payot@gmail.com>
Date2011-09-11 12:22 -0700
Message-ID<mailman.1002.1315768955.27778.python-list@python.org>
In reply to#13047
+1 for PostgreSQL. It's faster than MySQL for years now, and is much more seriously featured.
If you don't need ACID properties (transactions stuff) you should also give Document-based databases like MongoDB a try. It changed my code life.

[toc] | [prev] | [next] | [standalone]


#13216

Fromalex23 <wuwei23@gmail.com>
Date2011-09-12 23:56 -0700
Message-ID<775ad552-1452-4b32-bf93-024c6d3761ea@u6g2000prc.googlegroups.com>
In reply to#13047
On Sep 10, 1:54 pm, "Littlefield, Tyler" <ty...@tysdomain.com> wrote:
> I'm not feeling particularly masochistic, so I do not want to develop
> this project in PHP; essentially I'm looking to build a web-based MMO.

Google have been promoting the use of appengine along with HTML5 & JS
to produce games. One advantage of using GAE to host the server is it
takes care of the scaling for you.

I found these presentations fascinating:
http://cc-2011-html5-games.appspot.com/#1
http://io-2011-html5-games-hr.appspot.com/#1

This article covers the process in a little more depth:
http://clouddbs.blogspot.com/2011/02/how-to-write-html5-game-in-30-days-with.html

Google are also aggregating platform-specific info here:
http://code.google.com/games

Hope this helps (and let us know when you have something to show off!)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web