
Cloud
Learning Level
AWS RDS + Read Replicas (Cross-Region)
Primary DB (Region 1)
ā (Async replication)
Read Replica (Region 2)
Read Replica (Region 3)
Disaster Recovery Replica (Region 4)GCP Cloud SQL with HA + Backups
Primary Instance (Zone A)
ā (Sync HA)
Standby Instance (Zone B - auto failover)
Backup Storage (Multi-region)Azure SQL with Geo-Replication
Primary (Region 1)
ā (Async)
Secondary (Region 2 - readable)
Secondary (Region 3 - readable)AWS RDS - Performance Insights
-- Identify slow queries
SELECT digest_text, calls, mean_time
FROM performance_schema.events_statements_summary_by_digest
ORDER BY mean_time DESC
LIMIT 10;GCP Cloud SQL - Query Insights
Automatic collection of:
- Database CPU usage
- Query execution metrics
- Lock contention patternsAzure SQL - Query Performance Insight
DMV queries show:
- Top resource-consuming queries
- Wait statistics
- Execution plans-- Composite index for common queries
CREATE INDEX idx_user_status_created
ON users(status, created_at DESC);
-- Partial index for filtered queries
CREATE INDEX idx_active_users
ON users(id)
WHERE status = 'active';
-- Full text search index
CREATE FULLTEXT INDEX ON posts(content)AWS RDS Proxy
Application ā RDS Proxy (connection pool) ā RDS
- Multiplexing
- IAM authentication
- Failover handlingGCP Cloud SQL Auth Proxy
cloud_sql_proxy -instances=project:region:instance &Azure Connection Pooling
Application Pool ā Azure SQL
Built-in connection pooling
Min/Max connections configured// Shard key: user_id % 4 = shard number
function getShardId(userId) {
return userId % 4;
}
const shards = [
'db-shard-0.rds.amazonaws.com',
'db-shard-1.rds.amazonaws.com',
'db-shard-2.rds.amazonaws.com',
'db-shard-3.rds.amazonaws.com'
];
async function getUserData(userId) {
const shardIndex = getShardId(userId);
const shard = shards[shardIndex];
const connection = await mysql.createConnection({
host: shard,
user: 'admin',
password: process.env.DB_PASSWORD,
database: 'users'
});
return connection.execute(
'SELECT * FROM users WHERE id = ?',
[userId]
);
}// Cache hot data
const redis = require('redis');
const client = redis.createClient({
host: 'elasticache.amazonaws.com',
port: 6379
});
async function getUserWithCache(userId) {
// Try cache first
const cached = await client.get(`user:${userId}`);
if (cached) return JSON.parse(cached);
// Query database
const db = await getDatabase();
const user = await db.query('SELECT * FROM users WHERE id = ?', [userId]);
// Store in cache (24 hours)
await client.setex(`user:${userId}`, 86400, JSON.stringify(user));
return user;
}RTO (Recovery Time) | RPO (Data Loss)
AWS RDS:
- Regional failover: ~2 minutes
- Cross-region restore: ~30 minutes
- RPO: Seconds (Multi-AZ)
GCP Cloud SQL:
- HA failover: ~1 minute
- Backup restore: ~15 minutes
- RPO: Near-zero (HA)
Azure SQL:
- Failover: ~30 seconds
- Geo-restore: ~1 hour
- RPO: Depends on PITR retention# AWS: Automated backups + manual snapshots
aws rds create-db-snapshot \
--db-instance-identifier mydb \
--db-snapshot-identifier mydb-backup-$(date +%s)
# GCP: Point-in-time recovery enabled
gcloud sql backups create \
--instance my-instance \
--description "manual backup"
# Azure: Automatic retention + LTR
az sql db ltr-backup create \
--name "my-db" \
--server "my-server" \
--resource-group "my-rg"AWS RDS
At-rest: AWS KMS encryption
In-transit: SSL/TLS mandatoryGCP Cloud SQL
At-rest: Google Cloud KMS
In-transit: SSL/TLS with CMEKAzure SQL
At-rest: Transparent Data Encryption (TDE)
In-transit: TLS 1.2 minimum// AWS IAM Database Authentication
const AWS = require('aws-sdk');
const signer = new AWS.RDS.Signer({
region: 'us-east-1',
hostname: 'mydb.c9akciq32.us-east-1.rds.amazonaws.com',
port: 3306,
username: 'iamdbuser'
});
const token = signer.getAuthorizationHeader({
username: 'iamdbuser'
});
// Use token for connectionReserved Instances:
- 1-year: 30-35% discount
- 3-year: 50-55% discount
- Best for baseline capacity
On-demand:
- Pay per hour
- Full flexibility
Aurora (MySQL/PostgreSQL):
- Pay per GB stored + compute
- 25% cheaper than RDS for same workloadAWS:
- GP2 (default): $0.23/GB/mo
- IO1 (high I/O): $1.25/GB/mo + provisioned IOPS
GCP:
- Standard: $0.18/GB/mo
- SSD: $0.27/GB/mo
Azure:
- Standard: $0.12/GB/mo
- Premium: $0.23/GB/moData Transfer (out):
AWS: $0.02 per GB (first 10TB)
GCP: $0.12 per GB
Azure: $0.025 per GB
Optimization:
- Minimize cross-region queries
- Use caching for repeated reads
- Deploy in same region as computeCPU Utilization: Alert > 80%
Memory Utilization: Alert > 85%
IOPS: Alert > 80% of provisioned
Connections: Alert > 80% of max
Read Latency: Alert > 100ms
Write Latency: Alert > 10ms
Replication Lag: Alert > 5 seconds// CloudWatch metrics (AWS)
const cloudwatch = new AWS.CloudWatch();
await cloudwatch.putMetricData({
Namespace: 'MyApplication/Database',
MetricData: [{
MetricName: 'QueryLatency',
Value: elapsedTime,
Unit: 'Milliseconds',
Timestamp: new Date()
}]
}).promise();Source DB ā DMS ā Target DB
Supports:
- Homogeneous migrations (MySQL ā MySQL)
- Heterogeneous (Oracle ā PostgreSQL)
- Zero downtime (CDC)Source ā Validation ā GCP Target
Features:
- Schema conversion
- Data validation
- Minimal downtimeSource ā Online migration ā Azure SQL
- Transactional consistency
- Minimal downtime
- Database & schema migrationHigh-Traffic OLTP
ā AWS RDS with Read Replicas + ElastiCache + Sharding
Analytical Workloads
ā GCP BigQuery or AWS Redshift (data warehouse)
Real-time Applications
ā Firebase Realtime DB or GCP Firestore
Microsoft Stack
ā Azure SQL with Always On AG
Startup (Cost Sensitive)
ā GCP Cloud SQL with Postgres (most affordable)
Resources
Ojasa Mirai
Master AI-powered development skills through structured learning, real projects, and verified credentials. Whether you're upskilling your team or launching your career, we deliver the skills companies actually need.
Learn Deep ⢠Build Real ⢠Verify Skills ⢠Launch Forward