WorksComputer Science
Adaptive Warm-State Retention for Serverless Cold-Start Mitigation: Treating Keep-Alive Time as an Online Control Parameter
Abstract
Serverless platforms are easy to operate but pay a recurring price in cold starts: when a function is called after sitting idle, its execution environment must be rebuilt before the request can run, and latency suffers. The usual fix keeps idle environments alive for a fixed window, but a single value rarely fits a changing workload: too high wastes idle capacity, too low causes avoidable cold starts. We argue the keep-alive window should not be a fixed deployment constant; instead we treat it as a per-function runtime parameter, adjusted online from what the system observes, kept separate from how many replicas to run. We build an external retention controller for OpenFaaS/faasd that needs no platform changes, driven by two simple agents: a reactive AIMD (Additive-Increase Multiplicative-Decrease) rule and a UCB1 multi-armed bandit. Against fixed-timeout baselines and a predictive histogram keep-alive, on steady, bursty, and trace-derived workloads (Huawei Serverless 2023), the bandit cuts the aggregate cold-start rate from 63% under immediate scale-to-zero to 3%, holds P95 tail latency at the level of the longest-retention fixed baseline, and uses about 13% less accumulated warm time than that baseline, while also beating the predictive baseline. No fixed timeout is best on every metric, whereas the adaptive agents reach a favorable operating point without manual tuning; on the bursty workload at a converged horizon the bandit's advantage is statistically significant. On a multi-node Kubernetes cluster under the platform's own Horizontal Pod Autoscaler, the controller coexists with an autoscaler it does not control: the replica count follows load identically across policies, and retention independently governs warm time.
Introduction
Serverless computing has become a common way to build event-driven and cloud-native applications, most often through the Function-as-a-Service (FaaS) model [1, 2, 3]. Developers write small, stateless functions, and the platform takes care of deploying, scaling, and running them, paying for compute only while a request is being handled. This model is convenient, but it incurs a recurring cost. When a function is invoked and no initialized environment is available, the platform must first provision and initialize one. This delay, the cold start, arises from several steps in sequence: allocating resources, starting the runtime, loading dependencies, and performing application-level setup [4].
Cold starts are not a rare corner case. Studies of production traffic report that invocation patterns are highly uneven, with a long tail of functions that are invoked only occasionally and remain idle in between [5]. Recent end-to-end measurements show that cold starts occur frequently enough to affect tail-latency measurably [6]. Because idle environments are reclaimed first, it is precisely these irregular functions that repeatedly incur the reinitialization cost.
The usual defense is warm-state retention, or keep-alive: hold an idle environment for a bounded period so that a subsequent request can reuse it before it is torn down. In practice this window is almost always a static setting, such as a fixed idle timeout or a minimum replica count [7]. This is simple to configure but difficult to tune. A window suited to one function’s traffic is either wasteful or too short for another, and a value chosen for current conditions degrades once the workload shifts. Any fixed choice pins the operator to a single point on a trade-off curve: a short window conserves resources but admits more cold starts, while a long window suppresses cold starts but pays for idle capacity.
Our premise is that this window need not be a fixed constant. We treat the keep-alive time of a function as a runtime parameter , the time at least one environment remains available after the last invocation, and we adjust it online: every update is computed during execution from the outcomes observed so far, with no offline training phase and no knowledge of future invocations. One design principle is central to the paper: we deliberately separate the retention question from autoscaling, scoping this study to the single-instance regime where retention duration is the dominant lever. Most adaptive serverless work asks how many replicas to run; we address the narrower and, we argue, more specific question of how long a single environment should remain available after it becomes idle, the decision that dominates when one warm instance suffices.
We make the following contributions:
We recast per-function keep-alive as an online control variable decoupled from autoscaling, framing retention duration (not replica count) as an explicit, lightweight, training-free control target rather than a fixed timeout (§ 3).
We design and implement an external retention controller for OpenFaaS/faasd that enforces without modifying the platform, driven by two agents, a reactive AIMD rule and a UCB1 bandit, that need no training, no workload model, and only state, so the approach ports to any FaaS runtime (§ 3–IV).
We evaluate both agents against three static baselines and a predictive histogram keep-alive on steady, bursty, and trace-derived workloads (cold-start rate, mean and P95 latency, warm time), over 10,800 logged invocations, plus a sensitivity sweep over the agents’ parameters (§ 5–VI). The bandit attains cold-start and tail-latency behavior close to the longest-retention baseline at ∼13% less warm time and, despite being model-free, outperforms the predictive histogram baseline; no single configuration is best on every metric. We further establish the bandit’s advantage statistically at a converged horizon (Sec. VI-H), show the policy ordering carries over to two additional realistic functions, a JSON API and image resizing (Sec. VI-I), and, on a multi-node Kubernetes cluster under the stock Horizontal Pod Autoscaler, show the controller coexists with an autoscaler it does not control, whose replica count follows load and spans multiple nodes independently of the retention policy (Sec. VI-J).
Background and Related Work
Cold Starts and Warm-State Retention
Every FaaS invocation runs inside an execution environment (a container or micro-VM). A warm call reuses an initialized one and skips startup; a cold call must build one first [4]. Longer retention cuts cold starts but holds idle resources longer, so the best timeout depends on traffic: a busy function benefits from a long window, while a rarely called one gains little and mostly ties up capacity [5].
Heuristic and Cache-Based Retention
Early systems such as SAND improve performance by increasing environment reuse and reducing initialization overhead [7]. FaasCache reframes keep-alive as a caching problem, applying a Greedy-Dual policy that prioritizes which containers to retain under resource pressure based on recency and startup cost [8]. PULSE reduces keep-alive cost using mixed-quality predictive models to guide retention [9]. These approaches largely decide which environments to keep, using predefined rules or prioritization logic, and adapt retention only coarsely at runtime; the temporal question of how long a given function should stay warm receives less attention.
Forecast-Based Retention
A second line predicts future demand and pre-warms accordingly. Deep-learning frameworks model invocation behavior as time series to drive cold-start management [10], and systems such as IceBreaker forecast when each function will next be invoked and warm it in advance, selecting lower-cost hardware during the wait [11]. These methods are effective when traffic is predictable, but their performance depends on forecast accuracy; irregular, externally driven workloads are difficult to predict, and a prediction error causes either wasted retention or premature teardown. They also require historical data and periodic retraining.
Reinforcement Learning and Online Adaptation
Reinforcement learning (RL) treats resource management as sequential decision making and can outperform static heuristics [12], but most RL formulations target autoscaling (replica counts), fold retention in only indirectly, and need richer state and more interaction data to stabilize. Lightweight online methods are a middle ground: a multi-armed bandit selects among actions and learns their payoffs with minimal state [13], and UCB1 gives finite-time regret guarantees while balancing exploration and exploitation [14]; AIMD [15] is an even simpler reactive rule.
Positioning
Most existing work on cold starts is heuristic, forecast-based, or RL-based, and across all three the keep-alive window is seldom treated as an explicit per-function knob. The attention goes to how many environments to keep, not how long to keep one, even though that timing is the primary factor behind cold starts under irregular and bursty traffic. Our work addresses this gap. We make retention duration the variable of interest, adapt it online with two intentionally simple agents (AIMD and UCB1), and study its effect in isolation from autoscaling, later showing the two rules compose (Sec. VI-J). Table 1 positions our approach against representative prior work on the dimensions most relevant to runtime retention: runtime adaptation, freedom from a training/forecast phase, direct control of retention duration, and computational lightness.
Table 1. Positioning against representative prior work. part. marks mechanisms that affect retention duration only indirectly.
System Design
Problem Formulation
Let a function have a retention duration specifying how long at least one execution environment remains available after its most recent invocation. A static policy fixes for the entire run; an adaptive policy updates it during execution from observed outcomes. The objective is to dynamically choose so as to reduce cold-start frequency and latency while avoiding unnecessary accumulated warm time, under workloads whose invocation behavior is not known in advance.
Requirements
The system must (R1) adjust at runtime; (R2) operate at per-function granularity, since invocation behavior differs across functions; (R3) support multiple retention strategies (static and adaptive) under identical conditions for fair comparison; (R4) produce reproducible warm/cold transitions; (R5) exercise heterogeneous workloads; and, on the non-functional side, (R6) remain lightweight, (R7) stay modular by separating retention enforcement from policy decision, and (R8) work with an unmodified serverless platform.
Architecture
Figure 1 shows the four components. A workload generator emits invocation sequences; an invocation layer forwards them to the OpenFaaS gateway and records latency and platform state; a policy layer computes the per-function ; and a retention controller enforces it by observing replica/idle state and issuing scale-to-zero. Decoupling enforcement (controller) from decision (policy) satisfies R3 and R7: any policy plugs in without changing lifecycle logic.
Figure 1. System architecture. The retention controller enforces the per-function control parameter supplied by the policy layer, using only the platform’s external interfaces (replica/idle state in, scale-to-zero out).
Warm-State Lifecycle
To isolate retention from autoscaling, we adopt a binary lifecycle (Figure 2): a function is either warm (exactly one available environment) or cold (none). An invocation makes the function warm and starts a retention timer of length . A request arriving before expiry is served warm and resets the timer; otherwise the controller scales the function to zero, and the next request incurs a cold start. Restricting to one warm instance improves interpretability and removes replica-scaling effects, so observed differences are attributable to retention decisions.
Figure 2. Simplified binary warm/cold lifecycle. Retention duration governs the warmcold transition; it is the single control variable adapted at runtime.
Retention Strategies
We evaluate three static baselines, two adaptive agents, and a predictive baseline.
a) Static baselines: . The value 0 scales to zero immediately on idle (shortest retention); 60 retains the longest; 10 is an intermediate setting.
b) AIMD agent: A reactive feedback rule inspired by congestion control [15]. A cold execution multiplicatively increases retention to suppress future cold starts; a sustained run of warm executions additively decreases it to release idle capacity:
with multiplicative factor , additive step , and bounds that prevent unstable adaptation. The rule reacts strongly to cold starts and relaxes gradually during stable warm phases.
c) Bandit (UCB1) agent: An online-learning policy that selects from a discrete action set , treating each duration as an arm. After a round-robin warm-up that samples each arm once, it chooses by the UCB1 rule [14]:
where is the mean reward of arm and its selection count. The reward penalizes both sides of the trade-off, charging a fixed penalty for a cold execution and a smaller penalty that grows with the chosen retention duration, so the agent gravitates toward windows that keep both cold starts and warm time down. It needs no workload forecast and no offline training.
d) Predictive baseline (histogram): As an adaptive reference, we add a Shahzad-style predictive keep-alive [5]: per function it keeps a short history of recent inter-arrival times and sets to their 95th percentile, so regular traffic gets a short window and bursty traffic a longer one. Like the agents it adapts online, but it estimates the arrival distribution rather than optimizing the trade-off directly.
Algorithm 1: Retention enforcement and policy updates
Controller loop (every $\Delta$ seconds): 1 for each monitored function f: 2 if replicas(f) = 0: state(f) ← cold; continue 3 idle ← idleTime(f); T ← store[f] 4 if idle > T: 5 scaleToZero(f); state(f) ← cold 6 else: keepWarm(f)
AIMD update (after invocation, outcome o): 7 if o = cold: T ← min(aT, T_{\max}); streak ← 0 8 else if streak ≥ S: T ← max(T − b, T_{\min}); streak ← 0
Bandit (UCB1) update (after invocation): 9 r ← −(20 · [o = cold]) − 0.05 T 10 update $\hat{\mu}_T$, $n_T$ with r; t++ 11 store[f] ← arg max_i \left(\hat{\mu}_i + \sqrt{2 \ln t/n_i}\right)
Retention Controller
Because OpenFaaS/faasd exposes no configurable post-idle keep-alive, a dedicated controller (Figure 3) supplies it externally. On each tick it checks whether a function has active replicas; if not, it records the cold state. If warm, it reads the function’s idle time and the current from a shared store and, when idle time exceeds , triggers scale-to-zero; otherwise the function is kept warm. Adaptive policies write updated durations to the shared store, while enforcement stays entirely within the controller (R7).
Figure 3. Retention controller loop. Policy decisions enter only through the shared store; lifecycle enforcement (scale-to-zero) is fully contained in the controller.
Algorithm 1 states the controller loop together with the two policy update rules. Enforcement (lines 1–8) is policy-agnostic and reads only the shared store; the AIMD and bandit update routines write to that store after each invocation, so a new policy can be added without touching lifecycle logic.
Implementation
The prototype is implemented in Python 3.12 and runs on an Ubuntu 24.04 guest in a lightweight VM on an Apple M1 Pro host (16 GB RAM, macOS 26.5.1). OpenFaaS is deployed with the lightweight faasd runtime over containerd and systemd, chosen over Kubernetes to minimize orchestration complexity while retaining well-defined deployment and invocation interfaces and direct access to the container lifecycle, a practical compromise between realism and controllability.
a) Functions: Two benchmark functions use the python3-http template. fastpy is a lightweight handler with minimal startup cost; slowinitpy adds an initialization delay executed only on a cold path, modeling a more cold-start-sensitive workload. Sharing the runtime and deployment configuration isolates initialization behavior as the only difference.
b) Controller and scale-to-zero: The controller runs as an external Python process with a configurable check interval, monitored function set, and shared store. Since faasd provides no native post-idle retention, scale-to-zero is realized by interacting directly with containerd: tasks are terminated and deleted via ctr, then containers and images removed, so the next invocation must recreate the environment. A scheduling lock prevents concurrent scale operations on a function and retry logic improves teardown reliability.
c) Policies: The AIMD policy updates after each invocation, using multiplicative factor on a cold execution and additive decrease s after five consecutive warm executions (an error response resets the streak counter), with bounds s. The bandit uses arms s with a cold-execution penalty of 20 and a warm-cost penalty weighted by 0.05 per retained second, after a one-pass round-robin warm-up. The histogram baseline uses the 95th percentile of the last 20 inter-arrival times, bounded to [5, 120] s.
d) Cold-start detection: faasd exposes no explicit cold-start signal, so the experiment runner queries the active replica count immediately before each invocation and classifies an execution as cold when , a reproducible proxy for the warm/cold path. We validated this proxy against logged deployment latency: every cold-labeled invocation recorded a non-zero environment-creation latency (mean 0.2 s) and every warm-labeled invocation recorded zero. This 0.2 s is the containerd container-recreation cost the controller measures; the multi-second cold latencies reported later add application-level initialization on top (e.g., slowinitpy’s 3 s), so the two are not in conflict. Transient connection failures during initialization are handled by bounded retries. Every invocation logs platform state, cold classification, latency components, the active , and the policy decision.
Experimental Setup
Workloads
Three workload classes exercise different invocation dynamics: steady issues requests at a fixed 8 s inter-arrival interval; bursty alternates bursts of five requests at 0.5 s spacing with 25 s idle gaps; and trace-derived replays the Huawei Serverless Data Release 2023 [16]. Because the trace provides per-second request counts rather than replayable events, counts were expanded into individual invocation events with relative timestamps (capped at 100 events, with idle gaps capped at 10 min), and replayed with a speed-up to bound experiment duration while preserving relative ordering.
a) Timescale: All temporal parameters, namely inter-arrival intervals, idle gaps, retention windows, and the trace replay, are deliberately compressed to a common laboratory timescale. Because a function is served cold exactly when its idle gap exceeds the retention window, cold-start behavior depends on the ratio of window to idle gap rather than on absolute durations. The baselines bracket the gap scale of the workloads (0.5–25 s): a window shorter than, comparable to, and longer than the typical idle gap. Production keep-alive timers operate at minute scale but face minute-to-hour idle gaps, placing them in the same three regimes.
Configurations and Procedure
Each configuration is a (policy, function, workload) triple. We evaluate six policies (three static, AIMD, bandit, and the histogram baseline) two functions three workloads. Every run executes 100 invocations and is repeated three times under identical conditions (Table II), with function state reset before each run. In total, invocations were logged, i.e., 300 per (policy, function, workload) condition, on an Apple M1 Pro (16 GB, macOS 26.5.1) running an Ubuntu 24.04 VM.
| Parameter | Configuration |
| Functions | fastpy, slowinitpy |
| Static policies | |
| Adaptive policies | AIMD, Bandit (UCB1) |
| AIMD bounds / params | , , , streak=5 |
| Bandit action space | |
| Predictive baseline | histogram, p95 of recent IATs, |
| Workloads | steady, bursty, trace-derived |
| Invocations per run | 100 |
| Repetitions | 3 |
| Platform | faasd, Ubuntu 24.04 VM (M1 Pro) |
Table II. Experimental parameters.
Metrics
We report four metrics. The cold-start rate is the fraction of invocations classified cold (primary objective; lower is better). Mean response latency and the 95th-percentile (P95) latency capture average and tail responsiveness; P95 is emphasized because cold executions create heavy-tailed delays. Accumulated warm time (the summed seconds environments stayed warm) stands in for retained resource cost, where lower is better at a given cold-start level. Because retention affects both responsiveness and resource use, no single metric is sufficient; the relevant question is the trade-off each policy achieves. All reported values are means over three repetitions; run-to-run variation is small (standard deviation percentage points for cold-start rate and ms for mean latency) and is shown as error bars in Figure 4, Figure 6, and Figure 7.
Figure 4. Aggregate cold-start rate per policy (lower is better). The adaptive agents (AIMD red, bandit orange) approach the 60 s baseline and beat the predictive histogram baseline (green). Error bars: std over three runs.
Figure 6. Mean response latency per policy. Adaptive agents cut mean latency by versus immediate scale-to-zero (they approach the longest-retention baseline on the tail; mean latency remains above it).
Figure 7. P95 (tail) latency, pooled per policy. Short static windows incur multi-second tails; Static 60 s, AIMD, and Bandit cluster near 32–34 ms, while the histogram baseline is higher (per-function tails in Table IV).
Results and Discussion
Cold-Start Reduction
Figure 4 reports the aggregate cold-start rates. Immediate scale-to-zero (Static 0s) is the worst at 63.0%, as expected, since every idle gap reclaims the environment. Lengthening the fixed window reduces the rate substantially, to 12.3% at 10 s and 1.0% at 60 s. Both adaptive agents reach the same low-cold-start regime without a manually selected long timeout, at 3.3% for AIMD and 3.0% for the bandit, and both beat the predictive histogram baseline (5.0%).
Breaking the same numbers down by workload (Figure 5) shows why a fixed window fails to generalize across workloads. Static 0 s swings from 36% on the trace to a full 100% on steady traffic, where the 8 s arrival interval always outlasts the zero window and every request ends up cold. Static 10 s flips the story: excellent on steady traffic (1%) but poor on bursty traffic (20%), because the 25 s idle gaps outlive the window. No single fixed value covers all three patterns. The adaptive agents stay at or below 6% throughout, with the bandit reaching 1% (steady) and 2% (bursty), and the histogram baseline stays within 3–9%.
Figure 5. Cold-start rate per workload and policy. The best static window depends on the workload (e.g., Static 10s is good for steady but weak for bursty traffic), while adaptive policies remain low throughout.
Latency
Because cold executions dominate latency, the latency results follow the cold-start results (Figure 6–Figure 7). Mean latency falls from 1252 ms at Static 0 s to 40 ms at Static 60 s; the bandit reaches 79 ms and AIMD 86 ms, about 94% below scale-to-zero, though still above Static-60’s 40 ms, while the predictive baseline sits higher at 127 ms. The parity with the fixed baseline is on the tail, not the mean. Static 0 s and Static 10 s show P95 tails above 3400 ms owing to frequent cold starts, whereas Static 60 s, AIMD, and the bandit cluster tightly (Figure 7); per function the bandit’s tail matches the longest fixed baseline exactly (22 ms on fastpy, 35 ms on slowinitpy, Table IV), while the histogram is higher and function-dependent (82 and 213 ms). We report P95 per function, since percentiles do not average across a mixed population. In effect, warm executions occupy a similar low-latency band across policies, and the policies differ mainly in how often a request incurs the slow cold-start tail.
| Policy | fastpy Cold% | fastpy Mean (ms) | fastpy P95 (ms) | slowinitpy Cold% | slowinitpy Mean (ms) | slowinitpy P95 (ms) |
| Static 0 s | 61.7 | 264 | 529 | 64.3 | 2240 | 3565 |
| Static 10 s | 12.3 | 63 | 382 | 12.3 | 454 | 3507 |
| Static 60 s | 1.0 | 20 | 22 | 1.0 | 60 | 35 |
| AIMD | 3.3 | 30 | 28 | 3.3 | 142 | 36 |
| Bandit | 3.0 | 29 | 22 | 3.0 | 129 | 35 |
| Histogram | 5.0 | 51 | 82 | 5.0 | 204 | 213 |
Table IV. Per-function results (aggregated over workloads)
Warm Time and the Trade-off
For the static policies, accumulated warm time (Figure 8) grows as expected: s at 0 s, s at 10 s, and s at 60 s. The adaptive agents fall between the extremes, at s (AIMD) and s (bandit), both under the 60 s baseline. This is the central result: the bandit approaches Static 60 s on cold starts (3.0% vs. 1.0%) and matches it on tail latency, at roughly 13% less warm time. The predictive baseline uses even less warm time (s) but pays with more cold starts (5.0%), a different, less favorable point on the same curve. In trade-off terms, each static timeout commits the operator to a single cold-start/warm-time operating point chosen in advance, whereas the adaptive agents settle at a favorable point, namely low cold starts at less warm time than the longest baseline, without any prior knowledge of the workload.
Figure 8. Total accumulated warm time per policy (proxy for retained resource cost). Both adaptive agents use less warm time than the longest-retention 60 s baseline.
Adaptive Policy Behavior
We next verify that the agents adapt to the workload rather than converging on a single fixed value. Table III reports the mean retention duration each agent selects per workload, and the pattern is consistent with the traffic. On steady traffic, where an 8 s interval is covered by a short window, both agents settle low (AIMD 11.5 s, bandit 20.7 s) and conserve warm time. On bursty traffic the 25 s idle gaps make early teardown costly, and both increase their windows (AIMD to 34.5 s); the bandit rises further to 58.3 s, near its longest arm, trading warm time for cold-start avoidance. The trace, with irregular spacing, yields AIMD 43.2 s and bandit 39.9 s; for the bandit this sits between its steady and bursty settings, whereas AIMD, reacting to each cold start, settles slightly higher than on bursty traffic. The two reach similar outcomes by different mechanisms: AIMD responds multiplicatively to each cold start, whereas the bandit’s reward estimates steer it toward the duration that best balances the cold-start penalty against the warm-time penalty for that workload. The histogram baseline tracks the arrival distribution in the same direction (8.5 s on steady, 24.1 s on bursty), confirming that all three policies adapt per workload rather than settling on one value.
| Policy | Steady | Bursty | Trace |
| AIMD | 11.5 | 34.5 | 43.2 |
| Bandit | 20.7 | 58.3 | 39.9 |
| Histogram | 8.5 | 24.1 | 31.0 |
Table III. Mean selected (s) by workload
Effect of Function Startup Cost
The two benchmark functions differ only in how expensive their initialization is, so looking at them separately (Table IV) shows how startup cost changes the payoff from retention control. The cold-start rate is basically the same for both
under the 60 s baseline. This is the central result: the bandit approaches Static 60 s on cold starts (3.0% vs. 1.0%) and matches it on tail latency, at roughly 13% less warm time. The predictive baseline uses even less warm time (s) but pays with more cold starts (5.0%), a different, less favorable point on the same curve. In trade-off terms, each static timeout commits the operator to a single cold-start/warm-time operating point chosen in advance, whereas the adaptive agents settle at a favorable point, namely low cold starts at less warm time than the longest baseline, without any prior knowledge of the workload. functions under a given policy, which is expected: the rate is determined by invocation timing, not by how heavy the init is. The latency consequences are a different matter. A cold call to slowinitpy is much costlier, so Static 0 s runs to a 2240 ms mean and a 3565 ms P95, against 264 ms and 529 ms for fastpy. Avoiding cold starts therefore yields a larger benefit on the cold-start-sensitive function, and the adaptive agents capture it: the bandit reduces slowinitpy’s mean latency from 2240 ms to 129 ms, a 94% reduction, and matches the longest-retention baseline on P95 (35 ms for both). The same per-function control thus provides the greatest benefit where cold starts are most costly, which motivates making per-function (R2).
Discussion
Three observations stand out. First, the bandit’s advantage over AIMD is consistent with their mechanisms: across the three runs its cold-start rate (3.0% vs. 3.3%) and mean latency (79 vs. 86 ms) were lower. At this short horizon the gap is within run-to-run variation; a longer-horizon study (Sec. VI-H) isolates it and shows it is statistically significant. On tail latency the two are effectively tied. The bandit keeps a reward estimate per arm and balances exploration against exploitation, so it converges on the arm suited to the current traffic; AIMD reacts more slowly to pattern changes. Second, against the predictive histogram baseline the bandit is clearly better on cold starts (3.0% vs. 5.0%) and mean latency (79 vs. 127 ms); the histogram trades those for slightly less warm time, so the lightweight online agents are competitive with, and here better than, a predictive keep-alive without ever estimating the arrival distribution. Third, at the 100-invocation horizon the two agents are close because the online learner has little room to converge; the longer-horizon analysis of Sec. VI-H confirms the bandit’s advantage widens and becomes statistically significant once it does.
Parameter Sensitivity
To check robustness to the hand-set parameters, we swept them one at a time on the trace workload with slowinitpy (Table V). Behavior moves smoothly and predictably: raising the bandit’s cold-start penalty (10→40) trades warm time for fewer cold starts (10%→3%), while the warm-cost weight does the reverse (0.10 gives 12%); a finer arm set and a gentler AIMD factor land in between. The two lowest-cold-start settings (penalty 40 and weight 0.025) coincide because both drive the bandit to the same longest-arm operating point. No setting collapses, and the paper’s defaults sit in the middle of the useful range, so the result is not an artifact of a single lucky configuration.
| Configuration | Cold% | Mean (ms) | Warm ( s) |
| Bandit penalty 10 | 10.0 | 381 | 35.8 |
| Bandit penalty 20 | 6.0 | 236 | 65.4 |
| Bandit penalty 40 | 3.0 | 131 | 83.1 |
| Bandit weight 0.025 | 3.0 | 131 | 83.1 |
| Bandit weight 0.10 | 12.0 | 448 | 23.4 |
| Bandit arm 5/15/30/60 | 7.0 | 272 | 56.2 |
| AIMD | 8.0 | 307 | 45.1 |
| AIMD | 4.0 | 167 | 75.2 |
Table V. Parameter sweep (trace workload, slowinitpy). Defaults in bold.
Convergence and Statistical Significance
The runs above use a 100-invocation horizon and three repetitions. To test whether the bandit’s edge is real once the online learner converges, we reran the bursty workload at a longer horizon (250 invocations) over eight repetitions, adding ±15% jitter to inter-arrival times so repetitions genuinely differ (a per-repetition seed keeps the policies paired). Table VI gives per-policy means and pairwise Mann–Whitney tests against the bandit. At the longer horizon the bandit converges to a stable operating point and significantly outperforms the baselines it is most naturally compared to: versus AIMD it lowers the cold-start rate from 2.3% to 0.8% () and mean latency from 76.8 to 45.4 ms (); versus the histogram predictor the margins are larger, including tail latency (33 vs. 647 ms). The longest fixed baseline, Static-60, edges the bandit on cold starts (0.4% vs. 0.8%) only because a 60 s window happens to suit this workload; the bandit reaches comparable behavior without being given that window, at slightly lower warm time than Static-60 (2592 vs. 2641 replica-seconds, , a small margin); AIMD and the histogram in fact use less warm time still). The bandit and Static-60 are deterministic across repetitions (they settle clear of the idle-gap boundary), so the significance is carried by the run-to-run spread of AIMD and the histogram, whose distributions do not overlap the bandit’s operating point.
| Policy | Cold% | Mean (ms) | P95 (ms) | Warm (s) |
| Static-60 | 0.4*** | 36.3*** | 31.6* | 2641** |
| Bandit | 0.8 | 45.4 | 33.1 | 2592 |
| AIMD | 2.3*** | 76.8*** | 34.7 ns | 2392*** |
| Histogram | 6.1*** | 154.8*** | 646.7*** | 1880*** |
Table VI. CONVERGENCE/SIGNIFICANCE STUDY (BURSTY WORKLOAD, 250 INVOCATIONS, 8 JITTERED REPETITIONS). PER-POLICY MEANS; MARKERS GIVE THE TWO-SIDED MANN-WHITNEY SIGNIFICANCE OF EACH BASELINE vs. the bandit FOR THAT METRIC: ***, **, *, ns NOT SIGNIFICANT (). AIMD AND THE HISTOGRAM CARRY RUN-TO-RUN SPREAD (E.G., AIMD COLD-RATE 95% CI [2.2, 2.4]); THE BANDIT AND STATIC-60 ARE DETERMINISTIC ACROSS REPETITIONS, SO SIGNIFICANCE RESTS ON THE BASELINES’ SPREAD NOT OVERLAPPING THE BANDIT’S VALUE.
Generality Across Function Types
To check that the results are not specific to the two original functions, we evaluated every policy on two *additional, more realistic functions: a JSON transform API (parse, validate, and aggregate a record set) and an image-resize function (decode and produce several thumbnails with Pillow), run alongside the two originals. This ran as a self-contained sweep on a single x86 faasd host (four functions × three workloads × four policies × three repetitions); because it is a separate testbed from the main arm64 study we report it as its own comparison rather than merging it into the main tables.
The policy ordering carries over unchanged to the realistic functions (Table VII). Static-60 again attains the fewest cold starts but at the most warm time; the bandit uses about 21% less warm time than Static-60 (523 vs. 660 × replica-seconds) at a modest cold-start cost, and it again beats the predictive histogram on both cold starts (4.1% vs. 6.8%) and, sharply, on tail latency (413 vs. 2205 ms; the histogram’s mispredictions inflate the tail). Per-function absolute latency tracks each function’s compute weight, from about 17 ms warm for fastpy to about 430 ms for image resizing, while the relative ordering of policies is the same for every function. This sweep used a fixed inter-arrival schedule (no jitter), so it is a consistency check across function types rather than a significance test; the significance result is established separately in Sec. VI-H.
| Policy | Cold % | Mean ms | P95 ms | Warm (s) |
| Static-60 | 1.4 | 149 | 396 | 660 |
| AIMD | 4.5 | 245 | 420 | 479 |
| Bandit | 4.1 | 231 | 413 | 523 |
| Histogram | 6.8 | 311 | 2205 | 420 |
Table VII. GENERALITY ACROSS FOUR FUNCTIONS (JSON API AND IMAGE-RESIZE ADDED TO THE TWO ORIGINALS) ON AN X86 FAASD TESTBED: PER-POLICY MEANS OVER THREE WORKLOADS AND THREE REPETITIONS. THE POLICY ORDERING IS UNCHANGED FROM THE MAIN STUDY, AND THE BANDIT BEATS THE PREDICTIVE HISTOGRAM ON BOTH COLD STARTS AND TAIL LATENCY (Sec. VI-I).
Decoupling from Autoscaling
The main study fixes the replica count at one to isolate retention; faasd cannot demonstrate coexistence with an autoscaler because it does not scale a function horizontally. We therefore reproduce the decoupling on a genuine multi-node Kubernetes cluster (three-node k3s: one control-plane and two workers) under the platform’s own autoscaler. Crucially, horizontal scaling here is owned by the stock Kubernetes Horizontal Pod Autoscaler, HPA, autoscaling/v2, CPU-utilisation target 50%, fed by the cluster metrics-server), an autoscaler we do not author or control. Our retention controller acts only as the activation layer: once idle time exceeds it removes the HPA and scales the Deployment to zero, and on the next burst it restores the HPA and lets Kubernetes scale out again, after which the first request is served by a freshly started replica (a genuine cold start). This activation/scaling split mirrors how production autoscalers such as KEDA separate the decision to keep a function alive from the decision of how many replicas to run. The function is a CPU-bound HTTP workload so the CPU-driven HPA has a real signal to react to. We sweep three idle-gap regimes (18/45/90 s) × three policies × five repetitions, ramping the offered load (maximum five replicas).
The replica-count side decouples cleanly, now against an autoscaler we did not write. Across every policy and regime the peak replica count is 5.0 with standard deviation 0.0, and the replicas spread across both worker nodes in every cell (distinct nodes in use = 2.0, std 0.0): under identical load the HPA drives every policy to the same peak across the same two machines, regardless of which retention policy runs (Figure 9, top and middle). What differs between policies is only how many replicas persist between bursts, which is precisely the retention lever and the source of the warm-time separation below. Because the scaler is now a stock, independently authored controller rather than our own loop, and because it genuinely spans multiple nodes, this is a stronger test of composition than a single-node custom-scaler setup: the two loops compose without interference even though neither was written to be aware of the other. Retention is the lever that moves warm time (Figure 9, bottom; Table VIII): the adaptive policies hold far less warm replica-time than Static-60 at a comparable, uniformly low cold-start rate. At the 90 s gap the bandit matches Static-60’s cold-start rate (0.42% for both) while using about 60% less warm time (1058 vs. 2647 replica-seconds); at 45 s it uses roughly a third of Static-60’s warm time (1131 vs. 3523) for a sub-0.5% cold rate. Static-60 attains the lowest cold rate when its 60 s window covers the gap (18/45 s), but at 2–3× the warm cost, and once the gap grows to 90 s its window can no longer bridge it and its cold rate rises to the adaptive policies’ level while its warm cost stays high. Cold-start rates stay at or below 1.2% throughout. The two levers move independently: replica count with load, retention duration with the policy.
Figure 9. Decoupling on a multi-node cluster under the stock Kubernetes HPA (45 s idle gap). Top: the warm replica count follows the same load-driven 1→5 trajectory for all policies (peak 5.0, std 0.0 across all cells). Middle: replicas spread across both worker nodes (up to 2). Bottom: the retention window is set independently per policy (Static-60 fixed, bandit low, AIMD adapting). The HPA sets the replica count from load; retention sets the warm floor between bursts.
| Idle gap | Static-60 | AIMD | Bandit |
| Warm time (replica-seconds) | |||
| 18 s | 2585±19 | 854±96 | 1912±822 |
| 45 s | 3523±47 | 788±80 | 1131±71 |
| 90 s | 2647±102 | 791±104 | 1058±80 |
| Cold-start rate (%) | |||
| 18 s | 0.01 | 1.13 | 0.17 |
| 45 s | 0.01 | 0.71 | 0.48 |
| 90 s | 0.42 | 0.47 | 0.42 |
Table VIII. Multi-node Kubernetes under the stock HPA: pool warm time (warm replica-seconds, mean ± std over five runs) and mean cold-start rate by idle gap and policy. In every cell the peak replica count is 5.0 (std 0.0) and replicas span 2.0 nodes (std 0.0), independent of policy; the policy moves warm time and cold rate, not the peak (Sec. VI-J).
This experiment runs on x86 OVH instances, a different testbed and CPU architecture from the arm64 single-instance study; because every comparison here is within this one cluster and relative across policies, the decoupling conclusion is tested independent, and reproducing the mechanism on separate hardware strengthens rather than weakens it. We do not compare absolute latencies across the two testbeds.
Deployment Considerations and Overhead
The controller is a single external process that polls replica/idle state once per interval and writes one scalar per function, so its cost is per tick and independent of request rate. The agents are cheap too: AIMD is a constant-time update and UCB1 keeps two scalars per arm, with no training data or model. Using only the platform’s external interfaces, the design ports to any FaaS runtime exposing them and layers beneath a replica autoscaler (Sec. VI-J). These properties meet the requirements of § 3 (R1–R3, R5–R8); only reproducible cold-start generation (R4) is partial, which is why we aggregate over repetitions.
is why we aggregate over repetitions.
Threats to Validity and Limitations
The prototype runs on a single faasd host, so absolute latencies are environment-specific, though the relative ordering of policies is the object of study. The workload classes cannot represent the full diversity of serverless applications, and the 100-invocation horizon bounds online-learning convergence; the main study uses two functions, though Sec. VI-I shows the policy ordering carries over to two additional realistic functions (a JSON API and image resizing) on a separate testbed. The main study uses a single-instance lifecycle; the decoupling study (Sec. VI-J) runs on a multi-node cluster under the stock Kubernetes HPA, and other production autoscalers (for example KEDA or custom-metric HPAs) and larger clusters remain future work. That study also runs on a different testbed and CPU architecture (x86) from the main single-instance study (arm64); since its comparisons are within-cluster and relative across policies, the decoupling conclusion is testbed independent, and we do not compare absolute latencies across testbeds. We mitigate these by fixing the environment across policies, resetting state between runs, and averaging over repetitions. We compare against static timeouts and a predictive histogram baseline; RL-based policies are future work, and the agents’ arms and bounds encode a coarse prior on the idle-gap scale that the sweep (Table V) shows is not brittle. We present this as a controlled proof of concept, not a production benchmark.
a) Non-stationarity of the bandit reward: Our UCB1 controller assumes each keep-alive arm has a stationary reward distribution. In practice a given window’s reward can drift as the arrival regime changes within a run, so an index policy that averages over all past pulls adapts only slowly after such a shift. The standard remedy is to discount or window the observations: discounted UCB and sliding-window UCB retain finite-time guarantees under abruptly changing rewards [17]. Because the retention and scaling levers are decoupled, this is a drop-in change to the controller that leaves the autoscaling path untouched, and we leave a D-UCB/SW-UCB evaluation under within-run regime changes to future work.
b) Warm time as a cost proxy: The reward charges accumulated warm time rather than a directly metered resource cost. At a fixed per-instance footprint, keep-alive duration is proportional to the reserved resource-time (instance-seconds) that keep-alive pricing bills for, so minimising accumulated warm time minimises the reserved resource-time that dominates keep-alive cost; warm time is also platform independent and needs no per-provider billing hooks, which keeps the controller portable. Replacing the proxy with directly measured CPU and memory consumption, and with provider billing where available, is future work.
c) Timescale: Production platforms retain instances for minutes (roughly 5–27 min on AWS, about 15 min on Google Cloud [18]), whereas faasd has no native keep-alive. Our windows are smaller in absolute terms, but we preserve the governing window-to-gap ratio; applying the static policy analytically at the real timescale reproduces the same trade-off (cold-start rate falling from 100% to 18% at 1 min and about 1% by 15 min), confirming it is not a compression artifact. Two caveats: cold-start cost is fixed in real time while warm time scales with the clock, slightly favoring retention-heavy policies; and the bandit’s reward constants are calibrated to this timescale, though the method itself is scale-independent.
Conclusion and Future Work
This paper argued that the keep-alive window is best modeled not as a fixed timeout but as a per-function control variable adapted online and kept separate from autoscaling, a lightweight, training-free target that, to our knowledge and per the positioning of Table I, prior work has not isolated in this way. We supported this with an implemented system: an external controller for OpenFaaS/faasd that requires no platform changes, driven by two simple agents, a reactive AIMD rule and a UCB1 bandit, that adjust the window from runtime feedback. On steady, bursty, and trace-derived workloads both agents reached the low-cold-start, low-latency region; the bandit in particular came close to the longest-retention fixed baseline on cold starts and matched it on tail latency at about 13% less warm time, and outperformed a predictive histogram keep-alive on cold starts and latency. A parameter sweep showed the result is robust to the agents’ settings. At a converged horizon the bandit’s advantage is statistically significant, and, on a multi-node Kubernetes cluster under the platform’s own Horizontal Pod Autoscaler, the controller coexists with an autoscaler it does not control: the replica count follows load and spreads across nodes independently of the retention policy. Since no fixed timeout was best across all workloads, an adaptive window is a reasonable default. Future work includes other production autoscalers (KEDA, custom-metric HPAs) and larger clusters, non-stationary bandit variants (discounted or sliding-window UCB) evaluated under within-run regime changes, richer signals (contextual bandits or a forecasting hybrid), production-scale horizons, multi-replica retention lifecycles that hold more than one warm instance, and direct CPU/memory/cost measurement in place of the warm-time proxy.
Open Data
The controller, policies, workloads, and raw measurements used in this paper are available for reproducibility and future improvements at the anonymized, view-only repository https://bit.ly/44VLz6S [19].
References
- [1]H. Shafiei, A. Khonsari, and P. Mousavi, “Serverless computing: A survey of opportunities, challenges, and applications,” ACM Computing Surveys, vol. 54, no. 11s, Nov. 2022.
- [2]I. Baldini, P. Castro, K. Chang, P. Cheng, S. Fink, V. Ishakian, N. Mitchell, V. Muthusamy, R. Rabbah, A. Slominski, and P. Suter, Serverless Computing: Current Trends and Open Problems. Springer Singapore, 2017, pp. 1–20.arxiv.org/abs/1706.03178
- [3]D. Taibi, J. Spillner, and K. Wawruck, “Serverless computing—where are we now, and where are we heading?” IEEE Software, vol. 38, no. 1, pp. 25–31, 2021.DOI
- [4]M. Golec, G. K. Walia, M. Kumar, F. Cuadrado, S. S. Gill, and S. Uhlig, “Cold start latency in serverless computing: A systematic review, taxonomy, and future directions,” ACM Computing Surveys, vol. 57, no. 3, Nov. 2024.DOI
- [5]M. Shahrad, R. Fonseca, I. Goiri, G. Chaudhry, P. Batum, J. Cooke, E. Laureano, C. Tresness, M. Russinovich, and R. Bianchini, “Serverless in the wild: Characterizing and optimizing the serverless workload at a large cloud provider,” in 2020 USENIX Annual Technical Conference (USENIX ATC 20). USENIX Association, Jul. 2020, pp. 205–218.arxiv.org/abs/2003.03423
- [6]A. Joosen, A. Hassan, M. Asenov, R. Singh, L. Darlow, J. Wang, Q. Deng, and A. Barker, “Serverless cold starts and where to find them,” in Proceedings of the Twentieth European Conference on Computer Systems (EuroSys ’25). Association for Computing Machinery, 2025, pp. 938–953.DOI
- [7]I. E. Akkus, R. Chen, I. Rmac, M. Stein, K. Satzke, A. Beck, P. Aditya, and V. Hilt, “SAND: Towards high-performance serverless computing,” in 2018 USENIX Annual Technical Conference (USENIX ATC 18). USENIX Association, Jul. 2018, pp. 923–935.
- [8]A. Fuerst and P. Sharma, “FaasCache: Keeping serverless computing alive with greedy-dual caching,” in Proceedings of the 26th ACM International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS ’21). Association for Computing Machinery, 2021, pp. 386–400.
- [9]K. Sankaranarayanan, R. B. Roy, and D. Tiwari, “Pulse: Using mixed-quality models for reducing serverless keep-alive cost,” in SC24-W: Workshops of the International Conference for High Performance Computing, Networking, Storage and Analysis, 2024, pp. 99–109.
- [10]T. N. Nguyen, “Holistic cold-start management in serverless computing cloud with deep learning for time series,” Future Generation Computer Systems, vol. 153, no. C, pp. 312–325, Apr. 2024.DOI
- [11]R. B. Roy, T. Patel, and D. Tiwari, “Icebreaker: Warming serverless functions better with heterogeneity,” in Proceedings of the 27th ACM International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS ’22). Association for Computing Machinery, 2022, pp. 753–767.DOI
- [12]S. Agarwal, M. A. Rodriguez, and R. Buyya, “On-demand cold start frequency reduction with off-policy reinforcement learning in serverless computing,” arXiv preprint arXiv:2308.07541, 2024.arxiv.org/abs/2308.07541
- [13]T. Lattimore and C. Szepesvári, Bandit Algorithms. Cambridge University Press, 2020.
- [14]P. Auer, N. Cesa-Bianchi, and P. Fischer, “Finite-time analysis of the multiarmed bandit problem,” Machine Learning, vol. 47, no. 2, pp. 235–256, 2002.DOI
- [15]D.-M. Chiu and R. Jain, “Analysis of the increase and decrease algorithms for congestion avoidance in computer networks,” Computer Networks and ISDN Systems, vol. 17, no. 1, pp. 1–14, 1989.
- [16]A. Joosen, A. Hassan, M. Asenov, R. Singh, L. Darlow, J. Wang, and A. Barker, “How does it function? characterizing long-term trends in production serverless workloads,” in Proceedings of the 2023 ACM Symposium on Cloud Computing (SoCC ’23). Association for Computing Machinery, 2023, pp. 443–458.DOI
- [17]A. Garivier and E. Moulines, “On upper-confidence bound policies for switching bandit problems,” in Algorithmic Learning Theory (ALT 2011), ser. Lecture Notes in Computer Science, vol. 6925. Springer, 2011, pp. 174–188.DOI
- [18]L. Wang, M. Li, Y. Zhang, T. Ristenpart, and M. Swift, “Peeking behind the curtains of serverless platforms,” in 2018 USENIX Annual Technical Conference (USENIX ATC 18). USENIX Association, Jul. 2018, pp. 133–146.
- [19]“Artifact: controller, policies, workloads, and raw results,” http://bit.ly/44VLz6S (anonymized view-only), 2026.








