Refactoring (Domain 4 — 10% of the exam)
This domain tests whether you can take working-but-suboptimal code and move it onto the right AWS primitive: replacing self-managed infrastructure with managed services, choosing a migration pattern (rehost/replatform/refactor), tuning Lambda and DynamoDB for latency and cost, inserting the correct cache layer, decoupling a monolith with messaging, and deleting hand-rolled retry logic in favour of SDK behaviour. At 10% of a 65-question exam this is roughly 6–7 scored questions, but the concepts leak heavily into Development and Deployment questions. Answers here are almost never "build it yourself" — the exam rewards the least operational overhead, most managed, most decoupled option that still meets the stated constraint.
Optimizing applications to use managed AWS services instead of self-managed infrastructure
The core exam reflex: when a scenario describes a developer maintaining something AWS already sells as a service, the answer replaces it. Learn the standard swaps cold.
| Self-managed pattern in the scenario | Managed replacement | Why the exam prefers it |
|---|---|---|
| Cron job on EC2 firing scripts | EventBridge Scheduler (or EventBridge rule) + Lambda | No instance to patch; at-least-once delivery; one-time and recurring schedules; time zone and flexible time windows |
| Redis/Memcached installed on EC2 | Amazon ElastiCache | Managed patching, Multi-AZ failover, backups |
| Apache Kafka cluster on EC2 | Amazon MSK or Kinesis Data Streams | Managed brokers/shards |
| Session state in local memory + sticky sessions | DynamoDB or ElastiCache for Redis | Makes instances stateless so Auto Scaling/Lambda can scale horizontally |
| Uploads proxied through the web tier to disk | S3 presigned URLs (direct browser→S3) | Removes bandwidth/CPU from compute, no EBS sizing, 5 TB object support |
| Static assets served by EC2/nginx | S3 static website + CloudFront | Offload, edge caching, lower cost |
| Home-grown login, password hashing, MFA, JWT issuance | Amazon Cognito user pools | Managed tokens, MFA, hosted UI, federation |
| Credentials in env vars or config files | Secrets Manager (auto rotation) or SSM Parameter Store SecureString | Encryption, rotation, IAM-scoped, audited |
| Self-written job queue in a database table | Amazon SQS | Visibility timeout, DLQ, infinite scale |
| Logs written to local disk and rotated | CloudWatch Logs agent / native Lambda logging | Centralised, queryable with Logs Insights |
| Self-managed API keys, throttling, request validation | API Gateway usage plans, throttling, request validators | Declarative, no code |
| RDBMS on EC2 with manual backups | RDS / Aurora (Aurora Serverless v2 for spiky loads) | Automated backups, failover, patching |
| Long-running ETL on an always-on instance | Lambda, Fargate, or Step Functions | Pay per use, no idle capacity |
| Custom container scheduler | ECS on Fargate / EKS | No control plane or host management |
Statelessness is the prerequisite for most refactors. Before compute can be replaced with Lambda or an Auto Scaling group, local state (sessions, uploaded files, in-process caches, generated PDFs) must move to S3, DynamoDB, or ElastiCache.
Common traps
- Answers that keep EC2 but "add a script" or "add a second instance" — almost always wrong when a managed service exists.
- Choosing Secrets Manager when the scenario says no additional cost / configuration values only — that's Parameter Store. Choosing Parameter Store when the scenario demands automatic rotation of database credentials — that's Secrets Manager.
- Using ElastiCache for durable session data the scenario says must survive node loss at low cost — DynamoDB with TTL is the cheaper durable answer.
- Storing files in DynamoDB or an RDS BLOB column; the 400 KB DynamoDB item limit makes S3 + a pointer the right pattern.
- Confusing EventBridge Scheduler (one-time and cron/rate schedules, 1-minute granularity, over 270 targets) with EventBridge rules (event-pattern driven).
Worked scenario. A PHP app on EC2 behind an ALB uses sticky sessions; scaling in drops carts. Requirement: scale freely, minimal ops. → Externalise sessions to DynamoDB with a TTL attribute (or ElastiCache Redis), disable stickiness, keep the ASG. Adding more instances or a larger instance does not fix the stateful design.
Unlock with a paid plan
10 more sections (about 4,171 words) continue below. Every paid plan unlocks all DVA-C02 study guides, the full question bank and mock exams, from $4.97/month.