Home / Companies / Upstash / Blog / Post Details
Content Deep Dive

Reusing HTTP connections with 'keepalive' in Serverless

Blog post from Upstash

Post Details
Company
Date Published
Author
Andreas Thomas
Word Count
751
Company Posts That Month
9
Language
English
Hacker News Points
-
Post removed?
No
Summary

Keepalive is a technique that reduces latency by maintaining an open connection between a client and a server, which is particularly beneficial when making multiple requests to the same server in quick succession. Although serverless functions like AWS Lambda and Vercel are stateless, they can temporarily hold state when a "hot" function is reused, allowing data or connections to persist between requests. By placing variables or objects like an HTTPS agent outside the handler function, subsequent invocations can reuse these resources, enhancing performance. Testing on a Next.js app with Vercel and an Upstash Redis database showed that enabling keepalive and caching connections significantly reduced latency, with initial requests taking longer due to connection establishment but subsequent requests achieving much lower latency. This optimization is realized in the @upstash/redis SDK, enabling keepalive by default to improve performance across multiple calls without additional configuration.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Serverless 6 743 108 48 +27%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.