Skip to main content

Reactive Systems on AWS

Reactive Systems on AWS
AWS Whitepaper

Introduction

Microservice application requirements have changed dramatically in recent years. Many modern applications are expected to handle petabytes of data, require close to 100% uptime, and deliver sub-second response time to users. Typical N-tier applications can’t deliver on these requirements. Today reactive architectures and reactive systems have been adopted by a growing number of enterprises, because it is necessary to design applications in a highly scalable and responsive way. But what exactly is a reactive system?

The Reactive Manifesto, describes the essential characteristics of reactive systems including: responsiveness, resiliency, elasticity, and being message driven.

Being message driven is perhaps the most important characteristic of reactive systems. Asynchronous messaging helps in the design of loosely coupled systems, which is a key factor for scalability. In order to build highly resilient systems, it is important to isolate services from each other. Microservices are an architectural and organizational approach to software development where software is composed of small independent services that communicate over well-defined APIs. These services are owned by small, self-contained teams. Isolation and decoupling are an important aspect of the microservices pattern as well. This makes reactive systems and microservices a natural fit.

Characteristics of reactive systems

Responsive

Resilient

Elastic

Message driven

Observability and tracing

Reactive programming and reactive streams

Typical use-cases for reactive systems

In the previous section, the essential characteristics of reactive systems was outlined. What do typical use cases for reactive systems have in common? Potentially millions of messages flow into the backend system. The impact of this requirement is a backend system that is able to quickly scale out and is resilient.

Advertising technology (Ad tech) face an interesting challenge to collect or track a lot of information. Usually this is a tracking pixel on a website that ingests data into a system. Depending on the campaign and its success, the amount of data that needs to be collected and transformed may significantly vary and is not always predictable. The following sections take a closer look at an example implementation for a tracking system for ads.

For eCommerce, it’s a similar situation: if a product goes viral on social media or an advertising campaign is surprisingly successful, a lot of people will visit the eCommerce website and order products.

For IoT, you need to be able to manage millions of connected devices that produce a huge amount of sensor data. This data needs to be collected, stored, and analyzed. Often it is necessary to send additional data back to the connected devices to update the status. The complete system has to be responsive in order to deliver feedback to users or trigger changes in the devices or machines within a short span of time.

Example architecture

The reactive manifesto and AWS services

The following section focuses on how to map compute and messaging services to the four principles of the reactive manifesto. This section only focuses on a limited set of services which are also used in the example implementation examined in the last chapter.

Topics

Service introduction

Amazon ECS

Amazon Elastic Container Service (Amazon ECS) is a fully managed container orchestration service. It is a shared state, optimistic concurrency system that provides flexible scheduling capabilities for your tasks and containers. In the reference architecture, Amazon ECS with AWS Fargate is used to run the main application which is implemented using Java. One of the objectives in the development of the application was to keep the latency as low as possible, because in this part increased latency has a negative impact on the conversion rate. For this particular use case, it’s recommended to use Amazon ECS instead of AWS Lambda. If the different components of the application were split into individual Lambda functions and these were orchestrated with AWS Step Functions, this would have a negative impact on latency, which is not a problem for many use cases, but in this particular case, keeping latency as low as possible is a very important aspect of the overall application.

Amazon EKS

Amazon Elastic Kubernetes Service (Amazon EKS) gives you the flexibility to start, run, and scale Kubernetes applications in the AWS Cloud or on-premises. Amazon EKS helps you provide highly-available and secure clusters and automates key tasks such as patching, node provisioning, and updates. Amazon EKS was not used for the implementation of the sample architecture; however, it is possible to use Amazon EKS instead of Amazon ECS.

AWS Lambda

AWS Lambda is a serverless compute service that lets you run code without provisioning or managing servers, creating workload-aware cluster scaling logic, maintaining event integrations, or managing runtimes. With Lambda, you can run code for virtually any type of application or backend service - all with zero administration. AWS Lambda's role in the example architecture is to receive messages from the Amazon Kinesis Data Stream, which is very low implementation overhead. Lambda integrates natively with Kinesis Data Streams. The polling, checkpointing, and error handling complexities are abstracted when using this integration. This allows the Lambda function code to focus on business logic processing.

Amazon Kinesis Data Streams

Amazon Kinesis Data Streams is a massively scalable and durable real-time data streaming service. In this architecture, Kinesis Data Streams is used to decouple key application components, such as processing incoming data and persisting the enriched data in Amazon DynamoDB. This split is possible because the writing of the data can be done asynchronously, while the response to the requesting client should happen as quickly as possible.

Amazon ElastiCache

Amazon ElastiCache offers a fully managed in-memory data store, compatible with Redis or Memcached that enables you to power real-time applications with sub-millisecond latency. The service can scale-out, scale-in, and scale-up to meet fluctuating application demands. Write and memory scaling is supported with sharding. In this architecture, Redis is used in two different ways: source for core data, and pub/sub implementation to actively update the L1-cache in the main application.

Amazon DynamoDB

Amazon DynamoDB is a key-value and document database that delivers single-digit millisecond performance at any scale. It is a fully managed database with scalability and high availability built in. DynamoDB is used in this architecture as the central repository for the result data, since DynamoDB is fully managed, multi-region, multi-active, durable database for internet-scale applications.