Efficient data syncing in browser-based MMORPG

I’m working on a browser-based MMORPG using HTML, JavaScript, and CSS. We’re facing challenges with keeping user data in sync between the frontend and backend. The game loads once and then uses Ajax for updates.

We store user information such as cash and level in a JavaScript object, which is modified as users interact with the game. However, trouble arises when other players trigger changes during events like fights.

We initially tried two methods: one where we refreshed the data on every user action, which caused many superfluous database calls, and another that introduced a proxy to check if data had changed before querying. Despite the proxy reducing the load, we still experience a high volume of redundant Ajax requests.

Is there an alternative strategy that minimizes these unnecessary calls while ensuring up-to-date information?

One effective strategy to consider is implementing a combination of server-side events (SSE) and a message queue system. SSE allows the server to push updates to the client in real-time, reducing the need for constant polling. This can be particularly useful for time-sensitive updates like combat events.

For less critical updates, you could implement a batching system. Instead of sending individual updates for each action, collect changes over a short period (e.g., 5 seconds) and send them as a single update. This approach significantly reduces the number of network requests while maintaining reasonable data freshness.

Additionally, consider implementing a conflict resolution mechanism on the client-side. This would allow the game to continue smoothly even if there’s a brief desync, reconciling differences when the next update arrives from the server.

yo, have u tried using a delta sync approach? basically, only send changes instead of the whole dataset. could save bandwidth n reduce unnecessary updates. also, maybe implement a polling system with adjustable intervals based on game activity? just throwin ideas out there

hmmm, have u considered websockets for real-time updates? They could help reduce unnecessary ajax calls. What about implementing a local cache with timestamps to track data freshness? ooh, or maybe event-driven updates for specific game actions? Curious to hear ur thoughts on these ideas!