lukeL
Convex Communityβ€’3y agoβ€’
10 replies
luke

How to optimize database bandwidth?

Hey everyone!

I'm working on a multiplayer emoji matching game, and while I've been having lots of friends help me test everything, I was surprised to see that I'm already very close to hitting the database bandwidth limit πŸ˜…

The project is fully open sourced, and you can check my Convex-generated schema right now here: https://github.com/lucasheriques/emojinx/blob/main/convex/schema.ts. You can also play the game here: http://emojinx.lucasfaria.dev/

I've started as naively as possible and just storing it in the best way to make it work and worry about performance later, but given that I'm already hitting some limits on Starter plan I'm wondering there's a couple of ways to do it better.

From what I researched in previous discussions here, database bandwidth is roughly measured by how many db.calls I'm making, which is a lot for a single multiplayer session. Here are the things I have to track multiple times during a game , and the related field on the schema:

- The status of each emoji (emojiList)
- The players' score (players)
- The current player turn (currentPlayerIndex)
- currentMultiplayerTimer (determines how many seconds the player has to make a play)

And the things I have to track only a couple of times per game:

- The status of the game (status)
- The winners (winnerIds)
- The room name (roomName)

My first thought is to make different tables for the real-time-important stuff, and another one for these, but I would love to hear some of your thoughts as well.

Also, on a side note, I absolutely loved using Convex, and together with the hackathon from WebDevCody it single-handedly brought back my joy to side projects again. I already have my next idea too. My motivation is to build fun and interactive games to play together with my friends or coworkers remotely πŸ˜‚ I always wanted to learn animations, but I was tired of just doing courses after courses, and this hackathon gave me the best opportunity to learn in practice
A fun and interactive emoji matching game
Was this page helpful?