DEV Community

Cover image for Monolith or Microservices: One App or Many?
Emmanuel Paul
Emmanuel Paul

Posted on

Monolith or Microservices: One App or Many?

As someone who’s still fairly new to the software industry, I’ve heard a lot of people throw terms like “Monoliths” and “Microservices” left and right. Truth be told, I’ve mostly pretended to know what these words mean, well, until now.

After spending some time on Google and checking out a few well-written articles, I’ve decided to just write my take on it. Keep in mind, I’m not some expert, so I’m always open to constructive criticisms (not random hole poking) in my logic.

The Monolith

Monolithic architecture is pretty much a traditional approach to software development where the entire application is built as a single unified program. Every part of the application, whether it’s the UI, the business logic, or database access, is written within one codebase.

Based on what I’ve learned, this means the different parts of the application are tightly coupled and typically deployed as one unit. While mixing multiple frameworks or languages is technically possible, doing so can introduce much complexity.

Then There's Microservices

If monoliths mean joining everything in one codebase, microservices seem to be the exact opposite. The large application is broken into small, independent services that communicate over a network (APIs, I believe). Each service handles a specific task, which may be processing payments, sending notifications, or simply authentication.

As services are independent units that simply communicate, they can be written in different languages, depending on their use. For instance, using Python for a service that requires a decent amount of data manipulation and Node.js for a real-time chat service. Plus, if one service fails, the others keep functioning, rather than taking every part of the app down alongside it.

What’s The Catch?

If either one of these approaches was perfect, there wouldn’t be much debate between the two. Whether you go for monoliths or microservices, there are a few downsides to consider.

With monoliths, scaling can eventually become inefficient. Horizontal scaling requires cloning the entire application stack instead of just the limited features, which wastes server resources. Changing the framework or programming language is also nearly impossible once a monolith reaches a massive size. Furthermore, working in one codebase can easily become a nightmare as the engineering team grows, leading to constant git merge conflicts, slow build times, and a slow development cycle.

When it comes to microservices, you get far more complexity in terms of infrastructure. You may need container orchestration (e.g., with tools like Kubernetes), service meshes, and automated CI/CD pipelines. Besides that, you have to consider network latency, connectivity issues, and securing connections, as various services need to communicate to run the application.

Don't Overengineer It

I have quickly become what I call an “expert” in the whole “Monolith vs. Microservices” debate, and here’s my take: Don’t overengineer it. The best software development approach depends on your current needs. If you’re building some kind of MVP or startup project, then just stick to a monolithic architecture, as it is modular and supports rapid early development and simple deployment.

On the other hand, if you’re scaling an enterprise application, with large distributed teams across several domains, microservices may make more sense. You get the fault isolation, independent scaling capability, and much more flexibility.

At the end of the day, there’s no universal winner here. Start with what solves your current problem, and let your architecture change as the problem gets bigger.

Top comments (2)

Collapse
 
paul_emmanuel profile image
Emmanuel Paul •

Hey 👋, I'm Emmanuel. This is officially my first post on dev.to, so if you've got any suggestions or simply want to say "Hi," feel free to drop a comment.

Collapse
 
rahul_r15 profile image
Rahul R •

Good points! For a growing application, how do you decide when it's actually time to move from a monolith to microservices? Are there any specific bottlenecks or challenges you look for before making that decision?