4.2 - Troubleshooting performance and throttling

AWS Certified Developer Associate objective 4.2 covers troubleshooting and optimising performance. When a Lambda function occasionally returns TooManyRequestsException (429) under load, its concurrent executions are hitting the concurrency limit, so you raise reserved concurrency or request a higher account limit. When a Node.js Lambda opens a new HTTPS connection to AWS services on every invocation, adding latency, setting AWS_NODEJS_CONNECTION_REUSE_ENABLED to 1 reuses the connection across invocations. When a Kinesis producer intermittently gets ProvisionedThroughputExceededException, a hot shard is the cause; using a higher-cardinality partition key spreads records more evenly across shards. You should also know DynamoDB hot partitions, exponential backoff and caching. Expect scenario questions that describe throttling errors, per-invocation connection overhead, or uneven Kinesis load, and ask which cause or fix - concurrency limit, connection reuse or a better partition key - applies.

Memory hook
Lambda 429 under load = hitting the concurrency limit (raise it). New HTTPS per invocation (Node.js) = set AWS_NODEJS_CONNECTION_REUSE_ENABLED=1. Kinesis ProvisionedThroughputExceeded = hot shard; use a higher-cardinality partition key.

Practice questions

1. A Lambda function frequently times out on a slow downstream call. Which two settings most directly address this? (Choose the best single answer.)

  • Increase the function timeout and optimize the downstream call (correct answer)
  • Delete the function's IAM execution role and recreate it later
  • Disable CloudWatch logging for the function
  • Reduce the function memory to the minimum

Raising the timeout (up to 15 min) prevents premature termination while you also optimize or cache the slow dependency. Removing the role or disabling logs would break or blind the function.

2. A DynamoDB read returns ProvisionedThroughputExceededException during short traffic spikes on a provisioned table. Which change best handles unpredictable bursts?

  • Lower the provisioned read capacity units on the table
  • Add a second internet gateway to the VPC
  • Switch the table to on-demand capacity mode (correct answer)
  • Disable automatic retries in the SDK client

On-demand capacity mode scales instantly to traffic without capacity planning, eliminating throttling from unpredictable bursts (you pay per request). Lowering RCUs or disabling retries makes it worse.

3. A Lambda reading from a Kinesis stream falls behind, and IteratorAge keeps rising. Which change most directly increases throughput?

  • Add more shards and/or increase parallelization factor (correct answer)
  • Lower the function memory to save cost
  • Disable the CloudWatch Logs stream for the function entirely
  • Switch the stream to an SQS standard queue

Rising IteratorAge means processing lags behind ingestion. More shards raise stream capacity, and a higher parallelization factor lets multiple concurrent batches process one shard, both increasing consumer throughput.

4. A read-heavy DynamoDB workload needs microsecond latency for cached reads without changing application read logic much. Which service helps?

  • Amazon ElastiCache set up manually
  • A larger provisioned read capacity
  • DynamoDB Accelerator (DAX) (correct answer)
  • Global secondary indexes on all keys

DAX is an in-memory cache purpose-built for DynamoDB, delivering microsecond reads through a DynamoDB-compatible client with minimal code changes. It caches item and query results.

5. A Lambda behind API Gateway returns HTTP 502 Bad Gateway intermittently. What is a common cause a developer should check?

  • The API stage cache TTL is set too high
  • The usage plan quota was fully consumed
  • The function returned a malformed response payload (correct answer)
  • The Lambda has too much reserved concurrency

With Lambda proxy integration, a 502 typically means the function returned a malformed response (wrong shape, non-JSON, or an unhandled error). A consumed quota returns 429; cache TTL affects freshness, not 502.

6. A Lambda function's cost is high because it is over-provisioned. Which tool recommends the optimal memory setting from real invocation data?

  • AWS Trusted Advisor storage checks
  • Amazon Inspector vulnerability findings
  • A DynamoDB capacity auto scaling policy
  • AWS Lambda Power Tuning (Step Functions tool) (correct answer)

AWS Lambda Power Tuning is a Step Functions state machine that runs the function at different memory sizes and charts cost vs performance, revealing the optimal memory setting. More memory also raises CPU, sometimes lowering cost.

Related objectives