Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Network game - when is server overburdened?

Posted on 2014-03-16
12
366 Views
Last Modified: 2014-04-02
Hi,

For my network game - RTS - my clients are joining the server, and the server is instantiating a serverClient object to handle all the dealings with that client.

Is that correct?
the serverClient class will have its own Socket to gather communication from that client? Won't that blow the server's mind out? with that many sockets for a bigger game on top of the server's own socket?

And those serverClients update a gameState state representation?
Do I update the gameState clock every time a server cycle concludes (i.e. every client has sent a packet for that frame?) and the game state updates after every cycle, also.

I suppose RTS servers never get overburdened.
Thanks
0
Comment
Question by:beavoid
  • 6
  • 6
12 Comments
 
LVL 27

Assisted Solution

by:dpearson
dpearson earned 500 total points
ID: 39933334
the serverClient class will have its own Socket to gather communication from that client?

Yes that's fine.  I work on the server side of a game and we run up to 2,000 players per server and each has two sockets open.  Your mileage will vary depending on how efficient your code is and how complex the game, but it's certainly possible.

Do I update the gameState clock every time a server cycle concludes (i.e. every client has sent a packet for that frame?) and the game state updates after every cycle, also.
I would expect that you'd update the gameState each time you received an update message from a client.  That should be a lot less that every clock time - you should only need a message from a client when the user takes an action - e.g. asking to build a unit or direct a unit to move to a new location.  You should not need any messaging while the unit is making that move.

Hope that helps,

Doug
0
 

Author Comment

by:beavoid
ID: 39934713
Doug, thanks

You say each player has 2 sockets open for2000 players?
I shouldn't even be bothered by my sockets being complex!

What I did last time, and it worked, is each client sends a packet for each frame, to maintain connectivity. - and, why not? - even if it is a done-nothing frame. If I only send a packet for when an action is taken, then what happens during down-time / no activity ? How do I know when to increment the server cycleClock?.
Before, I'd increment the cycle clock and cycle, when each client sends an update, action taken, or done-nothing. Must I assume that if no packet arrives in 500 milliseconds, that that client did nothing? What about disconnects?
0
 
LVL 27

Assisted Solution

by:dpearson
dpearson earned 500 total points
ID: 39938906
Must I assume that if no packet arrives in 500 milliseconds, that that client did nothing?
Yes the server's update cycle should be clock based.  Indeed if you think about it for a bit it has to be.

What if you had 100 clients and one of them has a terrible network connection.  Packets are being dropped left and right and it's taking 3 seconds for them to send you one packet.  Does your server now only update at one frame per 3 seconds?  That would be a horrible experience because you're taking the slowest performing connection and running the game at that speed.

A much better model is the server just updates every 500ms (or whatever) and processes all messages received by then.  In the above case 99 players play on just fine and the 1 player with the terrible connection only gets to take one action every 6 frames - they're experiencing "lag" in the game and their game play experience sucks.  But it was going to suck anyway with such a bad network connection.

What about disconnects?
This model supports disconnects well, because a client will stop sending data for a while (in a disconnect) and then eventually the socket times out and is disconnected.  You certainly don't want the server to pause waiting to see if the socket times out or not.  The server just keeps updating every 500ms, while the socket is slowly timing out.

Doug
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:beavoid
ID: 39948169
Thanks

Just what I wanted to hear! Does Blizzard now do their servers on their machines? Or still - one of the players? How about age of empires?
0
 
LVL 27

Expert Comment

by:dpearson
ID: 39948209
I don't know about specific games, but these days most multiplayer games are client-server instead of peer-to-peer.  Better security, harder to hack.
0
 

Author Comment

by:beavoid
ID: 39949170
Hi Doug,

I'm curious, how is your dev setup done? 2000 clients . . . how do you run everything?

Do you sit at a machine coding the server, or the client? Another expert guessed you have 2000 other machines waiting to run a client. How do the other machines receive the new client code?

How do I initialize a compile / test

I'd like to code, run my server on my Macbook, code my client on PC next to it, and then start a process on my PC to run 2 or 3+ clients on other machines in the room
Can I work on the client code on my PC to be run around the room?

Thanks
0
 
LVL 27

Assisted Solution

by:dpearson
dpearson earned 500 total points
ID: 39952281
For us the client code runs in a browser - on the machine of the person playing the game.  But it's the same principle if they downloaded a client and ran it on a desktop computer directly.

For testing I generally run both client and server code on the same computer because it's easiest to deal with, but it's the same exact code when we move that to a production setup and the server is handling thousands of users at once.  But we also have it setup that the server code is deployed to an actual server (i.e. a remote box - you could easily use Amazon's EC2 for this) and then multiple people can connect to it using their browsers to test the multiplayer aspects.

I'd like to code, run my server on my Macbook, code my client on PC next to it, and then start a process on my PC to run 2 or 3+ clients on other machines in the room
Can I work on the client code on my PC to be run around the room?
Sure - why not?  You just need to be able to start up multiple client processes side by side on the PC and have them all connect to the Macbook.

Personally I'd suggest having a cheat/test mode where the clients do something reasonable - e.g.  walk around the map, shooting at stuff they can see - without you having to direct them.  That way as soon as you start up the 3 clients, you have a game which you can run for 15 minutes without pressing any keys.

That makes it much simpler to test and reproduce any bugs you need to solve.

Doug
0
 

Author Comment

by:beavoid
ID: 39952381
Thanks

When I did my first RTS effort for AI class, in Microsoft J++, it didn't care if I had 3 clients flying UDP everywhere, with a server flying them, too. ON THE SAME MACHINE !

Why wont I have a similar problem with Web Start?
Are you saying the webstart plugin will run my project on the same machine as my server with no problems? How many clients can I make? My client will need probably just an 800x800 window for simple JFrame testing, at first.
I'll do circle moving to start off!
Thanks
0
 
LVL 27

Expert Comment

by:dpearson
ID: 39952417
How many clients can I make?
That depends on how efficient your client code is.  If it's a relatively simple display you should have no problem running 3 or 4 clients on the same machine as the server.  With no display you might be able to run 50 or 100 clients.

It all depends on the code you write though :)

Good luck.
0
 

Author Comment

by:beavoid
ID: 39953817
Of course,
Thanks
Right now, I am doing no display yet, just a client engine.
How many DatagramSockets should my server itself have? Did someone say 2 per client?

I have one for joining clients, in a join phase,
and then I use that same socket to act as a game phase packet collector.
Maybe the game phase collector doesn't appreciate many clients sending packets simultaneously to it? Does the server have a socket for each client? Why 2 per client?
Do I make a clientHandler Class in the server that deals only with one client, and updates the game state at the end of a cycle - and sends the new state to the client?

Thanks
0
 
LVL 27

Accepted Solution

by:
dpearson earned 500 total points
ID: 39960836
You generally just need 1 socket per client and yes the server will have 1 socket per client as well.
0
 

Author Closing Comment

by:beavoid
ID: 39973086
Thanks

I hope my next question is, how will hackers hack this pre-Beta server!
But wait, that isn't a question, if my server is on its own.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
login jsp example 24 65
Running JavaFX on JDeveloper 12C 1 54
printf performancy 11 68
storing csv file in table variable in Python 2 24
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question