Microservices is a software development approach in which an application is a collection of services that are developed, deployed, and tested independently. These services are loosely coupled and communicate with each other using well-defined APIs. The services are small and easy to design and develop. The services together constitute one application. Amazon and Netflix were among the first few companies to adopt this development approach. The microservices have a significant advantage over a monolithic architecture in which the development activities are slow and very complicated.
A comparison of monolithic and microservices architecture.
Characteristics of microservices
Some essential characteristics of a microservices architecture are –
- Autonomy – The constituent services in a microservices architecture can be developed, deployed, and tested independently without affecting other services. The constituent services are operated and scaled independently.
- Decentralized – Microservices are decentralized, providing the developers with the luxury to develop component services using different stacks. There is no need to stick to a single stack to develop all the component services. Instead, the components can use independent languages, frameworks, and databases.
- Specialized – In a microservices architecture, each service specializes in one task. This approach not only helps in developing specialized and robust components but also helps in distributing the development of the applications based on business functionalities required.
- Scalable – The constituent services in a microservices architecture can be scaled easily and independently of any other service. Scaling one service doesn’t necessarily require scaling another.
- Easy Deployable – Microservices follow the principles of CI/CD (Continuous Integration/ Continuous Deployment). This allows us to innovate, experiment continuously, and develop new features and services into an existing application with ease.
- Agile – Microservices make it easy to reiterate over a small functionality in the code, and quickly obtain results, making the development process very agile.
- Easy Maintenance – The independent nature of the components in a microservice enables easy maintenance, bug fixes, and the addition of new features into the components as well as the application.
- Resilient – Microservice architectures are highly resilient to failure. Failure of one component does implicate the failure of other components.
Examples of microservices applications
Some of the companies using the microservices architecture are: –
How microservices complement cloud-native development
Microservices structures the application as a collection of loosely coupled services, which is beneficial for cloud-native development. The modularity of the application into services that interface with each other makes the application easily manageable. Most cloud vendors have infrastructure which is highly efficient and is specialized to manage a particular service or function. For example, a database service, or a compute engine or a queue service. Microservices architecture is the reason why these isolated cloud services have high demand. One can quickly build and deploy an application by breaking the application into multiple component services and then using efficient cloud infrastructure and services to deploy and manage those components.
A container is a mechanism of operating system virtualization which allows the abstraction of the environment in which a container-based application runs. The application’s code, libraries, and dependencies are packaged together to enable the application to run almost anywhere. Containers are portable and platform-independent.
Working on container-based applications.
Characteristics of containers
- Lightweight – Containers are lightweight as they do not boot up a complete operating system; also, the storage and memory need not be reserved in advance.
- Isolated – Containers isolate the application from the operating system and environment, and the application has its environment.
- Scalable – Containers are scalable and very efficient. Since they are lightweight and do not need to boot a complete OS, multiple copies of the container can run on each server. They are hence improving the scalability and efficiency very significantly.
- Reduced Overhead – Containers require very less overhead as all the libraries and dependencies of an application are packaged together, and it requires very few operating system resources.
- Portable – Container-based applications run on a wide variety of platforms and hardware without requiring any additional development.
- Consistent Operation – The applications behave and operate the same no matter what platform they are running on; hence the operation is very consistent.
- Agile – The development process with containers is very agile and flexible, accelerating production, and test cycles.
Container Services that are available on the cloud
- Amazon Elastic Container Service: Amazon Elastic Container Service (Amazon ECS) is amazon’s container management service that makes it easy to run, stop, and manage Docker containers on a cluster. Amazon ECS offers two launch types for your clusters the fargate (fully managed by amazon) launch type and the EC2 launch type(you get more control). Amazon ECS, along with other services like cloud formation, elastic load balancing, auto-scaling groups, IAM, and amazon container registry service.
- AWS Elastic Beanstalk – Amazon’s elastic Beanstalk is a fully managed service used for deploying web applications and services developed in Docker. Elastic Beanstalk automatically handles capacity provisioning, load balancing, auto-scaling, and application health monitoring.
- Azure Container Instances – Azure Container Instances (ACI) is a service that allows you to run containers on Azure without managing servers or infrastructure, making it simpler to build applications without focusing on infrastructure.
- Google Kubernetes Engine – Google Kubernetes Engine (GKE) is Google Cloud’s fully managed solution to manage and deploy containers via Kubernetes container orchestration service. You pay for the Google Compute Engine instances used, with no additional charges.
Serverless computing architecture is a cloud computing approach in which the cloud provider is responsible for allocating, provisioning, managing, and maintaining the back-end infrastructure. Serverless computing does not require the customers of the cloud to buy and provision resources. Instead, they are charged based on the number of execution of their functions, meaning that customers are only charged for the time their code executes on the server. This is enabled by a cloud computing model named “Function as a Service (FaaS).” Some of the cloud services for serverless computing are:
- AWS Lambda
- IBM OpenWhisk
- Azure Function
- Google Cloud Functions
The most popular among these is the AWS Lambda.
Typical architecture of a serverless web application.
Advantages of Serverless Computing
- Less Administration Overhead
- Reduced Management
- High Scalability
- Low Cost
- Rapid development
Disadvantages of Serverless Computing
- Reduced Control
- Available only in some programming languages
- Timeout and Memory Bottlenecks
- Architectural Complexity
- Multi-tenancy Problem
Read this similar column on what stateless microservices are and how they accelerate change.