Microservices architecture is considered one of the architectural design patterns types. Architectural design patterns provide solutions to software developers recurring problems by arranging and spliting code in several ways, each type of architectural design patterns has its own way.
Microservices architecture, is a method of developing software systems that has grown in popularity in recent years. For most developers it has become a preferred way of creating applications.
The idea behind microservices is that some types of applications become easier to build and maintain when they are broken down into smaller, composable pieces which work together. Each component is developed separately, and the application is then simply the sum of its components.
This idea arose Because having one giant code base that all developers touch often becomes hard to manage. So the idea behind microservices is to break the giant code into smaller ones managed by small teams, each team can work in release cycles that are decoupled from other teams.
Before Microservices architecture has grown there were another types of design patterns used the most. Till now we can say there are popular types of architectural design patterns like SOA and MVC.
Let’s take an overveiw..
Service Orianted Architecture(SOA)
A service-oriented architecture is a collection of services that communicate with each other.
What is a service in SAO?
A service is a self-contained unit of software that performs a specific task, and does not depend on the context or state of other services.
Benefits of SOA:
Having all components isolated into various services make it more flexible, Easier to test and debug, scalable, and reusable.
MVC is a software architecture that separates the application into three parts: the model, the view, and the controller.
The model-view-controller pattern proposes three main components or objects to be used in software development:
A Model , which stores data that is retrieved according to commands from the controller and displayed in the view. A View , which is a collection of classes representing the elements in the user interface. A Controller , which represents the classes connecting the model and the view, and is used to communicate between classes in the model and view.
Now, you can see the difference between types of architectural design pattern. So let us take a look about difference between microservices and other types, to know why microservices..
Monolithic vs. microservices
Microservices came to solve developers problem which is having large applications that require change cycles to be tied together.
In a monolithic service-oriented architecture (SOA), each small change meant that the entire monolith needed to be rebuilt, then it takes alot of time and re-builds weren’t happening as rapidly as they should have.
In a microservices architecture, each microservice runs a unique process and usually manages its own database.It allows each service to be deployed, re-built, re-deployed and managed independently.
Examples of Microservices:
Netflix, eBay, Amazon, the UK Government Digital Service, realestate.com.au, Forward, Twitter, PayPal, Gilt, Bluemix, Soundcloud, The Guardian, and many other large-scale websites and applications have all evolved from monolithic to microservices architecture. Why?
Netflix has a widespread architecture that has evolved from monolithic to SOA. It receives more than one billion calls every day, from more than 800 different types of devices, to its streaming-video API. Each API call then prompts around five additional calls to the backend service.
Amazon has also migrated to microservices. They get countless calls from a variety of applications—including applications that manage the web service API as well as the website itself—which would have been simply impossible for their old, two-tiered architecture to handle. Amazon Started with a monolithic C++ application. Then services written in Java and Scala. Ending up with a set of polyglot microservices.
The auction site eBay is yet another example that has gone through the same transition. Their core application comprises several autonomous applications, with each one executing the business logic for different function areas. eBay started in 1995 as a monolithic Perl application. Then it moved to a monolithic C++ application which ended up with 3.4 million lines of code in a single DLL. Now the eBay has quite a bit of Java, but a polyglot set of microservices.
The API gateway in microservice architecture:
An API Gateway is a server that is the single entry point into the system. It handles incoming requests by sending subsequent requests to a number of microservices over a high-performance LAN, then returning an aggregated response to the consumer.
The only relation between different microservices is the data exchange accomplished through the APIs they expose.
Deployment of microservices:
There are several microservice deployment patterns like:
- Service Instance per Virtual Machine: this pattern package the service as a virtual machine image and deploy each service instance as a seperate VM.
- Service instance per container: this pattern package the service as a container image and deploys each service instance in its own container.
- Single Service Instance per Host: this pattern deploys each service instance in its own host.