Answer Key: AlloyDB
Exercise 1: Design Architecture
Question: Design an AlloyDB architecture for a high-traffic application. How many read replicas? What's the failover strategy?
Answer
Goal: Design high-availability AlloyDB architecture.
Architecture
Primary Instance:
- Region: us-central1
- Machine Type: db-standard-8 (8 vCPU, 30GB RAM)
- High Availability: Enabled
Read Replicas:
- Replica 1: us-central1 (same zone as primary)
- Replica 2: us-east1 (different region)
- Replica 3: us-west1 (different region)
Failover Strategy: - Automatic failover (< 60 seconds) - Promote read replica to primary - Update application connection strings
Answer: Use 3 read replicas (1 same region, 2 different regions), enable automatic failover, design for < 60 second RTO.
Exercise 2: Handle Scaling
Question: Your application needs to scale reads. How do you scale with AlloyDB? What's the strategy?
Answer
Scaling strategies:
- Add Read Replicas: Add more read replicas for read scaling
- Connection Pooling: Use connection pooling for efficient connections
- Read-Write Splitting: Route reads to replicas, writes to primary
- Monitor Performance: Monitor replica lag and performance
Answer: Add read replicas for horizontal read scaling, use connection pooling, implement read-write splitting.
Exercise 3: Optimize Performance
Question: Your queries are slow. How do you optimize them? What AlloyDB features do you use?
Answer
Optimization strategies:
- Use Columnar Cache: Enable columnar cache for analytics
- Optimize Queries: Use appropriate indexes and query patterns
- Connection Pooling: Use connection pooling
- Monitor Performance: Monitor query performance and optimize
Answer: Enable columnar cache, optimize queries with indexes, use connection pooling, monitor and optimize continuously.