Accessing Database From Multiple Instances Of A Microservice RRS feed

  • Question

  • Hi All,

    We need to access a Database table from a micro-service. When this micro-service scales out, we are faced with a situation when multiple instances of the same micro-service are accessing the same table instance. In this case there is a possibility of parallel access, in which case we run into issues. Our use case doesn't allow us to follow eventual consistency.

    For safe guarding the above scenario, we have used Stored Procedures.

    Is it the right way to go ? Can someone suggest any other alternate approaches

    Thanks for your suggestions.


    Saturday, September 14, 2019 6:54 AM

All replies

  • Can you please explain your issue a little better?  It is common to have multiple instances of a service get data from the same database / tables
    Saturday, September 14, 2019 2:02 PM
  • The database table contains unique resources that need to be allocated to users. Whenever a parallel requests come in, a unique resources is being allocated to more than one user, which is the problem.

    To avoid this, we have use stored procedures ( As transaction ) to lock the table. This ensures only one request is processed at a time.

    The question is, Is using Stored Procedures for this use case the right way to safeguard the database resource ? Or there are other better ways to do this ?

    Sunday, September 15, 2019 2:24 PM