Backend/server for mobile turn-based multiplayer game?

I just found out about defold 2 days ago, haven’t even downloaded it yet but it seems the best IDE for my use case. I wanna build a mobile multiplayer turn-based card game that is as simple as poker, nothing fancy, and I’ts played 2v2 and 1v1. I’d like to have the option for at least 50-100 concurrent games at launch, each game having either 2v2 or 1v1 players. Also, I’d like to implement ranked matchmaking as well as casual, and the ability for people on iOS to play with those on Android.
I have never touched networking for games and I need some guidance.
The game itself is really easy to code, that’s why i wanna work out the networking first… I’m gonna use defold 100% but can’t seem to find a good answers on backend/server/networking technology.

Now that you have context I’ll shoot a few questions:

  • Since I’m a broke student all I could spend after launching the game is like 35$/month. Is that enough to have at least 50-100 concurrent games to be active? Is there anything that comes even close in this price range?
  • Can I use a random server provider but also use service like nakama to simplify the networking part.
  • For my use case what networking technologies would you suggest i use? Remember I wanna make ranked matchmaking along with casual, also in 1v1 and 2v2 modes.

Thank you for your time, and sorry for bad english.

1 Like

You mention Nakama and it is an excellent choice (an alternative would be Colyseus). You can definitely create what you describe using Nakama.

You should start by running the server on your local machine while developing the game. There’s no need to start paying for any kind of server hosting from the beginning. Setup for Nakama here:

https://heroiclabs.com/docs/nakama-download/

Once you need a server you can start small and use something like DigitalOcean or Heroku. Maybe @novabyte has some additional recommendations?

3 Likes

Thank you Britzl for answering quickly. Could you spare a little bit more of your time and tell me if it’s possible to have 50-100 concurrent games (like 300 ccu) while paying roughly 35$/month server service, with no other costs? My total monthly budget is about 30-50$. Or to rephrase: How many ccu-s could I get while paying 35$/month? That is the key part since money is my bottleneck lol. Also, would you suggest Nakama or Colyseus for my use case? Thanks!

This does heavily depend on the amount of data you generate per second. Seeing as you mention a card game and not a first person shooter I would imagine that the amount of data is really small. 300 users making at most 1 move per second. That really isn’t much.

But I can’t answer for sure if $35/month is enough. My guess is that it is.

But if I were you I wouldn’t worry about the number of users. Unless you have a lot of users lined up to play your game you’d be lucky to have 300 concurrent users playing your game when you launch it.

Both would work well. Since it is a card game I assume you want authoritative multiplayer (the server has the entire game state and decides the outcome of every move). This means you will have custom game logic running on the server and you need to write that game logic yourself.

Nakama supports Lua and Go: https://heroiclabs.com/docs/gameplay-multiplayer-server-multiplayer/
Colyseus supports JavaScript and TypeScript: https://docs.colyseus.io/server/api/

So the question is which language you prefer? One advantage with Nakama is that it uses Lua, the same language you use in Defold. This can be really useful since you could potentially share code between the client/game and the server.

5 Likes

Alright man, thanks a bunch. I will use Nakama, because it seems well documented, with many premade operations, also it seems easier to learn(even tho I’m familiar with JS).

To sum this all I need is : Defold with Nakama running on some Server(with the possible addition of
small plugins/services). One last question: While using these technologies will I have any extra costs besides the monthly server fee?

P.S. Sorry to bother this much but one more question: How hard will it be, with Nakama, to implement functionality that makes players reconnect to a game if they lost connection while playing?

1 Like

If the lag from different regions are not very important(for example you can target central eu and you can set your server at Germany) and the server load is predictable (like you said 300ccu) then you can use VMs like Linode. I believe 8 GB ram and 4 cores enough for your case. You can start from lower settings and when needed you can upgrade.
But as I said’ this is a regional solution also you have to setup and optimize nakama server by yourself. If you are looking for a minimal lag solution for every region you have to spend more…

Note: There is a info for deploying on Digital Ocean: https://heroiclabs.com/docs/deployment-digital-ocean/

Last note: CockroachDB works well by using different nodes(servers) It is how it is designed for. So it is a expensive solution. But this is not a limitation. https://www.cockroachlabs.com/docs/stable/recommended-production-settings.html

1 Like

Thanks for pointing that out. The game will be played 99% of the time in the Balkan region. I’m making a local popular card game, so i doubt anyone outside of central eu will even find this game, let alone download and play it. I guess Linode or Digital Ocean might be right for me, just need to check out the Digital Ocean prices and how hard it is to deploy Nakama on Linode and then decide.
From what I’m seeing at their page, Linode looks legit. I was wondering about prices of all other solutions i checked out, but Linode seems pretty tranperent.

Almost the same as setting up local environment. I don’t recommend any Docker solutions for production.

Linode is great. I’m using it for my daily job everyday. Documentation is good and their support is professional. You can try for a month, If you dont like it you can shut it down.

2 Likes

Hey @TocnoSanZna :wave:, a few people have built and are building card games with Colyseus. You can deploy it on servers as low as $5/mo on DigitalOcean and serve up to 3k concurrent players - I’ve benchmarked that myself for a card-game I’ve worked on last year :slight_smile:

Feel free to join the Colyseus Discord to discuss anything you need regarding the server-side, there aren’t many Defold developers there, but you’re gonna be welcome! :rocket:

7 Likes

also it seems easier to learn(even tho I’m familiar with JS).

@TocnoSanZna Looks like I’m a little late to this discussion. I’m one of the engineers at Heroic. :slight_smile:

If you’re more comfortable with TypeScript or JavaScript instead of Lua or Go you’ll enjoy the Nakama 3.0 release. We’ve just added full support for code to be developed and run efficiently in Nakama with TypeScript/JavaScript. The official release is next week but there’s some documentation which is already available so have a look here:

https://heroiclabs.com/docs/runtime-code-typescript-setup/

I also think that Nakama is a great fit for your game especially if you use the authoritative multiplayer engine which has been mentioned. We’ve got a project template which will be open-sourced next week as well which shows how to write TicTacToe with multi-round gameplay and transient disconnect handling (good for mobile) in TypeScript or Go code.

https://github.com/heroiclabs/nakama-project-template

(I’ve shared the link but expect it to be reachable next week)

Hope this helps.

6 Likes

Hello @novabyte,

I’ve just checked out your site after reading your post. I was hoping to get an idea of the pricing structure. I may have misunderstood, bit it looked like a single server would cost $600 a month?

Is this accurate or have I misunderstood something?

Cheers,
Spen

1 Like

No way! Yesterday evening I started repurposing a TicTacToe game made for Facebook instant games so that I can reuse it for different backends, and specifically as a Defold example of a game for Nakama. Perfect timing!

6 Likes

Isn’t that for dedicated hosting, support and maintenance provided by HeroicLabs? I believe you can spin up a Nakama server “anywhere”.

3 Likes

@TocnoSanZna I would definitely recommend Colyseus. Start with small, build a prototype using Colyseus + Defold, see the result yourself.

It is for dedicated hosting and support from Nakama team. Managing multiplayer fleet is tough business.
You can freely do whatever you want.

2 Likes

I see, that makes sense. Thank you.

@SpencerWF You’ve highlighted a good point. The website does not do a good job to convey the value of the Heroic Cloud.

The pricing which is covered on the cloud is more than just a single server it includes: game server hardware, database server hardware, load balancers, logs aggregation, metrics storage, database backups, SSL termination, unlimited bandwidth (subject to fair use), container build system (unlimited containers can be built and stored), etc.

Hope this makes it clearer.

As has been mentioned the server can be deployed to any cloud provider and run on whatever hardware you like (though we do outline some recommendations on the benchmarks page). We’ve engineered the server carefully so that it does not depend on functionality specific to AWS, GCP, or another major provider. Many indie teams use Digital Ocean or Linode or Vultr to run the server and manage it themselves.

4 Likes

Thank you so much for that explanation! Sounds like a great solution.

1 Like