-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Hello OpenWhisk maintainers,
I’m observing a curious phenomenon regarding prewarmed containers and cold starts, and I’d appreciate any insight from the community.
Description
I ran two sets of tests, each consisting of 8 invocations of the same action:
• Group A: Always spin up a brand-new prewarm container for each invocation (so effectively never reusing the same container).
• Group B: Always spin up a brand-new container with a typical cold start.
Observed Behavior
1. Group A’s first invocation is slower than Group B’s cold start.
2. However, Group A’s subsequent 7 invocations (still new prewarm containers) are consistently faster than Group B’s cold starts.
Hence, the puzzling result is:
First prewarm container > (longer latency) > cold start
But afterwards, new prewarm containers < (shorter latency) < cold start.
I would have expected a prewarm container to be at least as fast as or faster than a cold start on the first invocation, yet the actual data shows the initial prewarm is slower.
What I Suspect
My current hypothesis is that the prewarm container in OpenWhisk might only partially initialize the runtime (e.g., pulling the base image, starting the container process), but does not complete certain steps (such as /init, code injection, or JIT/loading overheads) until the first actual activation occurs. Thus, the very first time we use a “prewarm” container, we still pay an extra initialization cost, which sometimes ends up being even higher than a straight cold start.
After that, perhaps the system (Docker, cgroup, network, language runtime JIT, etc.) has enough caching or has done some overhead checks, so subsequent prewarm containers spin up quickly and end up faster than a brand-new cold container. This would explain why repeated prewarm containers (from the second to the eighth) become reliably faster.
Questions
Is this expected or documented behavior in OpenWhisk, that the initial prewarm usage might be slower than a pure cold start in some circumstances?