Suat Alkan Suat Alkan - 6 days ago 5
Node.js Question

Build simple backend with node.js and for mobile game

First of all I am a self-taught programmer/developer, sorry for some obvious questions. This topic is more of a design questions than programming.

I have a.t.m an Android game live at play store, I use 3rd party backend and networking solution. Now I want to build my own simple backend and networking solution. Why? Because:

  • The ability to add new functionality free of

  • Moving gamelogic from client to server-side

  • Learning about backend development

  • Learning about networking (not p2p, so no hole punching)

  • Getting experience in server-side development and technologies

For your information, my game is some sort of Spades.

Now my questions:

I am thinking to use node.js, and mongoDB to create my backend system.

These are what I want to do:


  • Just sending from server to client and vice versa

  •'hey') (server to client)

  • socket.Emit("JoinRoom") (client to server)

Backend functions:

  • User Authentication

  • Registering player information (name, unique id, score, date
    creation, etc)

  • Updating scores each time

  • Registering friends list so they can play together

  • Etc.

What will my gamelogic do for each room (ATM my gamelogic is totaly client side, so vulnerable to hacking and cheating):

  • When room created, wait for 10 seconds so other people can join

  • When 10 seconds are over, call a function that handles the startup

  • Randomize 52 deck card

  • AI choosing bet

  • AI choosing trump

  • AI playing when it’s his turn

  • Determining who has the next turn

  • Determining who has won

  • Updating scores in the database

  • When the game is finished opening the room so people can leave and
    join the game

  • Etc.

Is it possible to create this with node.js, and mongoDB? And if yes is it smart thing to do it with node.js, and mongoDB or is it better to do it with another technology?

Or should I use node.js and for the networking part, and another technologie(example for game logic? I have read that node.js is not good at CPU heavy tasks, and I think the gamelogic part is CPU heavy.

Maybe some of you may want to know how much player my system will support? Well atm I have daily 20 CCU but my game is for 3 weeks in store and I don’t promote a lot because I want first a strong backend system. I want my backend be able to handle 10 000 CCU, maybe I will never reach it but that’s my aim.

I hope I was clear about what I want, let’s hope you guys can help me out. I have looked for a week if what I want to do is possible and efficient.


NodeJS is a fine choice for this type of thing. Lots of concurrent IO, in relatively short bursts. You can definitely make a scalable server-side with the technologies you listed.

That game logic might get complex, but I doubt you'll even notice a CPU spike for the rules and checks you need to implement for a card game. At each stage, you'll have maybe 5-10 rules to check, and maybe iterate over a 52-card array (twice!). Not a problem. For CPU bound tasks, think "1000's of iterations" (image processing?) or "mathematical calculations" (overused fibonacci?).

I will point you to actionherojs as a node server with built-in chat (for your game room communications), built-in tasks (for your 10-second timeouts and AI turns), and a nice project structure for starting a new NodeJS app from scratch.

Have fun!