How to efficiently update player data in a browser-based MMORPG?

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

We store user info like cash and level in a JS object. This data can change from player actions or from other players (like during fights). Right now, we’re using two methods to keep things updated:

  1. Make an AJAX call for every user action such as tab clicks, fights, or purchases.
  2. Use a proxy to determine whether the data has changed before initiating a database query.

The issue is that approximately 70% of our AJAX calls turn out to be unnecessary because the data doesn’t update between intervals. Does anyone have ideas for a better approach? We need to maintain a responsive game while reducing the server load from excessive AJAX calls. Any insights would be greatly appreciated!

One approach you might consider is implementing a client-side prediction and server reconciliation system. This technique allows the client to make immediate updates to the player’s state, improving responsiveness, while periodically syncing with the server to ensure accuracy. You could combine this with a batch update system, where multiple changes are aggregated and sent to the server in a single request at regular intervals. This would significantly reduce the number of AJAX calls while maintaining data integrity. Additionally, you could implement a priority system for updates, ensuring that critical changes (like combat results) are sent immediately, while less urgent updates are batched.

hey sophia, have u considered using websockets? they’d let u establish a persistent connection between client n server, so u can push updates in real-time without constant ajax calls. u could also implement a delta compression algorithm to only send changed data, reducing bandwidth. might be worth lookin into!

ooh, interesting challenge! have u thought about usin local storage to cache player data? u could update it client-side n then sync periodically with the server. maybe combine that with a debounce function to limit ajax calls? just brainstormin here, but it could help reduce unnecessary server hits. what do u think?