Codingfullstack

· 8 minute read
by Avinash Singh

Microservices are an architectural style that develops a single application as a set of small services.

Each service runs in its own process. The services communicate with clients, and often each other, using lightweight protocols, often over messaging or HTTP.

  Microservices captures your business scenario, answering the question, “What problem are you trying to solve?”

 

Current Trend

Analysts predict that by 2022 developers will build 90% of all new applications on top of microservices.

What is so good about this method and should any business consider it as the best option for their next project?

Let’s find the right answers for your company together.

Microservices architecture made its name in the world of software development as a powerful technique to build large, highly scalable apps.

Its effectiveness has been proven by Netflix, Amazon, Twitter, Uber, PayPal, and other heavyweights who have adopted microservices and thrived on the ability to handle billions of user requests a day.

This doesn’t mean that all companies should reject the traditional approach and quickly move from a monolith to microservices.

Let’s take a look at both architectures,

What is monolithic architecture

  The word ‘monolith’ means ‘one massive stone’, so when we talk about something monolithic we communicate an idea of a large unified block.

In software development, monolithic architecture is a traditional way to build an application as a single structure containing a user interface, a server-side application, and a relational database. All layers and components of the app are tightly connected, so if you want to alter one feature, you will need to update the entire app at once.

microservices1 Image credit: Learning Hub

Pros of monolithic architecture

The main advantages of the traditional approach stem from its simplicity which makes it a good fit for smaller companies. Compared to microservices, the monolithic app is:

  • Easier to develop.

    You have a broad range of available tools that let you build software in a standard way. Any development team is capable of creating a single code-based app.

  • Easier to deploy.

    You need to deploy your application only once instead of performing multiple deployments of different files.

  • Easier to test and debug.

    With a monolith, you have fewer variables and thus lower risks that something will go wrong.

Cons of monolithic architecture

The drawbacks of monoliths become more obvious with app growth. Enterprise-grade software often faces the following challenges associated with the traditional approach:

  • Difficulties with onboarding new talent.
    The huge size of the codebase and complex interconnections between tightly coupled elements make it hard to understand the entire app in full, especially for newcomers who join your project.
  • Lack of flexibility.
    Monolithic architecture gives you no other option than to stay with the technology you chose at the initial stage of development. Consequently, you can’t benefit from new and more advanced frameworks and languages appearing in the software development market.
  • Time-consuming change implementation.
    Because of the tight interconnections, rolling out changes to a large and complex app is a cumbersome process. Minor as they may be, alterations affect the functionality of the whole system and force your team to update the entire codebase.
  • Low fault tolerance.
    Not only changes but also bugs and faults that occur in one part influence other elements, so the whole system can go down due to a minor failure. When the bug is fixed, you’ll need to retest the whole app.
  • Scaling limits.
    Monolithic apps can’t be scaled endlessly, so the more people who use your software, the more problems you have with handling all the requests.
  • Long time to market for large apps.
    It may take months or years to develop an enterprise-grade monolithic application, which means that your product might hit the market too late to be a success.

 

What is microservices architecture

With a microservices approach, a large application is split into loosely-coupled parts, each performing a particular task.  

Loose coupling brings about a scenario where every service or component has its own lifecycle, runs its own processes, and uses its own logically distinct database.

These independent elements can be developed, deployed, scaled, and maintained separately, while the rest of the app will continue to function in its usual way. As a result, you can use different frameworks, programming languages, and technologies for creating different modules of the app.

microservices2

 

Pros of microservices

  • Flexibility in choosing technology.

    You are free to use various tech stacks for each microservice. For example, one module can be built with Node.js, another with Python and another with Java. Your choice will be based on the skills of the available engineers and the needs of the particular service.

  • Fast delivery of new features to end users.

    If you follow the microservices philosophy, you have several teams each working on their own module and taking the whole responsibility for its lifecycle, from design to deployment and maintenance. As a result, smaller services are developed faster and the team can release their part of the code without waiting for other modules to be ready.

  • Effective updating.

    When you implement changes to a microservice or redeploy it, you don’t need to update the whole system.

  • Quick scaling.

    You can scale each service independently, so it takes less time and effort to grow your product than with a monolithic approach.

  • Resistance to failures.

    If one particular service crashes, it won’t bring down the whole system. Moreover, chances are high that you’ll find and fix a bug within an isolated piece of code much faster than in a huge monolith.

  • Reusability across the business.

    Login systems, file uploaders, and other small services can be reused across the large application.

 

Cons of microservices

There is no ideal technology, and the benefits of microservices come at a price as well. The major challenges posed by this trendy software architecture are:

  • Company reorganization.
    When you move to microservices, you should also decentralize your business dividing it into autonomous teams, capable of building, testing, and running their separate service.
  • Issues with handling communications.
    To work as a well-tuned mechanism, microservices need to communicate with each other using REST APIs or message queue services. Virtually, you have many tiny applications interchanging multiple messages. This continuous ‘chatting’ reduces performance due to network latency and the time the system takes to process messages.
  • Testing microservices.
    Testing monoliths is quite straightforward, as the app has a single code base stored in one place. Microservices, on the contrary, reside in different machines and have to interact synchronously via the network which adds a layer of complexity to the testing process.
  • Development complexity.
    A microservices app is a distributed system containing hundreds of separate parts with complex interconnections. You need highly skilled professionals to architect a robust and reliable structure from the very beginning and to manage it later on.
  • Operational complexity.
    Among other major challenges brought by microservices, business owners mention problems with security, deployment, support,and monitoring. There are different automated solutions (for example Kubernetes) to make things easier, but each adds to the overall complexity and increases the budget, and these investments don’t always pay back.

 

Monolith vs microservices comparison table

microservices3

Category Monolithic app Microservices
App Structure Single unit Finely-grained services with their own lifecycle
Workflow One or more teams develop one app Each microservice is developed, tested, and run by the independent team
Language Typically developed with one language Different languages can be used for different microservices
Scaling and updating You always scale and update the entire app at once You can scale and update each microservice separately

 

Monolith vs microservices: how to make the right decision

To make the choice between a monolith and microservices you’ll need to consider the following parameters.

Your business size and goals

For a small business, a simple unified solution will be a better option, as it is more manageable and cost-effective when compared to a bundle of independent parts. Enterprises serving millions of customers and companies aiming to grow rapidly will benefit from microservices, which make scaling and adding new functionality much easier.

Of course, there are ambitious tech-savvy startups that opt for microservices in order to be ready to scale fast at any moment. However, this is rather risky and often falls short of expectations.

Your team’s expertise

Adopting microservices involves great risks if you lack proper skills and resources to handle all the processes. You need engineers with expertise in DevOps, distributed architecture rules, container and cloud technologies, domain-driven design, and many other fields. Also, keep in mind, that to run its own service independently each team should have all the mentioned above knowledge.

Your domain

The specific requirements of your domain is another critical parameter when choosing between microservices and monolithic architecture. Together with a business analyst consider whether your domain is complex enough to be broken into subdomains. If the answer is ‘no’, the traditional architecture would be a better option.

Your budget

Microservices apps usually cost more than monoliths as they require more resources, including cross-functional teams, many servers, a broad set of cloud infrastructure services, etc. If you have a lean budget, stick to a traditional unified structure.

 

Do you seriously need microservices?

To sum up the microservices vs monolith discussion, you should implement microservices only when you really need them.

The fact of the matter is that there are many options between the two extremes of a huge, rigid monolith and a suite of hard-to-manage microservices.

comments powered by Disqus