AWS Builder Center

Amazon EKS: MySQL on Pod vs Amazon RDS — Stateful vs Stateless Architecture

Stateful vs Stateless Architecture

When building applications on Amazon EKS, one important architectural decision is where to run the database.
Should we run MySQL inside Kubernetes using a StatefulSet, or should we use Amazon RDS for MySQL?
Both approaches are possible, but they solve different problems.


🚀 1. Stateless vs Stateful

First, let's understand the difference.

Stateless Application

A stateless application does not depend on data stored inside its Pod.
Examples:
  • React frontend
  • Node.js API
  • Java Spring Boot
  • Python Flask
  • Nginx
For these workloads, Kubernetes  Deployment  is commonly used.
Users
↓
AWS Load Balancer
↓
Kubernetes Service
↓
API Pods
├── Pod 1
├── Pod 2
└── Pod 3
If one Pod crashes, Kubernetes creates another Pod.
The Pods are interchangeable.



🗄️ 2. MySQL on EKS using StatefulSet

MySQL is a stateful workload because the database needs persistent data.
A typical architecture looks like:
Users
↓
AWS Load Balancer
↓
Kubernetes Service
↓
Application Pods
↓
MySQL Headless Service
↓
MySQL StatefulSet
├── mysql-0 → PVC → EBS
├── mysql-1 → PVC → EBS
└── mysql-2 → PVC → EBS
Here we use a StatefulSet instead of a Deployment.
Why?
Because StatefulSet provides stable Pod identity and persistent storage association.
For example:
mysql-0
mysql-1
mysql-2
Each Pod can have its own PersistentVolumeClaim (PVC).
The storage can be backed by an AWS EBS volume.
mysql-0
↓
PVC
↓
EBS Volume
↓
MySQL Data
If  mysql-0  is recreated, Kubernetes can associate it with its persistent storage.



🌐 3. Which Service is used?

This is an important part of the architecture.
For the application:
api-service
Type: ClusterIP
The Service provides a stable internal endpoint for application Pods.
For StatefulSet database Pods, we commonly use a Headless Service:
clusterIP: None
For example:
mysql-headless
This allows stable DNS identities such as:
mysql-0.mysql-headless
mysql-1.mysql-headless
mysql-2.mysql-headless
So the architecture becomes:
AWS Load Balancer
↓
api-service
ClusterIP
↓
Application Pods
↓
mysql-headless
Headless Service
↓
mysql-0
↓
PVC
↓
EBS



☁️ 4. MySQL on Amazon RDS

The second approach is to keep the application in EKS but move the database to Amazon RDS for MySQL.
Users
↓
AWS Load Balancer
↓
Kubernetes Service
↓
Application Pods
↓
TCP 3306
↓
Amazon RDS for MySQL
In this architecture, Kubernetes manages the application.
AWS manages much of the database infrastructure.
RDS provides capabilities such as:
  • Automated backups
  • Multi-AZ deployment options
  • Monitoring
  • Database patching
  • Storage management
  • Automated maintenance
  • Managed failover capabilities
This significantly reduces operational work for the DevOps team.



⚔️ 5. MySQL on Pod vs RDS

Area
MySQL on EKS
Amazon RDS
Kubernetes object
StatefulSet
AWS managed service
Service
Headless Service
RDS endpoint
Storage
PVC + EBS
RDS managed storage
Pod management
You manage
AWS manages
Backups
You manage
AWS managed features
Patching
You manage
AWS managed
HA
You design/manage
Managed options
Customization
High
More limited
Operational effort
High
Lower
Production recommendation
Specific use cases
Usually preferred



🎯 6. Which one should you choose?

For most production applications, I would choose:
Amazon EKS
|
+---------+---------+
| |
Stateless Apps Services
| |
+---------+---------+
|
↓
Amazon RDS
MySQL
Why?
Because Kubernetes should focus on running the application workloads while a managed database service handles database operations.
However, running MySQL inside EKS can make sense when you need:
  • Full control over the database
  • Custom database configurations
  • Kubernetes-native database workflows
  • Isolated environments
  • Specialized testing/lab environments
  • A specific database operator or cluster architecture



💡 Final Takeaway

The key concept is simple:
Stateless application → Deployment + Service
Stateful application → StatefulSet + PVC + persistent storage
Managed database → EKS application + Amazon RDS
For example:
Frontend
↓
AWS Load Balancer
↓
Kubernetes Service
↓
Backend Deployment
↓
Backend Pods
↓
Amazon RDS MySQL
This architecture keeps the application scalable while reducing the operational burden of managing MySQL inside Kubernetes.
Understanding when to use StatefulSet and when to use a managed service like Amazon RDS is an important step toward designing production-ready applications on Amazon EKS.
#AWS #AWSCommunityBuilders #AmazonEKS #Kubernetes #DevOps #CloudComputing #AmazonRDS #MySQL #AWSArchitecture
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article