Ahsan
Ahsan

Reputation: 4154

Multiple micro-services backed by the same DynamoDB table?

Is it an anti pattern if multiple micro-services read/write to/from the same DynamoDB table?

Please note that:

Upvotes: 2

Views: 1549

Answers (2)

Ashish
Ashish

Reputation: 3652

I have a different opinion here and I'll call this approach as anti-pattern. Few of the key principles which are getting violated here:

  1. Each MS should have it's own bounded context, here if all are sharing the same data set then their business boundaries are blurred.
  2. DB is single point of failure if DB goes down, all your services goes down.
  3. If you try to scale single service and spawn multiple instances, it will impact DB performance and eventually, will effect the performance of other microservices.

Solution,..IMO,

  1. First analyze if you have a case for MSA, if your data is very tightly coupled and dependent on each other then you don't need this architecture.
  2. Explore CQRS pattern, you might like to have different DB for read and write and synchronize them via event pattern.

Hope this helps!!

Upvotes: 1

Anunay
Anunay

Reputation: 1893

When you writing microservices it is advised to not share databases. That is there because it provides for easy scaling and provides each to services to have their own say when it comes to their set of data. It also enables one of these services to take a call on how data is to be kept and can change it at their will. This gives services flexibility.

Even if your schema is not changing you can be sure of the fact that one service when throttled will not impact the others.

If all your crud calls are channeled through a rest service you do have a service layer in front of a database and yes you can do that under microservices guidelines

I will still not call the approach an anti pattern. Its just that the collective experience says that its better not to talk to one databases for some of the reasons I mentioned above.

Upvotes: 3

Related Questions