using python in web applications

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

using python in web applications

Littlefield, Tyler
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.

--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Ben Finney-10
"Littlefield, Tyler" <[hidden email]> 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
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Littlefield, Tyler
On 9/9/2011 10:19 PM, Ben Finney wrote:
> "Littlefield, Tyler"<[hidden email]>  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.

--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Laurent-65
In reply to this post by Littlefield, Tyler
[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.
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Littlefield, Tyler
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.

--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Laurent-65
In reply to this post by Littlefield, Tyler
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.
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Chris Angelico
In reply to this post by Laurent-65
On Sun, Sep 11, 2011 at 9:35 AM, Laurent <[hidden email]> 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
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Tim Roberts
In reply to this post by Littlefield, Tyler
"Littlefield, Tyler" <[hidden email]> 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, [hidden email]
Providenza & Boekelheide, Inc.
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Laurent-65
In reply to this post by Littlefield, Tyler
+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.
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

hidura
In reply to this post by Tim Roberts
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 <[hidden email]>
Sender: python-list-bounces+hidura=[hidden email]
Date: Sun, 11 Sep 2011 11:48:01
To: <[hidden email]>
Subject: Re: using python in web applications

"Littlefield, Tyler" <[hidden email]> 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, [hidden email]
Providenza & Boekelheide, Inc.
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

alex23
In reply to this post by Littlefield, Tyler
On Sep 10, 1:54 pm, "Littlefield, Tyler" <[hidden email]> 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!)
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Alan Plum-4
In reply to this post by Littlefield, Tyler
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.
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: using python in web applications

Roy Smith
In reply to this post by Littlefield, Tyler
In article <[hidden email]>,
 Alan Plum <[hidden email]> 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.
--
http://mail.python.org/mailman/listinfo/python-list