Microservices Best Practices
As more and more development teams are becoming aware of the benefits of microservices and service-oriented architecture, we need to make sure we’re not just barreling ahead with little to no plan. It’s essential to think about the consumers of these services; we need to craft good developer experience in order to make working with microservices easy and maintainable.
In this article, we’ll look at some microservices best practices suggested by Michele Titolo (Capital One) from her talk at DockerCon 2016.
What Is a Microservice?
Let’s start off with a clear definition of what a microservice is:
- A small service that does one thing well
- Owner of its own data
Microservices exist in a larger ecosystem. It’s important to not just think about the one microservice. We need to make sure we think about how it connects to the larger system of the network.
Make Microservices Easy to Use
The needs of consumers of microservices all overlap. How can we ensure we’re making a great microservice for everyone?
There are a few things that are essential to creating a good developer experience with a microservice, and you should put enough effort into them to make sure you’re doing a good job with them:
- Documentation: Be clear and concise.
- Version and revision history: Provide historical records of when things changed and why.
- Live documentation: If possible, offer live responses (for example: APIs —> JSON response).
Other initiatives that can help make a big difference are:
- creating a dependency graph
- auto-generating documentation
- integration monitoring tools
We need to be able to surface errors before our service goes down.
Make Sure Your Microservices Can Coexist
In the end, it all comes down to two things:
Here are a few good questions you can ask yourself in order to check that you’re developing your microservice in a sustainable way:
- How does my microservice fit in with the others?
- Are my services capable of working together? Think date formats and so on.
- Am I taking single responsibility too far? Don’t try to force yourself into breaking up your monolithic apps. Sometimes it makes sense to not break everything up.
Your Best Practices for Microservices Checklist
Finally, if you want to build friendly, sustainable microservices, here’s a good checklist:
- Helpful documentation
- Built with monitoring and troubleshooting in mind
- Easily deployable and scalable
- Easy to consume
- Coexists with established conventions
Always be sure to make your service easy to deploy and scale. Provide consistent error messaging and make sure your microservice consumers can hit the API directly in a nonproduction environment.
|Reference:||Microservices Best Practices from our WCG partner Manue Weiss at the Codeship Blog blog.|