Microservice vs. Monolith: Which One is the Best to Use? 

microservice vs. monolith

What are microservice and monolith? 

Microservice is an approach to application development in which a large application is built as a suite of modular services. It is generally used by large scale business to handle larger traffic loads. Martin Fowler advised that early startup should not even consider microservices unless you have a system that is too complex to manage as a monolith. The majority of software systems should be built as a single monolithic application, so pay attention to good modularity within that monolith but don’t try to separate it into separate services. 

Monolith is described as a single-tiered software application in which different components combined into a single platform from a single platform. Monolith handles requests by executing business logic, accessing database, exchanging messages with other systems, and returning an HTML/JSON/XML response. These are logical components corresponding to different functional areas of application. 

What are the benefits of monolith and microservice? 

Monolith is well-known among internet services such as Netflix, Amazon, and eBay. Most web applications developed by an author has a monolithic architecture. These companies use monolithic architecture because monolith is simple to develop, simple to deploy, and simple to scale. 

As the team grows and business becomes more complex, however, most businesses will migrate to microservice. Microservice is beneficial to large startups because microservice enables continuous delivery and deployment of large and complex applications. It is also easier for a developer to understand, as it starts faster, improves fault isolation, and eliminates any long-term commitment to a technology stack. 

Example in an application 

When you choose to use monolith, imagine that you are building an e-commerce application that takes orders from customers, verifies inventory and available credit, as well as ships the goods. The application consists of several components including StoreFrontUI, which implements the user interface, along with some backend services for checking needed information. This application is deployed as a single monolithic application which you can run multiple instances of the application behind a load balancer in order to scale and improve availability. 

When you choose to use microservice, imagine that you are creating an e-commerce application that takes orders from customers, verifies inventory and available credit, and ships all in a separate order. In this case, each microservice is focused on single business capability. Search, rating, review, as well as payment have their own instance (server) and communicate with each other. Unlike monolith that runs under one navigator, microservice has its own navigator for different services. 

Final Thought 

When you are introduced to the monolith or microservice, it would be wiser for a startup to use monolith. Zaiku in his article cited that traditionally, the most successful startups started with a monolith architecture for a while until their business model is proven and growing. When your business is big, you can switch to a more advanced architectural pattern such as microservice. Other than that, the following reasons are the perfect time you should use microservice

  • When your startup requires quick, independent service delivery. Yet, depending on the size of your team, it can take some time before you see any service delivery gains versus starting with a monolith. 
  • When your startup platform needs to be extremely efficient. For example, if your business is doing intensive processing of petabytes of log volume, building service from microservice architecture will be more efficient. 
  • When you plan to scale your team. Having more team members that are separated by service boundaries makes scaling your development organisation easier. 

And here is the perfect time to use monolith

  • When your startup team is just a few. If you currently have 3 or 6 members in your team, it will be hard to maintain your system using microservice. 
  • When you are building a concept instead of a product. Monolith is ideal to allow rapid product iteration. 
  • When you or your team has no microservice experience. If your team has no prior experience with microservice, it is likely that you will risk your early startup to fall. Microservice is quite complex, thus, have no experience means better to stick to a monolith to start. 

“Keep reminding yourself that different startup has its own context and process. The key is to start with service architecture that suits your business.”

Read also: What Makes a Successful Entrepreneur? Jack Ma Shared 5 Top Tips for Startup Founder