

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: RDS: Relational Database Service
incomplete
2: Create a PostgreSQL Database
incomplete
3: Connect to Your Database
incomplete
4: Connect App to Database
incomplete
5: RDS Storage and IOPS
incomplete
6: RDS Backups
incomplete
7: Read Replicas
incomplete
8: Cleanup
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Think about how Discord or Slack works for a moment. There are chat channels filled with tons of users. Do you, as a user, read more or write more to the server?
Unless you're an incredibly chatty person, you're going to read waaaaaay more messages than you send. Wouldn't it be nice to offload those reads from an expensive primary database to a cheaper server?
Enter read replicas.
SELECT statements)INSERT, UPDATE, UPSERT, DELETE)Read replicas can lag behind the primary by a few seconds due to asynchronous replication. This is usually fine for most use cases, but if you need real-time consistency, you'll need to read from the primary.
Traffic is growing and the database is starting to sweat. Engineering wants to offload read traffic to a replica so the main DB can focus on writes.
Create a read replica (patientping-replica) from your existing patientping-db instance.
Cost check: Read replicas cost the same as the primary instance (given the same instance class). A db.t3.micro replica costs about $0.018 per hour (~$13 per month). We'll delete it after testing.
Once the replica status shows Available, check its domain name. You'll see that it's different from the primary DB.
Run and submit the CLI tests.
Your applications (or data analysts?) can connect to the read replica just like the primary database, but remember: it's read-only. Any write operations (INSERT, UPDATE, DELETE) will fail. Only SELECT queries will work.
For CLI users, create a read replica with the following command:
aws rds create-db-instance-read-replica --db-instance-identifier patientping-replica --source-db-instance-identifier patientping-db --db-instance-class db.t3.micro --vpc-security-group-ids YOUR-SG-ID --no-publicly-accessible