@shinyaz

AWS SDK for Rust takes ~900ms on first request — TLS handshake is 99%

1 min read

While writing a Lambda Rust + DynamoDB benchmark, I noticed the first request after a cold start took 912ms. Init Duration itself was only 112ms — fast. Yet the first DynamoDB call was abnormally slow.

Breaking down the latency revealed that TLS handshake averages 745ms, accounting for 99% of the total. DNS resolution is 7.3ms, TCP connection is under 1ms. At 128MB (roughly 7% of a vCPU), TLS cryptographic processing is extremely expensive.

Output
DNS:  7.3ms   (1%)
TCP:  0.7ms   (0%)
TLS: 745ms   (99%)

The fix: run client.list_tables().limit(1).send().await once during Init to warm the connection. This drops first Duration from 912ms to 21ms (82% reduction in total Billed Duration). Use let _ = to ignore the result so Init succeeds even if warming fails.

Share this post

Shinya Tahara

Shinya Tahara

Solutions Architect @ AWS

I'm a Solutions Architect at AWS, providing technical guidance primarily to financial industry customers. I share learnings about cloud architecture and AI/ML on this site.The views and opinions expressed on this site are my own and do not represent the official positions of my employer.