How to start up multi-instance on one server machine

Hi there

I am now using docker-composer to run Nakama, but if I want to run more than one instance on one machine what do I do?
So basically what I want is port 7350 is one database with storage and leaderboard, and port 7360 is another database with another storage and another leaderboard.

Thanks for helping

Hi @JasonXuDeveloper :wave:

What’s the reason you want to split up the execution like that across the Nakama nodes? And why would you want to solve this on top of docker-compose?

So there are too many players in my game, the reason why I want to split my datas into muliple database is it will become more friendly to new players as they won’t see the large scary scores that they won’t be able to reach.
I am now running my server via docker-composer, so is there a way running to instance on one docker container or any other ways?
Thanks for helping!

I think you’re solving the problem in the wrong way. You don’t want to restrict the ability for players to play together.

You should implement a cohorts system for your leaderboards or create multiple leaderboards that you can shard your player base into (probably via a content hash over the player ID). Trying to split things up at the infrastructure level seems like the wrong approach to me. What do you think?

So you mean spliting players into different leaderboards base on their created time?
Its gonna work perfectly I guess!

Btw I have a new question:
If a player changed its Username, how can the player change its name displayed on leaderboard as well. When I changed my player’s username, the name on leaderboard is still the old one.

@JasonXuDeveloper We cache usernames in leaderboard records for performance reasons.

If you really want to have player’s usernames updated and the leaderboard is set to best score operator. You could write a leaderboard record update with a score of zero which won’t replace the score but would update their username.

My leaderboard operator is now set to “set” mode because my leaderboard requires latest score.
So you mean if I send a leaderboard update request as score of 0, the username will change?

Yes but with the “set” operator it will overwrite the score to the last one achieved which would be zero for this leaderboard. You shouldn’t use this approach for that leaderboard. I would suggest you just leave it for the usernames because the next score submitted by the player will update their username anyway.

Thanks, I will try.
Because when I changed player’s name and resubmit the score, score changed but username did not change.

@JasonXuDeveloper What version of Nakama do you use? You should remember that session tokens cache the username field into the token (for performance reasons) so if you really want to propagate the change of username fastest you should use a small RPC function to refresh your session token.

I am now using Nakama 2.9.1 in Unity 3d.
So after player change their names I should recreate a session for them in my code?

@JasonXuDeveloper We added the username updates in leaderboard records in the v2.10.0 release of the server. You can keep an eye on the release notes here:

Thanks for helping!

Just found that I installed nakama twice: one from docker and one manual install, the docker one version is 2.9, but the one I installed manually is 2.11.1, so I have to pull new version of nakama on my docker, thanks again!

1 Like