Best backend for realtime multiplayer game in meteor?

I’m using meteor, mongodb, javascript, and canvas to create a simple multi player game. I’m hoping to achieve at least 2 active players with less than a half second of lag when deployed on the web.

Locally meteor and the mongodb are fast enough to have a few connected clients, however when I try to run it on heroku + cloud mongodb there is up to a 5 second delay in response.

My mongodb has a Players collection of each active player where each record has the x and y coordinates of an active player, the current animation frame number for that player, and a string describes which animation should be playing for the current player. I have been testing wit just 2 players.

Is there a different back end or some other thing I could do to improve the performance to less than half a second of lag?

Hi @heuristiclese, welcome to the forums!

Have a read of thos similar thread:

The problem is different, but the suggested solutions are relevant to yours.

I would recommend tracking state in memory on the server and sending updates to the clients as needed instead of storing in a database. Especially on a platform like Heroku, where your db is likely on a different server and you need to pay the network latency penalty for both updates and reads.

There will still be some latency with this approach, especially if you’re sending updates from each client 60 times a second and then updates to each client at a matching 60 times per second!!
Ideally throttle the number of updates that need to be sent, if you can.

If you need really low latency, look into webRTC, so the clients can send updates to each other. In this configuration you will likely want an intermittent check from the server that the updates are sensible.

Good luck