Microservices are now having a good time, not only because it is easier to scale but also easier to maintain (for some points). Compared to the monolith, microservices can be released by a changed part only, not the whole application. Moreover, the technology stack for each service can be different to leverage the technology stacks for various cases. Upon learning microservices, I found this book, Building Microservices by Sam Newman. I would like to make some reading notes about this book, maybe looks like review too. Oh, maybe you will not find all the things here, because it is intended so you will be encouraged to read the book on your own.
What are covered in this book?
Ok, so this book covers the benefits of microservices architecture, comparison with monolith architecture, how to breakdown your monolith application, and how to optimize your microservices. On this reading notes, I don’t separate it by using the chapters like on the book, rather I group them based on their strong connection.
Modeling the Microservices and Integration
In a system, monolith or microservices, it is common for each service to communicate with other services. Based on that, it is recommended to use domain driven development to model the microservices and integrate them. Several domains then combined in a bounded context to form a microservice. This concept will make the system will have strong cohesion and loosely coupled.
Then, how about the integration? It is recommended to use integration by calling the service, not by using database integration. There are several methods to communication such as remote procedure calls and REST. The choice needs to look at how the technology stack of the system. Can each microservice use a different stack?
The book also discussed several optimizations. One of the optimizations is the versioning strategy. Then strategy to separate UI to call its own microservices. It is also discussed whether to use asynchronous of synchronous for methods.
Deployment and Testing
Sam Newman discussed using CI/CD for the deployment. As microservice has the advantage to deploy only the changed microservices, it would be more proper if the CI/CD tools build only for the changed microservices than having to build the whole system. The source code can be from 1 repository or several repositories, based on the size of the code. Sam also discussed the following flow of deployment and you can read it through to get a better understanding of the deployment. After all, developer and DevOps should tag along together to build the system.
Testing is the next thing. Testing is crucial to deliver with confidence. Sam then explain the importance of testing, along with four categories of testing based on Brian Marick’s testing quadrant. They are unit testing, acceptance testing, property testing, and exploratory testing. Unit testing will answer the question “Did we build it right?” and usually it is made by developers. Next one is acceptance testing which will answer the question “Did we build the right thing?”. The third one is property testing that will test the performance, security, and other properties. The last category is exploratory testing which is manual testing to explore the usability of the system.
There are several other points about testing to make the system testing more maintainable such as making the system faster to test. This can be done by making the test can catch a bug using a faster test which is unit testing. Imagine we get a bug in acceptance testing, such as end-to-end test, which may be slower than a unit test. By using that knowledge we make test in unit testing that can catch bug like that in the unit test. Other points related to the testing scope and the flow of the test.
Monitoring and Security
Monitor your system across many instances will be hard if you do it manually. Luckily there are many tools right now to ease with monitoring both on your own instances or cloud platform. Cloud platforms also commonly have the tools to do monitoring across their instance. Standardizing how to log is also very helpful for monitoring.
Security also discussed thoroughly here. The strategy for authentication and authorization for the system is one of the fundamental security needs to handle. Then, how it should communicate between the microservices and also with third-party service should also be tailored to its finest. We must not let any security issue arise in the system.
Managing The Team
There are ways to manage the microservices team. The management should consider the scope of the team. Should they work across the microservices or specific only in of the service? Then, we’ve talked earlier about the communication of the microservices, but how about the communication of the team worked on it? There are several methods proposed here with their advantages and disadvantages.
So, these are the reading notes of this book, Building Microservices by Sam Newman. It may be a book published in 2015, but I think this book is still a good relevant book for microservices architecture. You can get the book at Amazon here.
Info: GDP Labs is hiring 1000 great engineers, register at https://career.catapa.com/gdplabs/jobs!
Image source: Pixabay.com