plainblack / Lacuna-Server-Open

The open source Lacuna Server repository.
36 stars 29 forks source link

Reduce lag by reducing status block #430

Open icydee opened 8 years ago

icydee commented 8 years ago

Status is returned for pretty much every API call. Fixes to reduce the overhead.

1) Make the return of status optional, have an api argument _nostatus which over-rides the return of the status block. Client can (for example) then only request it if more than (say) 60 seconds have elapsed. 2) Server can choose to send status anyway if something has changed (e.g. mail has arrived). 3) For baby empires make the request for baby empires/planets a separate API call. We only need to get the planets for a baby empire when we open the empire in the Right Hand Menu.

icydee commented 8 years ago

We could turn this around, only send the status block on request. The server could have a cache value for 'significant events' for each empire. A significant event being anything that would change the empire, e.g. an email being read/received, a new colony being created/destroyed, essentia being spend/purchased.

A similar cache value for each body could be created to catch significant events (not, for example normal increase in resources, which can be calculated) but things like more incoming ships, a 'needs_surface_refresh' etc. This cache value would have a modest timeout, say 2 minutes to ensure that it is sent fairly frequently (but not always)