We’ve all heard the terms crop up in conversation: monoliths and microservices. But, what exactly do they mean? And how exactly do we ‘break up the monolith’?
In this post we’ll explore the differences between monolithic- and microservices-based applications and highlight some of the benefits of Amazon microservices.
We’ll also explore what services AWS has available to help you to build out a microservices-architected application on the AWS cloud.
Microservices Basics: What are Microservices?
Microservices (or microservices architecture) is a service-oriented architecture—a way of building software applications that are broken down into smaller, independent and composable service units that function together to deliver the overall functionality of the application.
Each microservice (or component), is continuously developed and maintained separately from the other microservices.
Microservices are often connected together via RESTful APIs, so they have access to a broad range of tools and solutions from the extensive web services ecosystem.
What Is the Difference Between Microservices and APIs?
While microservices and APIs (Application Programming Interfaces) are related concepts, they are not the same thing. This can sometimes lead to confusion, so let’s clear that up now.
Microservices is an approach to building an application as a collection of independent services or components. On the other hand, APIs are a set of protocols and tools that enable communication between software applications, including microservices.
Monolith vs. Microservices
In contrast to microservices, which are deployed as independent, self-contained services, web services are typically built as monolithic applications. All of the application’s software components are tightly coupled in a single package and run as a single service.
If we use an e-commerce website as an example application, you can imagine the different functions of the site might include the user interface, product catalogue, search functionality, payment gateway and a recommendation engine.
Delivered as a monolithic application, these components would all be in a single package, deployed on a single server. If the e-commerce site gets busy, say during Black Friday sales, the only way to scale would be to add more servers, regardless of which part of the application is experiencing the most load.
Using the same example, with each component delivered as a microservice, each component could be individually scaled based on which particular part of the application is experiencing the most demand.
For example, at the start of the sale the user interface would be the first component to be affected, before any stress reaches the payment gateway, so this component could be scaled independently of the other components.
|Single code base for all application components and business functions||Each component is as small as it can be, and delivers a specific business function|
|Slower Service Startup||Fast Service Startup|
|Tightly Coupled - changes to one component may affect others||Loosely coupled - changes to one component do not affect others|
|Faults not isolated - failure of one component can bring entire system down||Faults are isolated - failure of one component does not bring entire system down|
|Scaling is challenging and wasteful - lots of over-provisioned resources||Only the busy component needs to be scaled, making more efficient use of resources|
|Large development team, difficult to manage||Small, focused two-pizza teams able to iterate faster|
|Centralized data management||Decentralized data management|
|Single code base for entire application||Different microservices can use different code bases|
So, now that we understand some of the differences between monoliths and microservices, let’s take a look at some of the key benefits of microservices.
- Simpler and Faster to Deploy: microservices enable the deployment of individual application components without affecting other services.
- Simpler to Understand: it is easier for developers to follow microservices code, as the code of the component is isolated and has fewer dependencies on other parts of the application.
- Developer Independence: smaller, two-pizza teams working on a single application component can iterate faster than a large team working on a monolithic app.
- Isolation and Resilience: if one microservice fails, it is easy to spin up another while the rest of the application continues to function.
- Scalability: if a particular component of the application is more in demand than other components, it can be scaled independently.
- Reusability: application components can be shared with and re-used by other applications across the business, speeding up the development process for those apps.
- Lifecycle Automation: individual components are easier to manage in a Continuous Integration/Continuous Delivery (CI/CD) environment.
- Minimized Risk: given the flexibility over language and platform selection, microservices help businesses avoid technology vendor or language lock in.
Microservices Use Cases
Now that we’ve looked at some of the benefits of microservices, let’s take a look at some of the more compelling use cases for decoupling an application into a microservices architecture.
- Extensive Data Pipelines: one example of an extensive data pipeline would be a reporting system on retail store sales. Every step in the data preparation process could be handled by a microservice—data collection, cleansing, normalization, enrichment, aggregation, reporting and so on.
Because the microservices workflow is easily traceable, it would be easy to figure out which microservice needs to be updated in the event that there are any problems identified with the data.
- CPU or RAM-Intensive Application Components: it is easy to spawn multiple instances of a CPU-intensive microservice on demand, without starving the rest of the application of CPU power. Text analysis tools that consume a lot of RAM can be problematic to redeploy and restart—if they rarely change it makes sense to separate them out.
- Machine Learning: a microservices-based machine learning environment can collect, aggregate and analyze data flow so that the machine learning framework can calculate an outcome. In such an ML environment, the data has to run through many steps before an outcome is reached.
One advantage of using microservices is that different machine learning models can be applied to the same data to produce a more accurate outcome.
Scaling technology resources to meet peaks in application demand is always challenging. Scaling of microservices environments is not necessarily easier, it just presents a different challenge.
In a traditional monolithic application, scaling is achieved by running multiple copies of the application on multiple servers and load balancing between them.
In a microservices environment, scaling is achieved by scaling the individual components. But, there is an added level of complexity when scaling microservices in that they are communicating with other services, which may be written in different code bases or hosted on different platforms.
When demand for the application increases, all components have to be coordinated to scale appropriately to handle the increased demand.
Use of an application proxy or application delivery controller is advisable—this can help to identify performance issues with the application and can automate scaling of the appropriate components.
An appropriate Application Performance Management tool should also be deployed to enable end-to-end tracing of the application, which will help developers to quickly identify which microservice is responsible for any application performance degradation.
AWS Microservices Architecture
AWS offers ‘the most complete platform for Microservices‘. The AWS service portfolio offers a broad range of easily integrated building blocks to enable delivery of any application at any scale. Let’s take a look at what’s available:
- Amazon Elastic Container Service: containers are widely regarded as the compute platform of choice for delivering microservices. ECS is a highly scalable, high-performance container management system that enables AWS customers to run their applications in Docker containers on a managed Amazon EC2 cluster.
- AWS Lambda: Lambda is the AWS serverless offering, which enables AWS customers to upload and run application code without provisioning servers. Users simply upload their code and Lambda takes care of running, scaling and high availability.
Users only pay for compute while their code is running, so a website hosted on Lambda with no visitors can effectively be hosted for free! This is a great commercial model for startups with limited budget and no legacy code to worry about.
Even better, development teams no longer have to decide between serverless vs. microservices. When the situation calls for it, they can have both with Lambda.
Storage and Databases
- Amazon DynamoDB: DynamoDB is the AWS NoSQL database, offering consistent, single-digit millisecond latency at any scale.
- Amazon ElastiCache: ElastiCache improves microservice performance by enabling customers to retrieve data from fast in-memory caches, rather than from slower disk-based databases.
- Amazon S3: S3 provides durable, highly scalable and secure object storage.
- Amazon RDS: RDS makes it easy to set up, manage and scale a relational database. RDS supports Microsoft SQL, MySQL, PostgreSQL, Maria DB and Oracle.
- Amazon Aurora: Aurora is AWS’ own database engine, which offers the simplicity and cost-effectiveness of open source databases, with the performance of high-end commercial databases.
- AWS App Mesh: App Mesh enables standardized communication between microservices, making it easy to monitor and control microservices running on AWS.
- Application Load Balancer: ALB is a layer 7 load balancer enabling advanced HTTP and HTTPS request routing to microservices and containers.
- Network Load Balancer: NLB is a layer 4 load balancer operating at the IP level—NLB can handle massive network traffic, while ensuring low latency.
- Amazon API Gateway: API gateway enables applications to process thousands of concurrent API calls.
- Amazon Route 53: Route 53 is Amazon’s highly available and scalable DNS service.
- Amazon Simple Notification Service (SNS): SNS enables applications to push messages out to subscribers. For example: Mobile App notifications.
- Amazon Simple Queue Service (SQS): SQS is a fully-managed message queue service that enables the decoupling and scaling of microservices.
Logging and Monitoring
- AWS CloudTrail: CloudTrail continuously logs AWS account and API activity across a customer’s entire infrastructure, which simplifies security auditing and analysis.
- Amazon CloudWatch: Cloudwatch enables application and resource monitoring via the collection and tracking of key monitoring metrics.
- AWS X-Ray: X-Ray enables distributed tracing of serverless applications running on AWS Lambda.
- Amazon Elastic Container Registry (ECR): ECR is a fully-managed Docker container image repository, which facilitates the storage, management and deployment of containers on AWS.
- AWS Developer Tools: a set of services enabling Developers and IT operations teams to deliver software quickly and safely. The services enable secure storage and version control of app source code and enables customers to build, test and deploy their apps to AWS or on-premises infrastructure.
So, there you have it—the most comprehensive collection of services enabling customers to build out microservices architectures at any scale. If you’re interested in learning how to leverage any of these AWS services, take a look at our AWS Migration and AWS Managed Services pages.
Our team of certified AWS specialists is ready to talk to you about how Logicata can help you break down your monolith or help you to build out your new microservices application on AWS.