JSON document splitting

Ok, my question is a bit complicated, but it says:

I have a Python server that stores client sessions (written in JavaScript) and has a complete understanding of what the client currently stores in its state.

The server will constantly retrieve data from the database and check for any changes regarding the status of the client. JSON data; consisting mainly of lists and dicts. I need a way to send a response to a client telling him to change his data according to what the server has.

I reviewed:

  • Sending a JSON-serialized recursively scattered dict of modified elements and never using lists is not bad, but I cannot use lists
  • Send the entire client version of the client state to the client - costly and inefficient
  • Find the hard way to the difference lists - painful and dirty
  • Text scatter of two after reset as JSON - simple dumb

I am very excited and I will be grateful for any help with this.

UPDATE

I am considering sending zeros to the client to remove unnecessary data and remove the server from its client status version.

+4
source share
1 answer

Related question

Cm

There are several possible approaches:

  • Make the actual recursive diff for the recursive tree;
  • Encapsulate JSON updates so that they generate diff at the same time;
  • Create only JSON with changes directly from your data.

What are your expected average and maximum sizes for JSON client state?

What are your expected average and maximum sizes for diff updates?

How often are updates requested?

How fast does baseline data change?

Why can't you use lists?

You can only save a known timestamp of the client’s status and query the database for items that have changed since then - effectively, let the database do the diff for you. For each table element, the last modified timestamp and item-deleted flag will be required; Instead of directly deleting items, set the flag deleted by the item and get a cleanup request that deletes all entries with the flag marked by the item set more than two full refresh cycles back.

It would be useful to see some examples of data - two sets of JSON client state data and the difference between them.

+3
source

Source: https://habr.com/ru/post/1313944/


All Articles