I want to write a server for a browser-based MMO game, which uses WebSocket for communication, SQL Server for database, and the language of choice for server is Python. What I would like to know is which libraries can provide Websocket and MMO support, and should I use Stackless or PyPy?
ws4py is a websocket library for python 2.6 and 2.7, and this is the customized django-websocket applied for rfc6455. Websocket became RFC6455 in the end of last year, so you should use libraries applied for it. These both libraries are supporting it.
ps Tornado is also supporting RFC6455 from version2.2.
Take a look at Tornado. It should contain all the stuff you need.
Tornado is definitely a good choice for what you are doing. It supports web sockets with the latest version and it works fine with PyPy if you are concerned about performance. I already have a prototype MMO working with this set up and it works great. Also you can add new connection types later. So you could start with web sockets, but if you ported the game client to a mobile device you can add a TCP handler into the game with minimal effort.
On the database side, I would consider looking around at other options. Maybe SQL Server is perfect for your needs, but I am more inclined to use something like Membase (renamed Couchbase recently) if you can do without the database being relational. Only because it scales well and seems to be very efficient on cloud hardware.
Good luck with your endeavour.
Related
I am developing my web app with Python 2.7 + Bottle. Everything is great and python is an amazing language coming from ASP.NET. I am building a web application that needs to use real-time client/server communication and socket.io for node.js comes to mind.
I wanted to know how can I implement socket.io-like using Python + bottle. I've read this article on bottle, but I can't still seem to understand how it works - what I need to install, and how all works out (code examples?).
I really need that for my next web application but need help in understanding what I need to put in my project in order for it to work. I have no problem working with 'preview' codes which aren't stable release yet. I'm developing on Windows platform. Thanks.
I also want to know if its scalabe. whether I can use redis in the back so all calls will be sync when running my website on several servers, so when one client send data, all the other clients connected to the other servers will get it to.
maybe websocket can help you,many modern browser support this protocol,but bottle.py don't support it now,you can get some idea from tornado.websocket and some answer here
cause every connection can be saved,so i guess it can run on several servers,but i never implement.
since bottle is micro framework,you should do something by yourself.
I have a python program that I would like to present as a simple web application. The program currently uses sqlite for storage. I also need to distribute the whole thing to colleagues so having something standalone and easy to start would be ideal ( no install if possible). This web app is meant to be used locally , not by multiple users over a network.
Is there a suitable python framework that might fit my needs? I looked at Django so far but it seems a bit heavy handed for what I need.
Thanks for any suggestions.
I have never tried it myself, but you could try Bottle:
Bottle is a fast, simple and lightweight WSGI micro web-framework for
Python. It is distributed as a single file module and has no
dependencies other than the Python Standard Library.
try http://docs.python.org/library/simplehttpserver.html
As web frameworks are not part of the standard lib, you will have to install something in every case. I would propse to look at http://flask.pocoo.org/. It has a build in WSGI server.
Lots of choices for Python web frameworks! Another is web2py which is designed to work out of the box and allows, but doesn't require, through-the-web development. It is mature and has a strong community and is well-documented.
Tornado as a framework may be a lot more than what you're looking for. However it will meet the requirement of being a completely python based web server. http://tornadoweb.org
I generally just download the source, drop it in /tornado/ of my project and do includes there from the app.
I don't think that any web framework is specifically oriented for the use case you're talking about; They all assume they are running on a server and there's a browser on a remote machine that is accessing them.
A better approach is to think about the HTTP server you'll be using. It's probably preferable to use a server that's as easy to pack and ship as the rest of the python code you'll be using. Now most frameworks provide a 'development' server that's easy to invoke from the command line, but most of them are intended to be "easy for the developer" which often means they are restricted to a single thread. This is bad for deployment because single threaded servers will always feel a bit sluggish.
CherryPy stands out in contrast, by providing a full featured, embedded server that's easy to configure for many use cases, and is available by default with the rest of the framework. There are probably others, but I haven't used 'em.
I'm a complete novice in this area, so please excuse my ignorance.
I have three questions:
What's the best (fastest, easiest, headache-free) way of hosting a python program online?
I'm currently looking at Google App Engine and Web Frameworks for Python, but all the options are a bit overwhelming.
Which gui/viz libraries will transfer to a web app environment without problems?
I'm willing to sacrifice some performance for the sake of simplicity.
(Google App Engine can't do C libraries, so this is causing a dilemma.)
Where can I learn more about running a program locally vs. having a program continuously run on a server and taking requests from multiple users?
Currently I have a working Python program that only uses standard Python libraries. It currently uses around 2.7gb of ram, but as I increase my dataset, I'm predicting it will use closer to 6gb. I can run it on my personal machine, and everything is just peachy. I'd like to continue developing on the front end on my home machine and implement the web app later.
Here is a relevant, previous post of mine.
Depending on your knowledge with server administration, you should consider a dedicated server. I was doing running some custom Python modules with Numpy, Scipy, Pandas, etc. on some data on a shared server with Godaddy. One program I wrote took 120 seconds to complete. Recently we switched to a dedicated server and it now takes 2 seconds. The shared environment used CGI to run Python and I installed mod_python on the dedicated server.
Using a dedicated server allows COMPLETE control (including root access) to the server which allows the compilation and/or installation of anything. It is a bit pricy but if you're making money with your stuff it might be worth it.
Another option would be to use something like http://www.dyndns.com/ where you can host a domain on your own machine.
So with that said, perhaps some answers:
It depends on your requirements. ~4gb of RAM might require a dedicated server. What you are asking is not necessarily an easy task so don't be afraid to get your hands dirty.
Not sure what you mean here.
A server is just a computer that responds to requests. On the dedicated server (I keep mentioning) you are operating in a Unix (or Windows) environment just like you would locally. You use SOFTWARE (e.g. Apache web server) to serve client requests. My vote is mod_python.
It's a greater headache than a dedicated server, but it should be much closer to your needs to go with an Amazon EC2 instance.
http://aws.amazon.com/ec2/#instance
Their extra large instance should be more than large enough for what you need to do, and you only turn the instance on when you need it so you don't have the massive bill that you get with a dedicated server that's the same size.
There are some nice javascript based visualization toolkits out there, so you can model your application to return raw (json) data and render that on the client.
I can mention d3.js http://mbostock.github.com/d3/ and the JavaScript InfoVis Toolkit http://thejit.org/
I will soon start a new project with Amazon Web Services, on Linux
They have frameworks available for PHP, Ruby, Python, Java and .Net
http://aws.amazon.com/ruby/
http://aws.amazon.com/python/
I am fluent in PHP and Java, I hate .Net
The project is to have a lot (around 50) Amazon instances connect to a central pile (or decentralized, not sure yet) to have jobs to do, with auto-scaling and such.
This implies there will be a lot of database and communication between the instances.
Also, a lot of the job will be Web related like using another Web service, crawling a website, etc. So I need good JSON/XML support and stuff like SOAP would be nice.
I did all that in PHP once using SQLite and going through Apache, but since we are moving to Amazon, we now have granular control of each node with the command-line and everything, I feel it would be way better with a PostgreSQL database and daemons in Ruby/Python.
What do you think?
MySQL or PostgreSQL?
Rewrite everything that was done in PHP to make better daemons in Ruby or Python?
If not, I will simply convert a lot of the code to use the CLI instead of going through Apache.
I am very open to other suggestions
Thank you a lot
If you have no pressing need for a rewrite, just use your existing codebase. Maybe refactor some things step by step, to see if Ruby, Python or Java suit well for particular problems. Python for example is a perfect glue language, also good for crawling and has native json support since 2.6.
I am developing a twisted server. I need to control the memory usage. It is not a good idea to modify code, insert some memory logging command and restart the server. I think it is better to use a "remote console", so that I can type heapy command and see the response from the server directly. All I need is a remote console, I can build one by myself, but I don't like to rebuild a wheel. My question is: is there already any remote console for twisted?
Thanks.
twisted.manhole.telnet uses the deprecated module twisted.protocols.telnet. It is recommended to use twisted.conch.manhole instead.
Here are some tutorials of how to use it:
Writing a client with Twisted.Conch -- twisted.conch documentation
Network programming with the Twisted framework, Part 4 -- IBM developerWorks
Twisted Network Programming Essentials - Chapter 10 -- Online book preview
Take a look at twisted.manhole