Need some clarifications on the best practises that needs to be followed while updating data into the DB in a spring microservices based webapplication
We have a webapplication, in which when the user sends request from the UI, for processing the request, at the backend the request goes to a microservice and we have to update the request and response objects in a particular table in the database. I wanted to know the right approach for updating the data in the databse. Below are my queries.
Should we insert the request Object as soon as we receive it in the microservices or
Should we process the request and after the processing, once we receive the response, should we do a single insert to the database with both request and response Object to avoid multiple DB calls.
Any help on this is much appreciated. Thanks in Advance.
Then to me, that is suggestive of how to design your app. As for "best practices"... One "best practice" is to not allow best practices to prevent you from producing a design which does what the specs say.
Let me ask you a follow-on question, though. If there's a catastrophic failure while your microservice is running and it's unable to update the database with the response object, do you still want to see the request object in the database?