4 minutes read

POSTED Dec, 2020 dot IN Distributed Tracing

Microservices on AWS: An In-Depth Look

Ismail Egilmez

Written by Ismail Egilmez

Business Development Manager @Thundra


Microservices are a development and organizational pattern in which software is organized into small, independent services that interact through well-defined APIs. Each service is typically owned by a small, independent team.

Amazon Web Services (AWS) is widely used to implement applications powered by microservices. It offers a variety of services and solutions that can support microservice applications across the following categories:

  • Compute: Microservices can be deployed as containers on Amazon Elastic Container Service (Amazon ECS) or Elastic Kubernetes Service (EKS), and via the AWS Serverless ecosystem, primarily AWS Lambda.

  • Storage: Microservices typically store data securely using Amazon Simple Storage Service (S3) and ElastiCache.

  • Networking: Microservices can use Amazon ECS Service Discovery and AWS App Mesh for communication and coordination, AWS Elastic Load Balancing for dynamic traffic routing, and Amazon API Gateway for API management.

  • Databases: Microservices can rely on managed, relational database services via Amazon RDS, or cloud-native databases—such as Amazon Aurora and DynamoDB.

  • Monitoring: Microservices can monitor API traffic via AWS CloudTrail, and can monitor infrastructure with Amazon CloudWatch.

  • Messaging: Microservices can perform message queueing via Simple Queue Service (SQS) and can use Simple Notification Service (Amazon SNS) for notifications.

  • CI/CD: Amazon supports CI/CD workflows in a microservices environment using the Amazon Elastic Container Registry (ECR), AWS CodeCommit, and AWS CloudFormation.

Microservices Architecture on AWS

Traditionally, developers built applications with multiple layers, including one layer for user interface (UI), one for business, and another for persistence. A microservices architecture, on the other hand, separates software by functionality, rather than by technological tiers. This ensures that each component is a self-sufficient unit that performs a specific function.

Typical customer-facing application with microservices on AWS

Figure 1: Typical customer-facing application with microservices on AWS

User Interface

The majority of current web applications are built with JavaScript frameworks as single page applications that communicate using representational state transfer (REST) or RESTful APIs. To host static web content, AWS offers S3 and Amazon CloudFront.


AWS provides building blocks to support microservices development. Three common approaches are running serverless functions via AWS Lambda, running Docker containers in a serverless model via AWS Fargate, and running managed Kubernetes clusters on AWS.

With AWS Lambda, you can load code, run it in production, measure performance, and adapt to real demand without any configuration or management of the infrastructure. Lambda can be accessed from other AWS services and can be used with a wide range of programming languages and trigger events from either mobile or web apps.

Fargate is a container management service by AWS; it’s often used for running serverless containers and eliminating the need to provision, configure, or scale a cluster of virtual machines. You can also manage Enterprise Kubernetes deployments on AWS using the Elastic Kubernetes Service (EKS).

Data Storage

Microservices need to persist data, and do so in a way that supports scalability and prevents central dependencies.

AWS enables storage of shared session data using in-memory caches like Memcached or Redis. These two technologies are offered as part of the ElastiCache managed service. A common mechanism is to insert a cache between the application server and the database to offload database reads. As a result, caching also improves latency.

Relational databases can help you store structured data and objects for microservices. Many microservice applications use AWS database services, such as Amazon’s RDS, which is compatible with Microsoft SQL Server, Oracle, MySQL, MariaDB, and PostgreSQL. It is also compatible with pure play and cloud-native databases, like Amazon Aurora.

NoSQL is an alternative way to ensure database scalability, performance, and availability through consistency. AWS NoSQL services include DynamoDB, DocumentDB, and the Amazon Neptune graph database.

Implementing Microservices on AWS

You can reduce operational complexity and implement a microsystem architecture using the following three key AWS services:

  • API management: AWS API Gateway lets you create and run RESTful APIs without having to manage a server. It acts as a gateway for web or mobile apps hosted on Amazon and other on-premises or cloud infrastructures, and also improves security of microservice applications.

  • Lambda functions: AWS Lambda and the API gateway work together as synchronous requests come to the application. This enables serverless microservice applications.

  • Deploy Lambda-based apps: Use AWS CloudFormation to define, deploy and manage your serverless applications. AWS SAM CLI lets you start AWS serverless runtime on a local machine and test the code before deploying to the AWS production environment.

Cross-Service Considerations

The most common challenge with microservices is helping them discover other microservices, identify their health, advertise their own capabilities, and connect. AWS provides tools and features to help your microservices connect and coordinate with each other.

  • Service discovery: There are several common strategies for service discovery, including DNS, specialized software like Consul and Eureka, or service mesh products, including AWS App Mesh.

  • State management and orchestration: With a large number of microservices, managing state becomes a challenge. AWS provides Step Functions, a built-in feature in its serverless infrastructure, which helps compose applications from multiple decoupled components. Step Functions makes it easier for services based on tools like Amazon SageMaker, Glue, Lambda, EC2, and ECS to work together. An alternative approach is using specialized tools, like Terraform.

  • Security: Beyond native AWS services, the complexity of security concerns is driving the growth of commercial cloud-native security offerings. You can use Amazon API Gateway to protect microservice applications. It supports authentication and authorization across all microservices, provides a permissions framework for microservices, and supports API throttling. Amazon Cognito, which integrates with API Gateway, can also be used for user management, authentication, and authorization using JSON Web Tokens to be sold and directly integrated with API Gateway.

  • Data management: Monolithic applications are often built using centralized relational databases. However, doing so will render microservices unable to scale. Since microservices perform many different functions, sometimes with overlap between them, there is a need for control logic, data cleanups, and methods to avoid duplication.

  • Communication and messaging: Microservices send messages to each other. This can be achieved via networking, or, to improve reliability, via asynchronous messaging tools supporting publish/subscribe patterns, like Kafka or Amazon SNS.

  • Decentralized monitoring: With many microservices that can be individually scaled, monitoring becomes a challenge. Amazon CloudWatch enables managed monitoring of microservice applications. To gain additional monitoring capabilities, a popular choice is Prometheus with Grafana.

  • Chattiness: When a large number of microservices communicate with each other, there can be a very high message load. Service consolidation is not always the best way to avoid chattiness. Light, text-based protocols, such as YAML, or binary formats like Avro, can solve this problem. Another approach is to use persistent caching via solutions like Amazon ElastiCache.

Microservices on AWS with Thundra

Today’s applications are more distributed and event-driven than ever, easily causing cascading failures that are difficult to spot. Thundra helps you understand if the failure is rooted in the code you wrote or the service you use with distributed tracing. It also lets you dive deep into the problem by setting tracepoints into your code that take snapshots from production applications with zero overhead. Finally, Thundra integrates production debugging with distributed tracing, reducing the troubleshooting time from hours to minutes.

Maintaining the health of microservices on AWS has become a defining challenge in modern applications. By composing distributed tracing and production debugging, Thundra provides best-in-class troubleshooting for microservices on AWS. Get started with Thundra today.