Should I trust Change Stream?

Hey, I’ve been making an online game project for a while. I use MongoDB almost for everything related to database. I’d like to explain how I cache player data in game.

Basically, when player joins the game, the mongo document saves in server memory as a cache and I use cache for almost everything realted to player data. For now, I use change stream to update cache; when the “player” collection update, insert or delete, change stream will update server cache.

Should I really trust “Change Stream” for a long time? Normally, online games are using sockets and rest API for datas but I’ve found the Change Stream more suits what I’m doing. In the future, if the project grows up, I’ll probably use sharding and other complicated things for database and I really don’t want to change my bone caching system. Therefore, I’d want to know I should trust change stream for a long time or not.

Hi @Duck,

I think change streams with all the recommended resume-ability options implemented should be a reliable solution.

It is vastly used in many MongoDB products. However, its important to note all the production considerations and trying to keep the open change streams to a minimal number as long as the performance is setisfied:

https://docs.mongodb.com/manual/administration/change-streams-production-recommendations/

Please note there is a specific section for Sharded cluster there.

Please let me know if you have any additional questions.

Best regards,
Pavel

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.