A microservice is a common design pattern that has recently gained a lot of traction in the application development world. Microservices have a lot of benefits and are not without merit, however, they are not always the best option. If you are considering migrating your old monoliths to microservices, you should make sure it’s a good fit for your use case before taking the plunge.
Here’s an outline of some of the advantages and disadvantages of microservices.
Advantages of Microservices
- Horizontal scalability
- Resilience to partial failures
- Low downtime
- Rolling updates
- Reduced code coupling
- Features can be partially rolled out as they are completed, instead of all at once
- Dev teams can be divided along service lines
Disadvantages of Microservices
- Increased amount of configuration
- Increased deployment complexity
- Fragmentation in code base
How to Successfully Migrate From Monoliths to Microservices
Once you have decided to start the migration, it’s worth taking some time to reevaluate how your application is designed. Design and implementation using microservices can be drastically different from how things work in a monolith application.
It’s also worth considering whether or not you want to include any other large design changes you’ve avoided making so far because they would have been too costly to implement in your monolith, such as changing programming languages or picking a software stack that is better suited to microservices.
Keep in mind: It may be better to stick with technologies your team already knows well.
Microservices go hand in hand with containers. Depending on your specific requirements, it would be worth looking into a container orchestration framework that is cloud native. This can take a lot of the hassle out of managing and deploying containers in AWS or Google Cloud. Check out our Container Wars blog post which pitches the leading container orchestration tools against each other for more information on the best option.
API Gateways Make It Easier
Using an API gateway can make the transition to microservices easier. It allows you to control which requests go to the legacy monolith and which ones go to the new microservices. An API gateway will allow you to create a minimum viable product with microservices without having to create every single microservice you need. There are going to be unforeseen problems with any new deployment. Starting small with a single service allows you to fix any issues you have before switching the entire system over.
API gateway is a design pattern that can be accomplished in a number of ways. Amazon offers a managed product that has a number of features, but there are other options, such as Nginx or a custom service to route requests. Which option you choose will depend on your specific needs.
Start With a Minimum Viable Product
Once your design is ready, I recommend you begin by deploying a single service to work alongside the existing monolith. This minimum product will help you work out bugs in the design and the deployment. When working on a brand-new system, there will always be unforeseen issues that pop up.
Starting with a minimum viable product and getting it working in production will make things a lot easier down the line. Especially when you have to migrate the entire application. Writing and deploying your first microservice will probably take a lot longer than you think. However, the knowledge you gain from deploying that first service will help make migrating the rest of the application much smoother.
Moving your application piecemeal over to microservices will give you some of the benefits of microservices without having to replace your entire monolith all at once. This will also give your developers and your ops team time to get used to the new way of doing things, which will speed up the DevOps process in the future.
Monitoring Your Microservices
One of my old managers used to say, “A feature isn’t complete until it’s monitored.” This is even more important with microservices because these are distributed systems, and debugging them is more complex than it would be with a monolith. Consider deploying a log aggregator, such as Splunk or Elasticsearch, alongside a performance monitoring system, like Prometheus. For an in-depth guide to the best monitoring options available, check out our blog post on Container Monitoring: Prometheus and Grafana Vs. Sysdig and Sysdig Monitor.
When (yes, “when,” not if) things start to go wrong, monitoring tools will be your main resource for figuring out what’s happening and why.
Migrating a monolith to microservices can be challenging, but making deliberate design choices and moving slowly can help the migration go smoothly. The microservice design pattern allows DevOps teams and software engineers to make systems that are resilient to failure and scale to meet an application’s demand. Microservices are designed for the cloud, and the battle-hardened tools available today make this game-changing transition even easier.
Alternatively, get started using Caylent today! The DevOps container management platform that helps software teams manage containers, clouds, and microservices with ease. Sign up here.
Writer: Bryan Absher
Bryan Absher is a Software Engineer who is passionate about new and old technology. He is currently working on large scale distributed applications and single page web apps in the Pacific Northwest.
Fun fact: Bryan has a cat and will dance your pants off.