Refactoring Study Guide — DVA-C02

10% of the exam · domain 4 of 5 · AWS Developer Associate · Free Refactoring practice questions

0 of 43 topics covered
Domain 4 of 5

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 scenarioManaged replacementWhy the exam prefers it
Cron job on EC2 firing scriptsEventBridge Scheduler (or EventBridge rule) + LambdaNo instance to patch; at-least-once delivery; one-time and recurring schedules; time zone and flexible time windows
Redis/Memcached installed on EC2Amazon ElastiCacheManaged patching, Multi-AZ failover, backups
Apache Kafka cluster on EC2Amazon MSK or Kinesis Data StreamsManaged brokers/shards
Session state in local memory + sticky sessionsDynamoDB or ElastiCache for RedisMakes instances stateless so Auto Scaling/Lambda can scale horizontally
Uploads proxied through the web tier to diskS3 presigned URLs (direct browser→S3)Removes bandwidth/CPU from compute, no EBS sizing, 5 TB object support
Static assets served by EC2/nginxS3 static website + CloudFrontOffload, edge caching, lower cost
Home-grown login, password hashing, MFA, JWT issuanceAmazon Cognito user poolsManaged tokens, MFA, hosted UI, federation
Credentials in env vars or config filesSecrets Manager (auto rotation) or SSM Parameter Store SecureStringEncryption, rotation, IAM-scoped, audited
Self-written job queue in a database tableAmazon SQSVisibility timeout, DLQ, infinite scale
Logs written to local disk and rotatedCloudWatch Logs agent / native Lambda loggingCentralised, queryable with Logs Insights
Self-managed API keys, throttling, request validationAPI Gateway usage plans, throttling, request validatorsDeclarative, no code
RDBMS on EC2 with manual backupsRDS / Aurora (Aurora Serverless v2 for spiky loads)Automated backups, failover, patching
Long-running ETL on an always-on instanceLambda, Fargate, or Step FunctionsPay per use, no idle capacity
Custom container schedulerECS on Fargate / EKSNo 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.