Sign in to follow this  
Butabee

PHP Master server

Recommended Posts

Butabee    274
I want to make a game with one master server that takes care of things like determining what player attacked what mob or player, and pretty much all other authoritive things except for player positioning. It would also handle database interaction. I want this to be done in PHP.

Along with this, I want to have player hosted world servers that pretty much just handle the physics.


My main question is, how capable is PHP? How many players could a PHP server handle?


Also, how could I prevent players from flying if I get positions from the player servers? And how could I control their speed when there'd be different speed situations... such as mounts and vehicles.

Share this post


Link to post
Share on other sites
rip-off    10976
It depends on what your requirements are. Is this a fast paced action game, a slow turn based game or something in between? Do you expect lots of players to cluster together or will they be mostly separated? PHP isn't fantastically quick, but if your game is I/O bound this wouldn't matter.

[quote]
Also, how could I prevent players from flying if I get positions from the player servers? And how could I control their speed when there'd be different speed situations... such as mounts and vehicles.
[/quote]
The only way is to do these checks on your server. You could do them retroactively, maybe when a player is trying to move between servers. The "client" server could upload a path history to the master server, which could run through the path looking for collision violations and places where the player moves faster than their current mode of transport allows.

Share this post


Link to post
Share on other sites
Antheus    2409
[quote name='Butabee' timestamp='1306697317' post='4817212']

My main question is, how capable is PHP? How many players could a PHP server handle?[/quote]

[url="http://highscalability.com/blog/2010/3/10/how-farmville-scales-the-follow-up.html"]75 million[/url].

Share this post


Link to post
Share on other sites
Butabee    274
I'm thinking I'd limit the individual servers to about 100 players, so that's the max that could be interacting at any one time. It's going to be an action type game.

I don't think I can have set pathing because the environments are going to be dynamic. I guess I could let players get away with flying and a few other minuscule hacks on their own servers, or maybe I'll check and ban them or something. The main thing I don't want happening is players being invincible or hitting for a million damage and stuff.


I might just write the server in c++ because I was thinking I could use some cheap shared hosting with a php server but after checking it out, I don't think anyone will let me open sockets besides dedicated hosting.


I guess I'll have to run the server from home or something until I can afford dedicated hosting.

Share this post


Link to post
Share on other sites
Butabee    274
[quote name='Antheus' timestamp='1306700659' post='4817230']
[quote name='Butabee' timestamp='1306697317' post='4817212']
My main question is, how capable is PHP? How many players could a PHP server handle?[/quote]

[url="http://highscalability.com/blog/2010/3/10/how-farmville-scales-the-follow-up.html"]75 million[/url].
[/quote]

That's not all on one machine though right? From what I understand that's load balanced between multiple machines.

Share this post


Link to post
Share on other sites
hplus0603    11347
[quote name='Butabee' timestamp='1306697317' post='4817212']
My main question is, how capable is PHP? How many players could a PHP server handle?
[/quote]

How many requests per second do the players make, and how much is needed from your system per request? PHP is just a language. Your question is no different from the question "how many players could an assembly server handle" or "how many players could a C++ server handle" or "how many players could a JavaScript server handle."

If your game is actually interactive, with physics data being sent to different players, PHP is *not* the technology you want to use, though. Even if you can live with TCP for the state stream (and, if it's an interactive physics game, you probably can't), you cannot live with the overhead of forking one copy of the environment per request (PHP garbage collection pretty much depends on this), nor the overhead in trying to get the data you need to send to each player, into each player's return value. This is pretty much the reason why persistent servers with non-transaction protocols exist.

Share this post


Link to post
Share on other sites
Butabee    274
[quote name='hplus0603' timestamp='1306705690' post='4817252']
[quote name='Butabee' timestamp='1306697317' post='4817212']
My main question is, how capable is PHP? How many players could a PHP server handle?
[/quote]

How many requests per second do the players make, and how much is needed from your system per request? PHP is just a language. Your question is no different from the question "how many players could an assembly server handle" or "how many players could a C++ server handle" or "how many players could a JavaScript server handle."

If your game is actually interactive, with physics data being sent to different players, PHP is *not* the technology you want to use, though. Even if you can live with TCP for the state stream (and, if it's an interactive physics game, you probably can't), you cannot live with the overhead of forking one copy of the environment per request (PHP garbage collection pretty much depends on this), nor the overhead in trying to get the data you need to send to each player, into each player's return value. This is pretty much the reason why persistent servers with non-transaction protocols exist.
[/quote]

I wouldn't be doing any environment or physics on the master server, but maybe some line box collision tests for attacks. It would pretty much relay player/NPC positions, and do the attack tests and interact with a database.

But anyways, I think I'm just gonna use c++.

I don't feel like making a new protocol so I'll just use eNet :)

Share this post


Link to post
Share on other sites
hplus0603    11347
[quote name='Butabee' timestamp='1306707274' post='4817260']
But anyways, I think I'm just gonna use c++.

I don't feel like making a new protocol so I'll just use eNet :)
[/quote]

Sounds like what most games end up doing :-)

If you want a productive language suited to writing online servers, you might also want to check out Node.js/JavaScript, or OTP/Erlang, or Twisted/Python.

Share this post


Link to post
Share on other sites
Butabee    274
Actually, how do you guys think unity would work for this project?

I think they support a master server, but I'm not sure exactly what can be done on it.


EDIT - nevermind, looks like their "master server" is nothing but a matchmaking server.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this