Topics

Giving EdgeX Microservices Some Architectural Love

Drasko DRASKOVIC <drasko@...>
 

Hi all,
now that we are getting into Go re-write, I think it is a good
opportunity to address some of the architectural issues also.

Jim and Dell team already did great job putting all EdgeX in place,
but for example there is still tight coupling between microservices as
they share data models. In order to do Export Services re-write I am
currently re-defining some of Java classes even from Core repos.

Sharing data libraries between microservices is not a good idea:
https://blog.philipphauer.de/dont-share-libraries-among-microservices/
- they should be loosely coupled, independently scalable and thus have
separate data models. It of course affects directly possibility to
write microservice in some other programming language.

But this is not the only problem I spotted. There is also sharing of
database instances - for example ExportDistribution microservice will
tap directly into ExportClient's DB:
https://wiki.edgexfoundry.org/display/FA/Architecture--Export+Services--Distribution.

To give a few references why this is bad practice:
- https://www.nginx.com/blog/microservices-at-netflix-architectural-best-practices/,
chapter "Create a Separate Data Store for Each Microservice"
- https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/architect-microservice-container-applications/data-sovereignty-per-microservice
- http://www.ben-morris.com/a-shared-database-is-still-an-anti-pattern-no-matter-what-the-justification/
- http://enterprisecraftsmanship.com/2015/01/10/how-to-build-microservices-wrong/

Instead of sharing the DB, I would propose that ExportClient exports
an API for accessing it's DB, similar to this REST-based integration
pattern: http://hecodes.com/2017/04/integration-patterns-microservices-architectures-good-bad-ugly/

In any case, I would suggest better decoupling of microservices:
- No shared libraries (data models, Java classes, etc, ...)
- No shared storage (databases)

Best regards,
Drasko DRASKOVIC
Mainflux Author and Technical Advisor

www.mainflux.com | Industrial IoT Cloud
-------------------------------------------------------------------
Engineering Division | Paris, France

LinkedIn: https://www.linkedin.com/in/draskodraskovic
Twitter: @draskodraskovic