• The CI/CD Guy
  • Posts
  • #2 Cloud Architectures Uncovered — Chat System: Services Deep Dive — Part 1

#2 Cloud Architectures Uncovered — Chat System: Services Deep Dive — Part 1

In our previous post, we outlined the high-level architecture of our scalable chat system. In this post, we take a deeper look at three of the AWS services that contribute to its operation.

  1. AWS EKS — Container orchestration at scale

  2. AWS MSK — Fully managed Kafka for distributed event streaming

  3. AWS Pinpoint — Multi-channel user engagement and messaging

A quick recap of the flow:

When a user comes online, their inbox gets displayed by fetching it from AWS Aurora and saving it in Elastic cache for Redis for further retrievals.

Once a user enters a chat window, a WebSocket connection for the user is established, on which the user’s message is sent.

The WebSocket service, hosted on EKS performs some validations, authentication, and authorisation, and then forwards the request to the chat microservice, which persists the data in DynamoDB and AWS Aurora.

Based on the recipient’s availability, it either sends the message directly on the recipient’s WebSocket connection or invokes AWS Pinpoint to send a notification to the user.

Message events are also published to AWS MSK at the same time.

Let’s look at all of these services in a bit more detailed manner:

These services are not detailed in any particular order, so feel free to skip any service you are not interested in and jump directly to your area of interest.

AWS EKS(Elastic Kubernetes Service)

It’s a managed Kubernetes service that relieves customers from the operational overhead of provisioning and managing a K8s cluster.
K8s is ideal for running containerised workloads, used extensively to host microservice architecture-based applications.

Explore the infographic cards below for a concise, visual breakdown of the Amazon EKS service

In our architecture, we are using EKS to host our chat application microservices. Let’s quickly see two of these services:
1. Rest and Websocket API service
2. Chat and Notification service

Rest and Websocket API service:

This service is like a gateway for all the user interactions. It will host all the REST and WebSocket endpoints.
A user opening an inbox, or checking some account or profile information, will interact using REST endpoints, while tasks like sending and receiving messages happen via WebSockets.

Chat and Notification Service:

This service is the brain for our application, as this will host all the routing, persistence, and delivery logics. It will interact with various services in our architecture, like AWS Pinpoint, Elastic cache for Redis, Dynamodb and AWS MSK.

AWS MSK(Managed Kafka Service)

It is a managed Kafka Service provided by AWS. Kafka is a distributed event streaming platform which supports both:

  • Pub/Sub (one-to-many) — multiple consumers can subscribe to the same topic, and each will get a copy of the message

  • Competing consumer (one-to-one) behavior — if multiple consumers are part of the same consumer group, each message is delivered to only one consumer within that group (this mimics a traditional message queue like SQS).

Kafka architecture is complex and needs an infrastructure setup. It requires setting up:

  • Brokers: Nodes that receive and store messages.

  • Topics: Logical channels that producers write to and consumers read from.

  • Partitions: Each topic is split into partitions across brokers for scalability.

  • Zookeeper (pre-Kafka 2.8): Used for managing cluster state (note: Kafka now supports KRaft, a built-in replacement for Zookeeper).

Additional components:

  • Kafka Connect: For integrating Kafka with external systems (e.g., databases, S3).

  • Kafka Streams / ksqlDB: For stream processing and transformations.

AWS MSK abstracts away the heavy lifting of provisioning and managing this infrastructure, and provides additional support for Automatic patching and backups, and integrating with other AWS services.

In our setup, Kafka is used in a pub-sub model, where every message sent by a user is forwarded to Kafka on a particular topic by our Chat microservice(acts as a Kafka producer).
Multiple consumers are listening to the topic, which retrieves the messages and performs various tasks like profanity filter, fraud detection, analytics, etc.

AWS Pinpoint

Amazon Pinpoint is an AWS service that you can use to engage with your customers across multiple messaging channels. You can use Amazon Pinpoint to send push notifications, emails, SMS text messages, or voice messages.

In our architecture, this service is used to send push notifications to the users, when they recieve any message when offline.

📌 Stay tuned for Part 3, where we’ll explore the data layer of our architecture:

  • Amazon ElastiCache (Redis)

  • Amazon DynamoDB

  • Amazon Aurora