Home Uncategorized AWS RDS – Relational Database Service, Multi-AZ, Read...
Uncategorized

AWS RDS – Relational Database Service, Multi-AZ, Read Replicas, Backup: 20 Interview Questions

Amazon RDS (Relational Database Service) is a managed relational database service supporting MySQL, PostgreSQL, MariaDB, Oracle, and SQL Server. It automates infrastructure provisioning, patching, backups, and failover, enabling teams to focus on application development rather than database operations.

AWS RDS: Complete Overview

Amazon RDS is fully managed RDBMS service providing high availability, scalability, and security. Supports 5 database engines: MySQL, PostgreSQL, MariaDB, Oracle, and SQL Server. Automatic backups with point-in-time recovery (up to 35 days). Multi-AZ deployments provide automatic failover in <2 minutes. Read replicas enable horizontal scaling for read-heavy workloads across regions. Pricing: hourly rate for instance type + storage + backups. db.t3.micro: $0.017/hour (free tier), db.m5.large: $0.192/hour. Suitable for transactional workloads, web applications, ACID-compliant requirements.

RDS Core Features and Architecture

Single-AZ RDS: Single instance in one availability zone, cost-effective but single point of failure. Multi-AZ RDS: Primary + synchronous standby in different AZ, automatic failover <2 minutes, 99.95% uptime SLA, doubles cost. Read Replicas: Asynchronous replicas for read scaling, same/cross-region, each costs full instance price. Application routes writes to primary, reads distributed to replicas. Automated backups enable point-in-time recovery. Manual snapshots provide indefinite retention at $0.095/GB/month cost.

5 Complete Interview Questions with Solutions

Question 1: Design Multi-AZ RDS for E-commerce

10M users, 100k daily transactions, 24/7 analytics. Design: Multi-AZ, read replicas, backup strategy, cost optimization. Calculate monthly costs.

Configuration:
Primary: db.r5.2xlarge Multi-AZ (64GB, $3.07/hr each)
Replica 1: db.r5.xlarge same-region ($1.535/hr)
Replica 2: db.r5.large cross-region ($0.768/hr)
Storage: 1TB gp3 ($230/month)
Backups: 35-day retention ($95/month)

Costs:
Primary Multi-AZ: $3.07 * 2 * 730 = $4,482
Replica 1: $1,120
Replica 2: $561
Storage + Backups: $325
Total: $6,488/month

With Reserved (35% discount): $4,217/month
With Dedicated Hosts: $3,374/month

Explanation: Multi-AZ ensures 99.95% uptime. Read replicas scale reads. Cross-region replica provides DR. Reserved instances save 35%.

AWS – Database Architect

Question 2: Optimize RDS Query Performance

Dashboard query takes 30 seconds. Root cause: missing indexes, inefficient joins, slow replication lag. Use EXPLAIN ANALYZE, materialized views, caching.

— Before optimization (30 seconds)
SELECT u.id, COUNT(o.id) as orders, SUM(o.amount) as total
FROM users u LEFT JOIN orders o ON u.id = o.user_id
GROUP BY u.id ORDER BY total DESC LIMIT 100;

— EXPLAIN ANALYZE shows:
Seq Scan orders (50M rows) – PROBLEM!
NestedLoopJoin – SLOW!

— Fix 1: Add indexes
CREATE INDEX idx_orders_user_id ON orders(user_id);

— Fix 2: Materialized view
CREATE MATERIALIZED VIEW user_dashboard AS
SELECT u.id, COUNT(o.id), SUM(o.amount)
FROM users u LEFT JOIN orders o ON u.id = o.user_id
GROUP BY u.id;

— Result: 30 seconds -> 100ms (300x improvement!)

— Refresh daily
REFRESH MATERIALIZED VIEW user_dashboard;

Scroll to Top