A city Lambda pays TCP/TLS handshake costs on every invoke when creating new HTTP and AWS SDK clients inside the handler. What reuse pattern helps?
Select an answer to reveal the explanation.
Short Explanation
Handshaking TLS on every citizen click is like reintroducing yourself every sentence. Build the HTTP/SDK clients once outside the handler and reuse them on warm invokes. You skip the hello ritual and shave latency.
Full Explanation
A city Lambda that pays TCP/TLS handshake costs on every invoke by creating new HTTP and AWS SDK clients inside the handler should initialize those clients during cold start (outside the handler) and reuse them across warm invokes. Client reuse preserves connection pools and cuts latency for municipal APIs that call AWS services or HTTP backends repeatedly under load.
Instantiating a brand-new SDK client on every line of business logic maximizes handshake and init overhead.
Disabling keep-alive so every call performs a full handshake worsens the exact problem being solved.
Restarting the execution environment after every request to clear clients destroys warm-start benefits.
Exam caveat: Initialize SDK/HTTP clients in the global/cold-start scope for reuse—classic Lambda performance guidance.
Operational check: Move client construction outside the handler, verify connection reuse under load, measure duration improvement, and ensure clients are safe for concurrent invokes within a single environment. Keep the civic/municipal context in mind: high-QPS city APIs feel handshake taxes immediately when clients are rebuilt per request. Document the finding in the municipal incident ticket so the next on-call engineer inherits evidence rather than folklore.