Closed JustArchi closed 9 months ago
Another idea: we could implement some algorithm for calculating "checksum" of inventory state. This way we wouldn't need to keep state in the cache even, only saved checksum. The question is how that algorithm should work...
Bad idea, checksum alone won't do, BUT together with saving inventory in the cache, we can actually make it work.
Assuming inventory state is generated by some deterministic algorithm, ASF has previous inventory state, and current one. If it's determined that they're different, ASF sends previous inventory state, inventory changes, and newly calculated new inventory state. ASF backend can check if previous inventory state is the same in DB, if yes, it can add inventory changes and calculate its own new inventory state, then compare it with the one reported by ASF. If it's the same, we have 100% guarantee we didn't lose anything and there is no desync. If anything doesn't match (previous state, or new one), we tell ASF conflict and it needs to do full announce.
I don't see a problem anymore, I only need deterministic algorithm for inventory state now.
Checklist
Enhancement purpose
Right now ASF sends whole inventory state to ASFB, which is beneficial in a lot of aspects as we're always sure that we have the correct state. However, some people have really huge inventories which puts a lot of load on the server (and their links as well).
Solution
It could be a good idea to introduce "inventory diff" and announce that, it'd work like this:
Why currently available solutions are not sufficient?
It's working good enough, but with further increase in amount of users, inventories and items, we might reach a point where transmitting 50+ MB of (already compressed) data is not sufficient for operation.
Can you help us with this enhancement idea?
Yes, I can code the solution myself and send a pull request
Additional info
I'm not sure what to do about potential desyncs. We could have a situation where cache corruption or something else happens and we'll have outdated inventory state. Perhaps we could do bare minimum and along version send at least number of items we have right now, so server could do some bare minimum of state checking - we still risk corruption when we lose A and gain some other B, but that should be far less likely and resolve itself in time.
Other suggestions welcome.