Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share microservices between different projects

I want to make a microservice project including some microservices like: page, order, products and etc. I have two questions about that:

  1. I want to know if it is a good idea to reuse the same microservice in different projects and store multiple websites data in one microservice and retrieve corresponding data by the project token?

    For example we have website A and website B and share their data in the same microservice database and products microservice holds website A and website B products.

  2. If reusing microservice is a good idea, then problems may occur if maybe there are some slight changes between website A and website B products. Should I rewrite another microservice for website B or write a generic product microservice so it can handle different types of products?

like image 558
Mostafa Solati Avatar asked Jul 05 '26 18:07

Mostafa Solati


1 Answers

For the first time you can write generic service that is used by two or more consumers, but it will bring you problems if business logic changes for one of the consumers.

My advice would be, if you think that system will not change frequently and does not grow much, make shared service, otherwise decoupling would be much better approach.

like image 73
giorgi dvalishvili Avatar answered Jul 07 '26 13:07

giorgi dvalishvili



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!