Tuesday, August 26, 2025

Amazon Aurora | Deep Dive.


Amazon Aurora - Deep Dive.

Scope:

  • Intro,
  • Key Features of Aurora,
  • Engine Compatibility,
  • Architecture,
  • Storage,
  • Performance,
  • High Availability Durability,
  • Scalability,
  • Security,
  • Backup & Recovery,
  • Advanced Features,
  • When to Use Aurora,
  • Aurora vs RDS (MySQL/Postgres),
  • Real-World Aurora Architecture Example🌍,
  • Architecture Components,
  • High-Level Flow,
  • Benefits of Aurora Global Setup,
  • Step by step hands-on setup for Aurora (Three scenarios) UI & CLI,
  • Aurora Cluster Setup (Primary DB),
  • Aurora Replicas (Scaling Reads),
  • Aurora Serverless v2 (Auto-Scaling Compute),
  • CLI / Terraform Sample setup,
  • Best Practices for Production.

Intro:

    • Amazon Aurora is a relational database service (RDS family) built by AWS.
      • Amazon Aurora is:
      • Cloud-native, 
      • Fully managed, 
      • MySQL/PostgreSQL-compatible.
    • Amazon Aurora is designed to combine the performance and availability of enterprise databases (like Oracle/SQL Server) with the simplicity and cost-effectiveness of open-source databases.

Key Features of Aurora

1. Engine Compatibility

    • Aurora MySQL-Compatible Edition: Works with MySQL drivers, tools, and code.
    • Aurora PostgreSQL-Compatible Edition: Works with PostgreSQL drivers, extensions, and code.

NB:

  • twtech can migrate existing MySQL/Postgres apps with minimal changes.

2. Architecture

Aurora is cloud-native and separates compute from storage:

  • Compute layer: DB instances that run the engine (MySQL or PostgreSQL).
  • Storage layer: Distributed, fault-tolerant, auto-healing storage system.
    • Data is automatically replicated 6 ways across 3 AZs (2 copies per AZ).
    • Continuous backups to Amazon S3.
    • No need to manage storage RAID or replication manually.

3. Storage

  • Starts at 10 GB and auto-scales up to 128 TB per database cluster.
  • Storage auto-heals — bad blocks/data are fixed automatically.

4. Performance

  • Up to 5x faster than MySQL and 3x faster than PostgreSQL on same hardware.
  • Designed for low-latency, high-throughput workloads.
  • Uses parallel query processing (Aurora Parallel Query) to push certain queries down to the storage layer for faster execution.

5. High Availability & Durability

  • Replication across 3 AZs automatically.
  • Failover typically happens in <30 seconds.
  • Supports Aurora Replicas (up to 15 read replicas) to offload read traffic.
  • Global Database: Replicates twtech database across AWS regions with <1 second lag — great for global apps.

6. Scalability

  • Compute: Add/remove DB instances to scale reads/writes.
  • Storage: Auto-scales independently of compute.
  • Aurora Serverless v2: Auto-scales database compute capacity (per second billing)
  • Perfect for unpredictable workloads.

7. Security

  • Encryption at rest using KMS.
  • Encryption in transit using SSL/TLS.
  • IAM integration for fine-grained access.
  • VPC isolation for networking (the practice of creating a secure, logically isolated network environment within a public cloud)

8. Backup & Recovery

  • Continuous backup to Amazon S3.
  • Point-in-time recovery (like rewinding your DB to a specific second).
  • Snapshots for manual backups.

9. Advanced Features

  • Aurora Multi-Master (write scaling across multiple AZs).
  • Aurora Global Database (cross-region replication).
  • Aurora Serverless v2 (on-demand scaling).
  • Aurora ML (integrates with Amazon SageMaker & Comprehend for in-database ML inference).

When to Use Aurora

Aurora is a great fit when twtech needs:

  • Enterprise-level performance but at a fraction of Oracle/SQL Server cost.
  • High availability and disaster recovery built-in.
  • Auto-scaling storage without downtime.
  • Global apps requiring multi-region replication.
  • Serverless database capacity for variable workloads.

 Aurora vs RDS (MySQL/Postgres)

Feature

RDS (MySQL/Postgres)

Aurora

Performance

Good (vanilla engine)

3–5x faster

Storage scaling

Manual

Auto (up to 128 TB)

Replication

Up to 5 replicas, same AZ/region

Up to 15 replicas, cross-AZ + Global

Failover

1–2 minutes

~30 seconds

Cost

Cheaper for small workloads

Slightly higher, but better $/performance

Serverless

Only Aurora Serverless

✅ Available

Real-world production architecture where Amazon Aurora powers a global, high-traffic application. (Real-World Aurora Architecture Example🌍)

Use Case: 

    • Global E-Commerce Platform
    • Think of Amazon Aurora like: Amazon.com (an online store) serving millions of users worldwide.

 Architecture Components

1. Aurora Global Database (Core Database Layer)

  • Primary Region (e.g., us-east-2)
    • Aurora cluster with 1 writer + multiple Aurora Replicas (for reads).
    • Storage auto-scales up to 128 TB.
    • Write throughput optimized by Aurora’s storage engine.
  • Secondary Regions (e.g., eu-west-1, ap-southeast-1)
    • Aurora Global Database replicas with <1 second replication lag.
    • Local reads served from replicas faster performance for EU/Asia customers.
    • Failover option: if the primary region goes down, promote a secondary to primary.

2. Application Layer

  • Microservices (deployed on Amazon EKS or ECS Fargate) connect to Aurora.
  • Services split by function:
    • Orders Service (writes Aurora writer)
    • Catalog Service (reads Aurora replicas)
    • User Profiles Service (reads/writes Aurora writer + cached in DynamoDB/ElastiCache)

3. Read/Write Splitting

  • Aurora provides a cluster endpoint (writer) and reader endpoint (load-balanced replicas).
  • Application uses:
    • Writer endpoint All inserts/updates.
    • Reader endpoint High-volume queries like product browsing, search results, reporting.

4. Caching Layer

  • Amazon ElastiCache (Redis) sits in front of Aurora for hot data (product details, pricing).
  • Reduces read load on Aurora by 70–80%.

5. Analytics Layer

  • Aurora Read Replicas feed into Amazon Redshift or Athena for reporting/BI.
  • Parallel query offloading helps with ad-hoc analytics without slowing OLTP traffic.

6. Resilience & Scaling

  • Aurora Serverless v2 used for bursty workloads (e.g., flash sales like Black Friday).
  • Auto-scaling Aurora Replicas handle global spikes in read traffic.
  • Multi-AZ replication ensures <30s failover.

7. Security & Compliance

  • IAM-based auth for apps.
  • KMS encryption at rest + TLS in transit.
  • Audit logs CloudWatch + S3 + Security Hub.

 High-Level Flow

  1. User in Europehits CloudFront + ALB routed to EU app servers.
  2. App queries Aurora Global Database replica in EU (fast reads).
  3. Writes (like checkout) forwarded to Primary Aurora Writer in US.
  4. Data replicated back to EU region in <1s.
  5. Cache layer (Redis) absorbs frequent queries less DB load.

 Benefits of Aurora Global Setup

  • Global performance: Users everywhere get low-latency reads.
  • High availability: Failover between regions within minutes.
  • Elastic scalability: Auto-scaled reads/writes during seasonal spikes.
  • Cost efficiency: Mix of Aurora Serverless + provisioned DB instances.
  • Data integrity: Strong consistency for writes, near real-time replication.

Step by step hands-on setup for Aurora (Three scenarios):

  1. Aurora Cluster (basic setup)
  2. Aurora Replicas (read scaling & HA)
  3. Aurora Serverless v2 (auto-scaling compute)

 1. Aurora Cluster Setup (Primary DB)

Using AWS Console

  1. Go to RDS Databases Create Database.
  2. Choose Amazon Aurora.
  3. Select Engine type:
    • Aurora MySQL-Compatible, or
    • Aurora PostgreSQL-Compatible.
  4. Choose Standard Create.
  5. Pick Aurora provisioned cluster (default).
  6. Configure:
    • DB cluster identifier: aurora-prod-cluster
    • Master username/password.
    • Instance type (e.g., db.r6g.large).
    • Multi-AZ deployment = enabled (for HA).
  7. Storage:
    • Aurora auto-scales storage, so no manual size needed.
  8. Connectivity:
    • VPC, subnets, security groups.
    • Ensure port 3306 (MySQL) or 5432 (Postgres) open to app servers.
  9. Create cluster.

Result: twtech gets one writer instance and cluster endpoints:

  • Cluster endpoint Always points to the writer.
  • Reader endpoint Load-balances read replicas (once added).

 2. Aurora Replicas (Scaling Reads)

Using AWS Console

  1. Go to Aurora cluster.
  2. Choose Add Reader.
  3. Pick DB instance type (same as or smaller than writer).
  4. Select AZ (different AZ for redundancy).
  5. Create.

Now twtech should have:

  • Writer endpoint for INSERT/UPDATE/DELETE.
  • Reader endpoint for SELECT queries (auto-load-balanced across replicas).

 With Up to 15 Aurora Replicas per cluster.

 3. Aurora Serverless v2 (Auto-Scaling Compute)

NB:

  • Aurora Serverless v2 allows twtech DB to scale per second from min max ACUs (Aurora Capacity Units).

Using AWS Console

  1. In the Create Database wizard, select Aurora Serverless v2.
  2. Set capacity range (e.g., 0.5 ACU to 64 ACUs).
    • 1 ACU 2 GB RAM + equivalent CPU.
  3. No need to pick instance size — it scales automatically.
  4. Deploy inside your VPC.

Benefits:

  • Perfect for unpredictable or spiky workloads.
  • Pay only for what twtech uses (per-second billing).

 4. CLI / Terraform Sample

# AWS CLI – Create Aurora Cluster

# bash

aws rds create-db-cluster \

  --db-cluster-identifier aurora-cluster \

  --engine aurora-mysql \

  --master-username twtech-user-pat \

  --master-user-password twtech-SecretPass123 \

  --engine-version 8.0.mysql_aurora.3.04.2 \

  --db-subnet-group-name twtech-subnet-group \

  --vpc-security-group-ids sg-12345678

# Add a Writer Instance

# bash

aws rds create-db-instance \

  --db-instance-identifier aurora-writer \

  --db-cluster-identifier aurora-cluster \

  --engine aurora-mysql \

  --db-instance-class db.r6g.large

# Add a Reader Instance

# bash

aws rds create-db-instance \

  --db-instance-identifier aurora-reader-1 \

  --db-cluster-identifier aurora-cluster \

  --engine aurora-mysql \

  --db-instance-class db.r6g.large \

  --promotion-tier 15 

 Best Practices for Production:

    • Always enable Multi-AZ for HA (high Availability).
    • Use IAM Auth instead of static DB passwords.
    • Direct writes to writer endpoint, reads to reader endpoint.
    • Enable Performance Insights to monitor queries.
    • Combine Amazon Aurora with ElastiCache for hot read data.




No comments:

Post a Comment

Amazon EventBridge | Overview.

Amazon EventBridge - Overview. Scope: Intro, Core Concepts, Key Benefits, Link to official documentation, Insights. Intro: Amazon EventBridg...