In a document editing web application such as Google Docs or Evernote, sync/save has to happen almost instantaneously to make sure data loss is minimal in case of a connection failure or a client crash.

A straight forward solution seems like to have the update end point called at short time duration or each time user pauses after typing. To keep this data in sync we will update the database field for the text/JSON data.

How do we better optimize these frequent write/update calls to the database? Is the optimization unnecessary?

1 Answer 1


You can keep updated data in a memory cache (such as REDIS) on the server side that is flushed into the database less frequently.

But the general rule of thumb for optimization is that you don't do it before you:

  • clearly see that there is a performance problem, either by experience or by calculations based on hard data and reasonable assumptions about usage frequency,

  • can demonstrate that the optimization addresses the performance problem,

  • can show that the cost of implementing the optimization is more than offset by the gains in performance.

In your case, calculate the expected load (how many users can be active at a time and how frequently does the client call the update endpoint?). If the database can handle that load easily, stop right there. No need to optimize.

You can keep notes on optimization ideas such as the memory cache so you don't have to search for possible solutions when the need arises later, but you should not burn time by implementing them before you really know you need them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.