The world’s leading publication for data science, AI, and ML professionals.

Is Microservice Architecture the best choice for Machine Learning Deployment?

Understanding the difference between Monolithic Architecture and Microservice Architecture

Photo by Eric Prouzet on Unsplash
Photo by Eric Prouzet on Unsplash

Introduction

Machine Learning deployments trends are moving towards agility, scalability, flexibility, and shift to cloud computing platforms. Organizations that previously managed and deployed applications with a central team and Monolithic architecture has reached the bottleneck when it comes to scaling with the increase of data volume and demand. Therefore, Microservices Architecture is becoming a popular approach for organizations and has been adopted by large organizations such as Netflix, Amazon, Uber, Grab, etc.

In this article, we will understand:

  • What is a Monolithic Architecture?
  • What is a Microservices Architecture?

What is a Monolithic Architecture?

Monolithic Architecture (Image by Author)
Monolithic Architecture (Image by Author)

A Monolithic Architecture is considered the traditional approach of building applications. A monolithic application is managed from a single, centralized location by a central data team which means all processes are run as a single unified unit.

Typically, the monolithic application uses one large code base that can be developed by multiple developers. If one of the developers wants to make changes to the code, they will have to access the same code base and make changes to the entire stack. If the code base grows larger, making changes such as adding a new feature will eventually become more complex. Eventually, the application will not be scalable as the complexity increases and new features are not able to be added easily. In addition, as all the processes are interconnected and dependent on each other, a failure on a single process will results in a failure on the entire application and the whole application has to be rewritten.

However, Monolithic Applications stills carry some advantages such as:

  • Easy for Deployment – As everything is in one single application, you will only need to handle just one particular file.
  • Easy for Testing & Debugging – As everything is in one single indivisible unit, end-to-end testing can be done much quicker.
  • Easy to develop – As Monolithic application has been the traditional approach, any data platform/engineering member is capable of developing a Monolithic application.

What is a Microservices Architecture?

Microservices Architecture (Image by Author)
Microservices Architecture (Image by Author)

While we know that a Monolithic Architecture is a build based on a single unified unit, Microservices Architecture is highly decentralized which breaks down a single big application / monolithic application into a set of smaller independent units. Each microservice will focus on a particular function and communicates with other microservices via APIs (Application Program Interfaces).

Let’s look at the advantages on why machine learning models are often the choice to be deployed as microservices:

  • Scalable – Each microservice is an independent component that runs its own process and is deployed independently. As each service is deployed independently, a particular microservice can be scaled independently of the entire application.
  • Agility – Failure in a microservice application only affects a particular service instead of the entire application. Therefore, fixing and debugging will be done on that particular microservice instead of pausing and fix the entire application.
  • Flexibility – Team members are not limited by the programming languages or tools used to create and deploy the microservice and can have different frameworks for each microservice. In addition, if there are codes developed previously, team members can leverage those codes instead of re-building them again.
  • Autonomy – Developing using a microservice architecture approach allows more team autonomy as each member can focus on developing a specific microservice that focuses on a particular functionality for example each member can focus on building a microservice that focus on a particular task in the machine learning deployment process such as – data ingestion, feature engineering, data validation, model scoring, etc.
  • Easy to Understand – As things are being split up into smaller components, a single microservice application is easier to understand and managed as usually, one microservice focuses on a particular task.

Microservice Architecture might seem like the perfect approach to you right now, but nonetheless, there are disadvantages too. Below are some of the disadvantages identified:

  • Higher cost – Compared with Monolithic Architecture, Microservices are usually more expensive as it required more resources as each service are independent to one another, it requires its own CPU/ instances and environment. In addition, the company will need to hire or provide training to have a set of skilled teams that is able to understand, develop and maintain the microservices.
  • Complexity – While Monolithic Architecture can be complex as the code base grows larger, a Microservice Architecture can consist of dozens or hundreds of different services (Eg: Uber has grown to have over 2,200 microservices) that need to communicate seamlessly and securely. With so many microservices, debugging can become more challenging as problem tracing will not be so straightforward.
  • Security – Microservices are often deployed on Cloud Platforms and require to communicate with each other over the network poses security challenges as it creates an opportunity for outsiders to gain access into the system.

Conclusion:

Depending on the scenarios for the business/project, if the organization has just been formed, the team is small and the project is lightweight – a Monolithic Architecture approach can be used. Where else, for large organizations building on complex applications with many members involves – a Microservices Architecture approach would be a better choice. Lastly, Microservices Architecture might work best for organizations that need to develop rapidly in an agile development process with many team members onboard.

Thanks for reading and I hope you enjoyed this article!


References & Links:

[1] https://aws.amazon.com/microservices/

[2] https://eng.uber.com/microservice-architecture/

[3] https://solace.com/blog/microservices-advantages-and-disadvantages/

[4] https://www.n-ix.com/microservices-vs-monolith-which-architecture-best-choice-your-business/


Related Articles