Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Massively Multiplayer Turn Based Game Performance : Server choice

Discussion in 'Multiplayer' started by akashif, Apr 23, 2018.

  1. akashif

    akashif

    Joined:
    Aug 25, 2016
    Posts:
    7
    Hi,


    I am in process of creating a multiplayer turn based game (unity3d), and expecting it to be very popular (imagining).

    I need to plan backend very carefully. So I am testing several servers which can handle several thousands clients.


    I have tested nodeJS with socket.io, but that seems not a good choice. (may be I am wrong).

    I have tested nodeJS load with “websocket-bench” and apparently nodeJS Socket.IO starts dying on 3000 connections and on 5000 connections totally dead, while server resources are free. I have a 16GB RAM DUAL XEON (sandybridge 24 CORE) ON CENTOS 7. Overall load of server never goes above 6 and only 3GB to 6GB memory is utilized.


    So I am not sure why nodeJS is not accepting more connections (I have set ulimit to 60,000).


    I am using websocket-bench like this


    websocket-bench -a 2000 -c 1000  [URL]http://localhost:3000/[/URL]





    and socket.io server is very simple.


    Code (JavaScript):
    1. // JavaScript Document
    2. var io = require('socket.io')(process.env.PORT || 3000);
    3. console.log('server started.');
    4. var _clients=0;
    5. io.on('connection', function (socket) {
    6.         _clients++;
    7.         console.log('Connections: '+_clients);
    8.  
    9.   socket.on('disconnect', function () {
    10.     io.emit('user disconnected');
    11.         _clients--;
    12.         console.log('Connections: '+_clients);
    13.  
    14.   });
    15.  
    16. });

    Considering this background, I have 2 questions,


    1) What wrong I am doing with my nodeJS setup. Am I missing something to get high very performance.


    2) For a massively played turn based game what server should I use?



    Thank You
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    What you're missing is massive multiplayer games typically run on a server cluster rather than a single server.
     
  3. Ellernate

    Ellernate

    Joined:
    Aug 25, 2017
    Posts:
    81
    Establishing a client connection on localhost is a lot different than handling incoming/outgoing data for 5000 users. Unless you have a team of networking gurus, I would look into load balancing
     
    Joe-Censored likes this.
  4. akashif

    akashif

    Joined:
    Aug 25, 2016
    Posts:
    7
    HI,


    @Joe-Censored, Thank you for pointing out, but I am not missing that, I do understand that I will defiantly plan to use cluster or load balancer. But cluster of what server nodeJS, uNet, ENET.. or REST APIs??.

    See, in my case what I can see that there are 3000 clients per serve before server starts dying. So assuming I want to have 100,000 clients (which is only 25,000 player playing a 4 player turn based game) I will need 34 server or say 30 Servers under load balancer or at-least 30 nodes in some cluster.

    I don’t think, but in games like “LUDO STAR"? where I am sure more than 100,000 users are playing game all the time (number for sure is more than 100,000, I am 101% sure), so this game is using some very BIG cluster with 100+ nodes.? That is not feasible. Now what I am missing here?


    @Ellernate, Thank you as well for pointing out localhost load testing, I do understand that as well. I am running test on localhost to avoid network latency and all other network related issue to measure the performance of server (hardware) and nodejs (socket.io)

    Just to add more, I have performed similar tests from LAN and from WAN as well. And results are similar. (If I ignore the WAN / LAN latency).

    Similar to my reply to @Joe-Censored , yes definable load balancing / clustering is need but on what server technology . NodeJS does not seems to be a better choice for that. Although I am plaining to test https://socketcluster.io

    Infect my question should be how I should architect my “Four player turn based game“ to support 100,000+ users, with reasonable hardware load balancing. should I keep always my clients connected like I am doing now with node socket.io. or I should create REST services and players should periodically check the data online and take turns (This options seems not a good idea to me.. but I am not sure.) . and most importantly what server should I use. Like I am also investigating https://github.com/nxrighthere/BenchmarkNet/wiki/Benchmark-Results


    So please suggest.

    Thank You

    Ali
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You haven't even said what service your server is going to be providing for your game. You originally said "massively multiplayer" which would mean you're building an MMO (which is what the MM in MMO stands for), but now you're saying you are making a 4 player game.... So what is this server even doing?

    Just make your 4 player game where one of the players hosts the match. You could set your own match maker server, but you only need to maintain connections to clients that are waiting for a match. They don't need to stay connected while playing the game. Or you could use one of the available cloud services for this, like Photon.
     
  6. akashif

    akashif

    Joined:
    Aug 25, 2016
    Posts:
    7
    @Joe-Censored, I am extremely sorry that I could not put my points clearly. In my first post I mentioned, “Multiplayer turn based game”, and I assumed that I made myself clear, but I was totally wrong. Let me fix my mistake now.


    I am planning a Multiplayer Mobile Game, targeting IOS and Android. It is going to be a 4 players card game. Users will be using social media logins and will be able to play with their online friends and with any other online guest.


    I assumed that I will be in need of a server where all my clients will be connected and server will be transmitting messages to clients. E.g. server receives a request to create a match and it finds 3 more waiting users and creates a match for them. All clients will send messages to server and server transmit that to other player.


    But from your last message I understood that I am thing in a wrong way. And I am confused how players will communicate with each other. I mean if a user hosts a game that is behind a firewall and there is NAT involved. Unless there is some tunnel/socket created how messages will be passed to each other, more over shouldn’t there be a stun (and or) turn server involved.


    OR I am thinking too much and in a wrong way.


    I am in desperate need of advice that what things I need to read for this? I need to understand concepts.


    Thank You

    Ali
     
  7. DBarlok

    DBarlok

    Joined:
    Apr 24, 2013
    Posts:
    265
    If Battlefield 1942 supported 64 players 15 years ago in 1 server (still supports it, it is not dead xd) , a card game can resist 64.000 players in 1 server? Besides this calculations, 34 servers it is a pot of money, right? And in the end, i think you will need Autorithative servers (sorry my english) or the game will be easy to hack. Look for NoBugs It.hara book about MMO, good reading.
     
  8. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    154
    What does it mean that it is totally dead? The nodeJS process dies? On a 24-cores hardware you'd expect a bit more than 5K users! For a turn based game you should be able to handle at least 20K+ players without breaking a sweat.
    I have worked mostly in C# and Java, so I don't know about nodeJS. I have made my own C# based game server before moving to SmartFoxServer a few years ago.

    Even a homebrew server in C# can handle a couple thousands players on a lowly EC2 instance (t2/t3 micro). In a similar fashion with SmartFoxServer I've run well over 3K players on a budget (2-cores) cloud server.
    Maybe you should look into these kind of solutions, though I would not recommend making your own server, it's just too much of a hassle.

    Or what @Joe-Censored suggested, match making server plus p2p gameplay, if cheating is not an issue.