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 the current time, the process ID and how long that process had been alive. That last field turned out to be the most useful thing in the whole test, because DigitalOcean's activation record doesn't label cold starts explicitly. It gives you a waitTime annotation instead, and you have to work out what it means by watching the process uptime keep climbing.

The first call versus the hundredth

Here's what the platform itself reported as waitTime, which is everything that happens before your code starts running:

Call waitTime
First call ever, Python 3.12 648 ms
First call ever, ten fired at once, Node.js 22 656-984 ms (average ~800 ms)
Same warm container, back to back 1-6 ms
Same warm container, after 90 seconds idle 42 ms

The function body itself, in every single one of these, ran in 1 to 3 milliseconds. A return statement doesn't take 650ms to execute. All of that time is the platform finding or starting a container.

What surprised me was the 90-second number. I'd expected a short idle gap to force a fresh container, the way some serverless platforms reclaim aggressively. It didn't: the same process ID and a steadily climbing uptime value came back, and the queueing cost was 42ms, not 650. Whatever DigitalOcean's idle window is, it's comfortably longer than 90 seconds.

What I got wrong on the way

My first few runs used a plain requests.post() call for every invocation, with no persistent connection. The numbers came back almost flat: a "cold" call at 1,122ms and "warm" calls hovering around 550ms, barely half the cold figure. I nearly wrote that up as "warm containers only save you 2x," which would have been wrong and would have buried the actual effect.

Running curl -w against the same host on its own showed why:

dns:0.000036s connect:0.000154s tls:0.341220s total:0.495107s 

A third of a second of that "warm" 550ms was a fresh TLS handshake, not the platform doing anything. Once I reused a requests.Session() so the connection stayed open, the warm numbers dropped to 140-150ms and the waitTime annotation dropped to single digits. The cold-start effect was real; my harness had just been hiding most of it behind a TLS handshake I was paying for on every single call, including the ones I thought were testing a warm container.

The lesson, which is obvious in hindsight and wasn't obvious while I was staring at two similar-looking numbers: if you're timing anything over HTTPS, know how many of your "requests" are actually opening a new connection.

The second mistake was trusting process IDs to count containers, which I come back to in the burst test below.

Round trip, broken into its parts

With that fixed, here's the full breakdown, averaged over several runs:

Component Time
TLS handshake, new connection ~330-340 ms
Warm invoke, connection reused ~140-150 ms
Warm invoke, new connection every call ~500-580 ms
Cold invoke, new connection ~1,100-1,700 ms

The platform's own share of a warm call, the waitTime annotation, was 1-6ms. The rest of the 140-150ms was the path between my machine and the API, which I didn't break down further.

Ten requests at once

I deployed a fresh action, never invoked, and fired ten blocking requests at it simultaneously with a thread pool:

(0, 1079ms, duration=2, waitTime=818, pid=6) (1, 1193ms, duration=1, waitTime=660, pid=6) (2, 1560ms, duration=3, waitTime=929, pid=7) (3, 1684ms, duration=2, waitTime=984, pid=6) (4, 1475ms, duration=2, waitTime=656, pid=7) (5, 1601ms, duration=2, waitTime=844, pid=6) (6, 1325ms, duration=2, waitTime=687, pid=6) (7, 1326ms, duration=1, waitTime=710, pid=6) (8, 1603ms, duration=2, waitTime=791, pid=7) (9, 1550ms, duration=1, waitTime=730, pid=6) total wall time for all 10: 1.70s distinct pids used: {6, 7} 

All ten requests finished inside 1.7 seconds, with no errors. Every one of them waited 656-984ms before its code ran, roughly one cold start's worth each, and the function body itself still took 1 to 3 milliseconds.

My first reading of that output was wrong. Only two process IDs came back, 6 and 7, and I nearly wrote that ten requests had been served by two containers. But each container has its own process namespace, so a freshly started process in a new container will often get the same small PID as one in the container next to it. The PID can tell me a container stayed the same over time, which is how I used it in the idle test, but it can't count containers. To count them, the handler needs an ID generated once when the process starts, which I've added to the command below. I didn't rerun the burst with it, so I can't give an exact container count for this one.

DigitalOcean's own Functions limits page documents a hard ceiling of 120 concurrent invocations per namespace, with new calls over that limit refused outright. I didn't push that far. Ten was enough to see what a burst costs, and getting anywhere near 120 would have meant running far more than this test needed.

What it refuses

The same limits page states memory runs from 128MB to 1GB and timeout tops out at 15 minutes. I checked the floor, the ceiling, and the exact wording of the rejection:

Limit Docs say What the API actually said
Memory floor 128 MB requirement failed: memory 64 mb below allowed threshold of 128 mb (HTTP 400)
Memory ceiling 1024 MB Function memory limit of 2048 megabytes exceeds allowed threshold of 1024 megabytes (HTTP 403)
Timeout ceiling 900,000 ms requirement failed: duration 1000000 milliseconds exceeds allowed threshold of 900000 milliseconds (HTTP 400)

All three numbers matched the documentation exactly, which is more than I can say for plenty of docs pages. The one loose thread: going under the memory floor and going over the timeout ceiling both come back as 400 Bad Request, but going over the memory ceiling comes back as 403 Forbidden. Same category of mistake, same validation layer presumably, different status code. Nothing breaks because of it. If a deploy script branches on status codes, it's simplest to treat a 400 and a 403 from this endpoint the same way and read the message, which names the exact limit.

Run it yourself

This needs a namespace UUID and key, which doctl serverless connect or the "Create namespace" API call will give you. Everything else is plain curl against the OpenWhisk-compatible API DigitalOcean Functions exposes directly, no SDK required:

API_HOST="https://<your-namespace-api-host>" # from doctl serverless connect AUTH="$DO_NS_UUID:$DO_NS_KEY" # deploy a trivial action curl -s -X PUT -u "$AUTH" "$API_HOST/api/v1/namespaces/_/actions/warmtest?overwrite=true" \ -H "Content-Type: application/json" \ -d '{"namespace":"_","exec":{"kind":"nodejs:22","code":"const id=Math.random().toString(36).slice(2);function main(a){return {now:Date.now(),id,pid:process.pid,uptime:process.uptime()};}"},"limits":{"timeout":10000,"memory":256}}' # invoke it, blocking, and read the waitTime annotation curl -s -u "$AUTH" -X POST "$API_HOST/api/v1/namespaces/_/actions/warmtest?blocking=true" -d '{}' \ -H "Content-Type: application/json" | python3 -c " import json,sys b=json.load(sys.stdin) ann={a['key']:a.get('value') for a in b['annotations']} r=b['response']['result'] print('waitTime', ann.get('waitTime'), 'id', r['id'], 'uptime', r['uptime']) " 

Run the invoke command once right after deploying, then again a few seconds later, and compare waitTime. The same id with a higher uptime means the same warm container answered. Wrap it in a requests.Session() (or curl with --next against the same connection) if you want the network RTT to stop hiding in your numbers.

What I'd actually do differently

  • I'm not adding a keep-warm ping to RevSofia yet. A container was still warm after 90 seconds idle, and I'd want to find where the real idle window ends before paying for pings that may not be needed.
  • If I put something latency-sensitive behind a Function with bursty traffic, I'd plan for every request in the first burst after a quiet spell to pay about a cold start, which is what all ten did here, not just the first one.
  • I'm keeping the measurement script with the persistent session. The version without one gave me a plausible, wrong answer, and I only caught it because the "no real difference" result made me suspicious of my own harness rather than of DigitalOcean's platform.