Write to database too slow for REST service

Problem: The request response time for a REST service we provided was too slow. Solution: Return data to API customer first and persist data later. Solution explanation: The runtime analysis showed that the write operation to the database was the slowest part of the API call. The solution for speedup was to write the data to the database AFTER returning the response to the client. While this increases the risk of having "old" data in the database for another call, that needs this data (very improbable case) it improves the response performance significantly. It also enables us to collect all responses for x seconds and save them in bulk to the database, which reduces overhead and therefore the total load on the database. The reduced response time and load on the database was worth the increased risk of answering requests based on "old" data.

Comments

You canot assure the user, that the object was saved. What if database is not available or save fails...
Aleksander Kami... - Sun, 12/15/2019 - 23:16 :::
No answers yet.