Running multiple instances of Nakama in the same server

Hi!

We are evaluating Nakama as our gaming server solution in the company I’m working.
One question that was raised during the discussion, is if we can run multiple Nakama instances on the same server.

To add some context, my company works with a lot of small and medium-sized games, and reducing costs is always a priority, that is the reason we want to put several games on the same machine.
If a game is very successful, we allocate more resources to that specific game.
We also have an IT team, so we were planning to deploy and balance the servers by ourselves.

I’m a developer, and I’m not an infrastructure expert, but I wanted to bring better information regarding this topic to our next meeting.

Thnk you in advance for your help.

1 Like

Hey Adrian!

It’ll be perfectly okay to run multiple instances of Nakama on the same server. A good approach would be to run one docker container per Nakama instance and then map a different host port to the container port for Nakama (say, 8080 to 7351). This way, you can have different games listening on different ports. Thereafter, you can use a reverse proxy like Nginx to distribute traffic based on the domain name to appropriate port.

Thx a lot for your quick and detailed response @thealphadollar.

I suppose there is a performance hit using docker containers rather than running Nakama natively, right?
If that is the case, then I suppose we need a machine per instance.

For most practical purposes, the performance of docker containers is close to native performance. So, I think it should be fine running multiple docker containers than running multiple Nakama instances separately on the same server (which is doable, just that the Nakama ports should be changed as one port can be used by only one application).

Ref: linux - What is the runtime performance cost of a Docker container? - Stack Overflow

Hi Adrian,

What @thealphadollar said is correct for development purposes. For production purposes, we strongly suggest that you deploy at least two instances of Nakama for the same game but on different hardwares to allow for (module) deployment + resiliency. You can then host multiple Nakama instances (for different games) on the same underlying node.

You should also consider how hardware resources should (evenly?) distributed against those instances to avoid noisy neighbour issues.

1 Like

It is true noisy neighbors can be an issue, a bug, or a bad practice (like expensive cron operations) in one game and can affect others if they share the same node, but in the beginning, everything will be very controlled and handled by our internal teams.

Thank you a lot, I think I have the info I wanted to prepare for the meeting.

1 Like

To avoid noisy neighbour, you can set resource limits on each game container inside the docker.

Ref: Runtime options with Memory, CPUs, and GPUs

Let me know how it goes and if you need further discussion.

Hi,
I have exactly the same situation (many small and mid-sized games I want to run on one server).
Maybe you can share how it’s going for you with such setup?