>DevOps Interview KB

How would you detect, from CloudWatch metrics alone, whether a Lambda function's tail latency problem is cold-start-driven versus something else?

IntermediateTroubleshootingAWSLambdaCloudwatch7 min read

Short Answer

Correlate the slow invocations' timestamps against CloudWatch's InitDuration metric (only present for cold-started invocations) and the ConcurrentExecutions metric around the same window — if slow invocations line up with non-zero InitDuration and a preceding rise in ConcurrentExecutions, the tail is cold-start-driven; if not, the investigation should shift toward downstream dependencies or throttling instead.

Detailed Explanation

CloudWatch's Lambda-native metrics give enough signal to distinguish cold-start-driven tail latency from other causes without adding custom tracing, because cold starts leave a specific, identifiable fingerprint: a distinct InitDuration value, correlated timing with ConcurrentExecutions growth, and a characteristic bimodal shape to the latency distribution. Working through those signals systematically (rather than guessing) turns "p99 is bad" into a specific, evidence-backed cause.

Symptoms

  • p99 (or p999) latency for a Lambda function is significantly worse than p50/median latency.
  • The gap between median and tail latency doesn't correlate obviously with request payload size or an identifiable "hard" subset of requests.
  • No custom tracing/instrumentation has been added yet, and CloudWatch's built-in metrics are the only available signal.

Possible Causes

  • Cold starts: a request lands on a newly-initialized execution environment, paying full initialization cost on top of normal invocation duration.
  • A slow downstream dependency occasionally responding slowly (a database, another service), unrelated to Lambda's own cold-start behavior.
  • Throttling causing some invocations to wait or retry.
  • Garbage collection pauses or other runtime-level pauses within an already-warm execution environment.

Investigation Steps

Compare Duration against InitDuration: CloudWatch's InitDuration metric (available specifically for invocations that experienced a cold start) reports the initialization time separately from the reported Duration. If tail-latency invocations correlate with the presence of a non-zero InitDuration, that's a direct, positive signal the tail is cold-start-driven — this is the single most direct CloudWatch-native signal for this diagnosis.

Check ConcurrentExecutions around the timestamps of slow invocations: cold starts happen when Lambda needs to spin up a new execution environment because existing warm ones are all busy — a spike in ConcurrentExecutions shortly before or during the slow-latency period is consistent with new environments being created (and paying init cost) to handle the burst, supporting the cold-start hypothesis; a flat ConcurrentExecutions line during the slow period argues against it (existing warm environments were sufficient, so a new one wasn't likely needed).

Rule out throttling via the Throttles metric: if Throttles shows non-zero counts correlating with the tail-latency period, some of what looks like "slow invocations" may actually be throttled requests that retried (adding apparent latency from the caller's perspective) rather than genuinely slow cold starts — checking this rules out a distinct cause that can look superficially similar.

Compare latency distribution shape against known cold-start behavior: cold-start-driven tail latency typically shows a somewhat bimodal distribution (most requests fast, a distinct cluster of slower ones roughly matching typical init duration for the runtime) — if instead the tail is a smooth, gradually-worsening distribution with no such clustering, that shape is more consistent with a different cause (like a downstream dependency's own latency distribution) than with cold starts specifically.

Cross-reference with deployment/scaling events: cold starts cluster around deployment times (new code version = fresh execution environments needed) and around traffic ramps (need for additional concurrent environments) — if the tail-latency spikes align with recent deployments or ConcurrentExecutions increases rather than being spread evenly throughout the day, that timing correlation further supports the cold-start explanation over a downstream-dependency explanation (which would more likely correlate with the downstream service's own load pattern instead).

Resolution

If InitDuration correlates with the tail-latency invocations and ConcurrentExecutions shows corresponding spikes, the fix is one of the cold-start mitigations (Provisioned Concurrency, SnapStart where supported, or reducing initialization-time work) rather than investigating downstream dependencies. If instead InitDuration is absent or doesn't correlate, the investigation should shift toward downstream dependency latency (custom tracing, X-Ray, or downstream service's own metrics) or throttling remediation, since CloudWatch's Lambda-native metrics have effectively ruled out cold starts as the cause.

Interview Follow-Up Questions

  • How would you set up a CloudWatch alarm specifically for cold-start-driven tail latency, rather than tail latency in general?
  • What would you add (beyond CloudWatch's built-in metrics) if this investigation were inconclusive, and why?
  • How would this investigation change for a function using SnapStart, where the built-in `InitDuration` semantics differ from the traditional cold-start case?

Key Takeaways

  • InitDuration is the direct CloudWatch signal for cold starts — correlating it with tail-latency invocations is the primary diagnostic step.
  • ConcurrentExecutions spikes around the same timestamps support the cold-start hypothesis, since new environments are created when existing warm ones are all busy.
  • Ruling out Throttles separately avoids conflating throttled-and-retried requests with genuinely slow cold starts.
  • A bimodal latency distribution (fast majority, distinct slower cluster near typical init duration) is more consistent with cold starts than a smooth, gradually-worsening tail.

References

Last updated August 21, 2026 · Last reviewed August 21, 2026