What a cold start actually costs on DigitalOcean Functions
RevSofia, the car-meet planner I built for Sofia, runs its planning endpoint as a DigitalOcean Function. I'd never measured what the first call to a function costs compared with the ones after it, or whether ten requests arriving at once are any worse than one, so this week I did. I built a throwaway namespace with two trivial actions, one in Node.js 22 and one in Python 3.12, each just returning…
DigitalOcean Functions incur significant costs during cold starts, which this report uncovers by measuring the platform's performance on newly initialized containers versus warm containers. A cold start involves DigitalOcean finding or starting a container before running the function code, which takes between 1 to 3 milliseconds, while a warm start, where the container has been idle, can take as little as 42 milliseconds.
The platform reports waitTime, which represents the time before code execution begins, highlighting the difference between a first call and subsequent calls. Initial tests using plain requests.post() calls revealed misleading results due to separate TLS handshakes on every invocation, hiding the true cost of cold starts. Reusing connections with requests.Session() reduced warm call times to 140-150ms, revealing the substantial impact of connection setup.
A burst test of ten simultaneous requests further demonstrated the cost, with each request waiting 656-984ms before execution, mirroring a cold start. The study emphasizes the need for developers to understand connection costs when timing serverless functions, especially when over HTTPS.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to