开发者

PHP + MySQL iPhone MMORPG [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 9 years ago.

Is it possible to make a mmorpg for the iPhone using PHP and MySQL(1,000+ players)? I was thinking of using MySQ开发者_StackOverflowL 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


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.


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜