Simplifying Architecture: Moving from Microservices to a Monolith 🗿
As the CTO of a tech startup, you’re constantly faced with important decisions that can shape the trajectory of your company. One such decision that we made at the end of 2022 was to migrate from a microservices architecture to a monolith. This transition came with its fair share of pros and cons, but in hindsight, it has proven to be the correct choice for our company. In this article, we’ll delve into the reasons behind this move and the valuable lessons we learned from it.
The Microservices Maze
In our previous architecture, each application operated as an independent service, complete with its own infrastructure, data model, and API. On top of these services, we had an ‘aggregation layer’ that provided authentication and authorization, along with a single API that the front-end utilized, creating a seamless user experience. Theoretically, this setup offered the ability to scale individual services based on their usage and make changes in one service without impacting the others. However, reality had a different story to tell.
Lessons Learned and Improvements Observed
1. Economy of Scale
In various industries, it’s a well-known fact that a single, large engine carrying multiple loads is more efficient than multiple smaller engines. This concept applies equally to computing as it does to trains or cargo ships. Operating separate compute resources for each service proved significantly more expensive than consolidating them into a single, robust server. As a startup in its early years, our usage patterns were often idle or low, with occasional spikes when customers processed data. This led to us either paying for servers that sat idle or witnessing them struggle to meet peak demands due to high compute costs.
💡 Lesson: Architect for the scale you need, not the scale you dream of.
2. Development Experience
In our previous architecture, development was a cumbersome process. Every engineer had to become proficient with technologies like Docker, Kubernetes, and Bash. While these skills are valuable, the constant need to spin up multiple services, manage dependencies, network configurations, and storage, all while dealing with issues arising from tightly coupled services, meant that valuable development time was spent on DevOps tasks rather than building features and addressing bugs. Since the migration to a monolith, our development speed has improved by at least 50%.
💡 Lesson: Prioritize development speed and add complexity only when absolutely necessary. Every piece of infrastructure you add to your architecture will require every developer to deal with it.
3. Simplified Monitoring
In the microservices world, monitoring can become a headache. With more than ten services running concurrently, we had ten different potential points of failure. Setting up alerts for each service, sifting through multiple log systems, and tracing network activity from one service to another could sometimes take over an hour to identify complex issues that spanned multiple services. This also compelled us to use complex monitoring solutions, each with its own learning curve and requirements. Post-migration, it now takes us an average of just ten minutes to identify an issue, with the need to check only one or two log streams.
💡 Lesson: Monitoring is supposed to make your life easier; don't let it become a source of complexity.
The Path Forward
While there are more benefits we could discuss, we’ll keep this post concise. Overall, transitioning from a complex microservices architecture to a simple monolith has proven to be a hugely beneficial decision for our specific use case. It has granted us the stability and confidence to focus on building the product our customers need. In the future, we may reevaluate whether some services should be decoupled from the monolith, but for now, keeping things simple has been the key to our success.
In the ever-evolving tech landscape, adapting your architecture to meet your current needs and priorities is essential. Our journey from microservices to a monolith has been a testament to the importance of simplicity, efficiency, and adaptability in building a successful tech startup.
If you find our articles useful, register for our monthly newsletter for regular industry insights 👇