D
D
Decadal2017-01-12 23:50:41
MySQL
Decadal, 2017-01-12 23:50:41

How to save large texts with frequent but minor changes?

There is a form that saves the text without a "save" button, i.e., interactively (something like googledoc). As soon as the user finishes entering text and a few seconds pass, a request is sent to the server with all the content to save the entered changes. There is a problem with large texts (there is a text size limit, 64 kb, it's still a problem).
There is a possibility that the next change of a large text will be corrupted (only a piece of text will be saved). This is especially noticeable with a slow Internet. In addition, as soon as there are a lot of users, I suspect the server will go down.
How to solve this problem? Is it possible to partially update a field in MySQL (I have no idea how it would look like), or use nosql (if so, what would be an approximate algorithm)? How to identify partial changes so as not to drive the entire text, but only the changes made? Share your experience.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Wolf, 2017-01-13
@Decadal

1. To create a delta of changes in anything (in text, or in binary data, etc.), there are utilities / algorithms that are already ready. You can take them and adapt for yourself, for example diff . How this will be implemented at the JS level in the browser, I still have no idea, but hypothetically - it is quite possible / feasible.
A partial update of a file is possible only if the amount of changed data is equal to the amount of original data, i.e. you cannot open a file and insert something in its middle, you can overwrite a piece of data exactly the same in length as it was before. Otherwise, the file will either be overwritten from the point where the change was made, or the entire file will be overwritten. It doesn't depend on the base, it's simple arithmetic.
Judging by the context of the epithet above, this is not a problem of the base, but of the slow Internet of a particular user. And also, some serious architectural errors. How users manage to send half of the request - I have no idea, even in "laboratory conditions" it is quite difficult to emit, not to mention the fact that this would be repeated many times. But if your requests somehow manage to come in chunks, put some marker at the end of the request that the user cannot reproduce, for example, some binary symbol that will indicate that this is the end of the message. If it is not there, give the user a message that everything is very, very bad...

How to identify partial changes so as not to drive the entire text, but only the changes made? Share your experience.
The answer to this question is contained in the 1st paragraph, above in the text :)
In addition, as soon as there are a lot of users, I suspect the server will go down.
It will be rather strange if your base falls under such a load ... This is more likely, again, to serious errors in the architecture, and not database / server problems as such.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question