Advertisement

Multiplayer Matchmaking, is this a good system?

Started by May 23, 2014 09:36 PM
3 comments, last by hplus0603 10 years, 5 months ago

So basically I have a design for attempting to do multiplayer matchmaking.

Essentially what it is, is the ability for people to host their own games, without the need of:

- Dedicated hosting (the server)

- Port forwarding (TCP and UDP)

First off, do you think matchmaking is better or worse for people who wish to play your multiplayer game?

By that I mean, will it drive people away or closer to playing your game? Will your game be more popular if you offer

matchmaking or more popular if you allow people to host their own servers?

Anyways, my design for matchmaking is that everyone connects to one server of which I host (or have dedicated hosting somewhere else, none the less same thing).

When a player wishes to "host" a game, a message is sent to the server and the server will create an instance of a class known as "Match".

Match will hold all the information necessary for a game match,

- Instances of incoming players (player names, keypress/keyreleases, positions, score, etc.)

- Who the host is

- The scores of the players

- What's currently happening in the game

- Solid blocks

With that said, Match will be doing a lot of work.

For example, in this game, there are multiple rooms to the world.

Each room has its own list of solid blocks for the server to do collision checks.

The reason for this is, it needs the information about the map, because the client also has this information.

The clients are basically a dummy. The only thing they do is send keypress/keyreleases, and the server will update the position

of the players, and check collisions. The server then sends keypress/keyreleases back to everyone (including the player), as well as the new positions of the player, and the clients will update the position/move the player/stop moving the player accordingly.

This way, the clients have no way of modifying their position for their advantage.

Anyways, like I said the Match class does a lot of work. Because the server checks for collisions on its side as well, the server

must contain:

- A list of all the rooms

- For each room, a list of solid blocks and their positions

With that said, there would be multiple Match instances. Depending on how popular the game is, there could be as few as 10 or even 30 to 40 Match instances.

That's 10-40 threads, or maybe 2 threads for each Match. One thread would be for game logic (updating player positions, collisions), and the other thread would be for networking logic (what to do for incoming messages).

All of that plus the main server thread that listens for incoming messages (TCP and UDP).

Is this efficient for a small server computer to do?

Or would it just be better to let players host their own servers?

What do you guys think? Am I overcomplicating it?

A few things --

You can't just send keypresses -- its wasteful at best, and a huge target for denial-of-service attacks at worst. The client has an understanding of the game world -- it takes input from the player and if the client believes the input is a valid move, it sends some state to the server, but not "I pressed left" or "I just moved here", more like "I want to move here" -- but in the mean time, the client goes ahead and does it. The server then takes that message and determines if its valid based on the server's own understanding of the game world. Based on that, it knows what the player state should be, and it sends it back to the player, and to other players, and each client reconciles it with their local understanding of the game world. Keypresses are insufficient to convey this.

Secondly, I would have one match per program instance. The question of how many matches to run per physical server is a separate concern, and also its possible, if not likely, that each match might have a different world or world-state, so keeping track of all that in one monolithic program is more work than it ought to be doing. To scale up the number of matches hosted on a physical server, just spawn more instances of the server program and attach them to a different port, possibly putting them behind some kind of lobby or load-balancer. If there's multiple, possibly-conflicting configurations, spawning a bunch of executables side-by-side might be problematic, but there are great solutions for this today, like Docker allows you to create, manage, and run multiple independent execution environments on one machine without resorting to VMs. Docker runs on Linux and is also available in MacOS X, I believe.

throw table_exception("(? ???)? ? ???");

Advertisement

I'm a bit confused on how else you would send movement without sending keypresses?

How else would the server know that a player is moving to the left, if you don't tell it that you pressed the left key?

How is this wasteful?

Also, are you saying that having multiple instances of Match in one process, is probably not a good idea, and its better to have a separate process

for each Match? You also said that when you have multiple processes of the Server, you need a new port.

Wouldn't you need to port forward for every single new server instance?

Let's say you port forward 12345 TCP, 123456 UDP.

Now a new server instance is created, you need to port forward two new ports, but how would you do this when you would need to manually go to the router settings and port forward?

Or are you saying, have a preset range of ports to be forwarded?

Which is kind of strange because you won't know how many Matches there would be depending on the popularity of the game.

You would be limited based on how large of a range of ports you want to forward.

It makes more sense for their to be a master server that handles all the network communication on two main ports (TCP and UDP), and the information is relayed to the Match instances and the Match instances can send information back to the master server and have the master server send out data.

The master server in other words would be in charge of networking, and the Matches would retrieve the network data from the server, and send it back to the server to be sent out to the designated clients.


How else would the server know that a player is moving to the left, if you don't tell it that you pressed the left key?

You tell it that you've moved left. Or you tell it where you've moved to.

Ideally, the precise detail of how the input was entered (eg. via a keyboard) is all handled by the client. The server just needs to be told about intent, ie. movement.

I personally like to operate by sending the desired new position to the server, which can then accept it or veto it accordingly based on information about the player's previous position, velocity, and capabilities. This seems adequate for most games, though it is unlikely to be sufficient for shooters.

Is your proposal that you build a service that runs matchmaking AND game servers for a game, and the developer focuses on the client?

There have been other such projects built, sometimes by large, well-funded teams, and almost none of them are still around.

I don't think the business model is there to support such a service.

The closest I know that still works is either matchmaking/social systems like SteamWorks, or service-based systems like Parse and Gamedonia.

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement