Question #611
A developer is migrating a social media application to AWS to handle a surge in user traffic. The application currently runs on two servers: one for the web application and another for a PostgreSQL database. The web server handles user sessions in-memory, and during peak traffic, memory usage spikes, causing performance issues. The developer plans to use Amazon EC2 instances in an Auto Scaling group behind an Application Load Balancer.
Which combination of changes should the developer implement to optimize performance and scalability?
Migrate the PostgreSQL database to an EC2 instance. Store session data and application data in the PostgreSQL database.
Use Amazon ElastiCache for Redis to manage session data. Migrate the PostgreSQL database to Amazon RDS.
Store session data in Amazon ElastiCache for Redis and application data in Amazon DynamoDB.
Utilize the EC2 instance store for session data and migrate the database to Amazon RDS for PostgreSQL.
Explanation
Answer B is correct because:
1. ElastiCache for Redis provides a managed, in-memory data store optimized for high-speed access, solving the session management issue. Storing sessions here allows all EC2 instances in the Auto Scaling group to share session data, ensuring consistency during scaling.
2. Amazon RDS offers a managed PostgreSQL database with automated backups, patching, and scalability features, reducing administrative overhead and improving database reliability.
Why other options are incorrect:
- A: Storing sessions in PostgreSQL (even on EC2) introduces latency and scalability bottlenecks, as relational databases are not optimized for session storage.
- C: DynamoDB is a NoSQL database, which may not suit relational application data without significant restructuring.
- D: EC2 instance stores are ephemeral, making them unsuitable for persistent session data.
Key Points:
- Use ElastiCache/Redis for scalable, shared session storage.
- Use RDS for managed relational databases to improve scalability and reduce maintenance.
Answer
The correct answer is: B