Sobes.tech
Senior

Should we duplicate schemas in each microservice or consolidate them into a shared library?

sobes.tech AI

Answer from AI

Duplicating schemas in each microservice is not recommended, as it leads to support and synchronization issues. It is better to move common schemas into a separate shared library that all microservices will use.

Advantages of this approach:

  • Single place for changes, reducing the risk of desynchronization.
  • Simplified support and updates of schemas.
  • Increased data consistency between services.

However, it is important to consider that too tight coupling through shared libraries can reduce the independence of microservices. Therefore, the shared library should only contain truly common and stable parts of schemas.