LocalStack

JWT authorizer causes unexplained latency overhead in HTTP API Gateway

warning
performanceUpdated Dec 16, 2024(via Exa)
Technologies:
How to detect:

HTTP API Gateway with Lambda integration shows ~600ms gap between integration latency (sub-40ms) and total latency (612-647ms). Issue persists on both cold and warm Lambda starts despite JWT authorizer token caching being expected to work (2-hour cache for IDP keys, caching of authorization decisions for repeated tokens).

Recommended action:

Monitor CloudWatch metrics to confirm Latency vs IntegrationLatency discrepancy. Test removing JWT authorizer temporarily to isolate issue. Verify JWT authorizer caching is functioning (should cache IDP keys for 2 hours, should cache authorization decisions for repeated tokens). Confirm resource-based policy exists on Lambda to avoid STS call overhead. Consider REST API instead of HTTP API if X-Ray tracing needed for deeper debugging. Enable detailed CloudWatch logging and metrics for additional visibility.