Search Unity

Help Wanted Beginner question about accessing stats on headless server build on a VPS

Discussion in 'Multiplayer' started by aivo, Jan 12, 2021.

  1. aivo

    aivo

    Joined:
    Feb 13, 2017
    Posts:
    29
    Hello

    We're setting up a super simple multiplayer game (with a maximum of 10 players) whereas we have got the basic tech working in LAN environment (multiple clients connecting to a server using MLAPI).

    Now we would like to make the game available to play over the internet (just one world).
    My idea was to rent a VPS (something like this) where a headless server build would be running.

    Now I'm wondering:
    Since the server build would be headless, how would I access statistics (like how many players are connected, game states, etc.)? Using just the log would be quite cumbersome. Is this the reason why games use databases as backbones (e.g. mySQL)?

    thank you very much
     
  2. BetaMark

    BetaMark

    Joined:
    Sep 27, 2014
    Posts:
    119
    Its actually a great question if you've never worked with a remote server before.

    There are a handful of ways that people solve for this when architecting their systems.
    * write events (user connects to server, user connect to lobby, user starts match, user ends match, user times leaves server) to a file or DB with timestamps (to be able to do your stats after the fact
    * log stats to a file or DB periodically (every 60 seconds won't hurt server performance)
    * or use a third party SDK and data platform like google analytics / firebase to track those events, and let those tools present the statistics to you.

    Some people even go as far as to build an rcon style interface or JSON REST api on their dedicated server platform so that this information can be pulled in real time from a live server, but that's pretty far out there in terms of effort.

    What would you want to use those statistics for?
     
    luke-unity likes this.
  3. aivo

    aivo

    Joined:
    Feb 13, 2017
    Posts:
    29
    thank you @mccorkle

    your answer really helped as it kindof ensured me that I'm at least somewhat on the right path. To be honest I don't really need the statistics for anything, I guess it's just curiosity to see whether anybody actually connects to our game :)

    I guess for the moment I'll go with the file writing, maybee if time allows I'll set up a database.
     
    BetaMark likes this.
  4. BetaMark

    BetaMark

    Joined:
    Sep 27, 2014
    Posts:
    119
    Yeah, the easiest answer is to just log every connection and major "game loop" event to the server in a log file, and then you can just download that log file and run through it any way you want.

    At my day job, I run through log files all the time, so if you need some examples of how to do write a good log file and then to do reports, feel free to ask at any point.
     
  5. GamerGraph

    GamerGraph

    Joined:
    Dec 10, 2020
    Posts:
    16
    Hi @aivo - not to go straight into pitch mode, but our tool was built to handle the issue you're solving for. GamerGraph is a cloud platform that delivers game analytics and social mechanics. We provide an API that developers can use directly, or through one of our plugins (Unity 3D, Unreal). We provide standard reports, or you can customize your own. Standard ones include:
    - monthly active users
    - daily active users
    - user churn
    - engagement/stickiness

    With the same API, you can also configure and enable social functionality like:
    - invite a friend
    - initiate a challenge
    - leaderboards

    We keep it simple...no server or any backend configuration or management needed. 2 minutes to set it up. Let me know if you want to check it out (you can sign up for free on our website) and I'll set up as much time as you need to help you out - https://gamergraph.io/
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,736
    Use ample logging for information that is appropriate. "tail -F" is very useful to watching logs in real time. I like to put game state logging into a separate log file, to keep it separate from the regular unity player log. For live stats, you can actually have the server sync that information to the clients, then any client can see it. If you're using a network architecture with a master server, you could have a specific client build that talks to the master server to get this information.

    For example, in my game it is structured with a master server, several supporting servers, and then many zone servers which actually run the game simulation. I have a special scene I call the command console which I don't include in any of the other builds. What it does is connect to the master server and sends commands to the server cluster and queries information. The master server talks to all the other servers, so can query any needed info from them, or talk to the database, then send the response to the command console client.
     
unityunity