views:

630

answers:

4

Is it possible to make a mmorpg for the iPhone using PHP and MySQL(1,000+ players)? I was thinking of using MySQL to store all of the player information (name,username,pass,location,position). Then I would make that data accessible through php(pass a location to the php page and it returns all the player info for that area). Would PHP and MySQL be fast enough for something like that? If not, what would be some other solutions for the backend? Also, would a VPS (http://www.linode.com/) be fast enough or should I go with a dedicated server?

Thanks

+1  A: 

Well. Tough question since you - as justin points out - don't mention anything about how massive the game is.

However, my answer to your question is 'yes'. PHP and MySQL will definitely be capable of running such a system. The more relevant question is whether it is the right choice - and the answer to that question is most likely that is probably not the right choice.

MMORPGs are normally quite real-time, which would mean that each client will have several requests/second to your server. Even if you use keep-alive HTTP connections, etc. I am convinced that you'd get a better result using a non-HTTP based approach.

You could of course use PHP for serving requests and then format them with JSON or similar and have the client react on that data. I however would choose an entirely different programming language like C or similar, because of the latency requirements that MMORPGs have.

I am not a gaming expert or a C expert so these are just my humble concerns.

phidah
Ah, ok. I was thinking of using php to handle the data requests. I'm either going to go with JSON or XML.
iAlexTsang
A: 

I would say go for it. I've seen several MMOG powered by PHP/MySQL combo and they ran quite fast ( with 50 000+ active players). Though you should forget about using shared hosting (if you are even considering it) (at least when the game gets more than 1000 players).

Also you should consider using some caching techniques like APC and implement a memcached support in the db layer. It would help a lot.

It's even better if you could use dedicated servers for PHP(lighttpd), Database and static content(images, flash, etc) (nginx). This would distribute the load between machines and static content won't kill your MySQL because of IO concurency for example.

bisko
So a http://www.linode.com/ vps wouldn't be fast enough?
iAlexTsang
It's possible, but you should aim for the higher plans like 720 and up. You need lots of ram for MySQL and/or caching if you want performance.I would say run it on a shared hosting for a bit, to see how much resources does it use (check with your hosting provider if they can give you such stats) and then decide how much money would you want to spend on your VPS/dedicated and check the offers accordingly.
bisko
+1  A: 

Definetly go with PHP/MySQL, use something like eAccelerator to cache and optimize your code and host all of your static content on a CDN (Amazon S3 comes to mind) that should give you plenty of speed.

fire
+1  A: 

A lot about this, obviously, depends on your game. Could it work for 1,000 users? On one box? Probably not. On a small cluster? Maybe, if you keep it simple. Once it gets popular, however, you've made an investment in a very difficult platform to manage. You will have scale nightmares not unlike those that plague large websites, but more difficult because of the interactivity between users.

Even simple turn-based games (think Facebook & Myspace apps) have massive scale problems using LAMP back-ends... and they are nowhere near real-time.

MySQL simply isn't fast enough to handle the transaction load (for writes & replication). Hardly any database is. You'll need to keep your state in RAM, then batch your writes on schedule. This technique eventually hits a wall and then you will need to split your databases into completely isolated clusters.

Getting people to play against each other on isolated data islands gets difficult, unless you get VERY creative. This is a problem that memcached can't solve. You'll probably need to shard those as well.

Popular online games use custom streaming protocols on their back-ends. World of Warcraft simply couldn't exist if it were powered by PHP. You can't get two players to battle each other, if both players need to hit your website every second to retrieve updates. The lag, if movements are animated, would be jerky (at best). You need a two-way communication protocol.

I'd highly suggest looking into a distributed messaging platform. Perhaps even a language that's built for parallelization & clustering, like Erlang.

Pestilence