\n
The Serverless Paradox: We Got Rid of Servers—and Latency Appeared
Serverless is known as an execution model where you “don’t have to worry about servers.” When there are no requests, compute resources can be scaled down or removed to save costs. When requests arrive, the execution environment can quickly scale up to meet demand. Developers can focus on code and business logic instead of infrastructure.
But this efficient model comes with a paradox:
Costs go down when there are no requests—but when requests return, users may have to wait.
The culprit is the cold start.
When Does a Cold Start Happen in Serverless?
If a function hasn’t been invoked for a while, the platform removes its execution environment from memory to save costs. When a new request arrives, the platform doesn’t simply run the code—it has to prepare the entire environment needed to execute it.
This typically involves:
- Creating a function execution instance or container
- Initializing the runtime
- Loading code and dependencies
- Configuring environment variables, networking, and permissions
- Executing the function code
If a warm instance is already available, the request can run immediately. But if the execution environment has been removed, the added setup time leads to cold-start latency.
The impact is especially noticeable with workloads such as:
- API functions invoked intermittently
- Scheduler functions that run periodically
- Event-driven data processing
- Services subject to sudden traffic spikes
- Workflows where multiple functions run in sequence, such as order, payment, and notification flows
For users, this may mean a slower-loading first screen, a payment request that takes longer than usual, or delayed notifications.
Would Keeping Functions Running Solve the Problem?
The most intuitive solution is simple: keep function instances in memory longer. This is often called a warm-keeping or keep-alive strategy.
For example, if every function is kept alive for 10 minutes after its last invocation, functions called again within that window are more likely to run without a cold start. But this approach creates another problem:
Even functions that aren’t being called continue to occupy memory.
That may not be a big deal if you have a few dozen functions. But the picture changes on a serverless platform running thousands—or more. If low-priority, idle functions keep taking up memory, there may not be enough room to place important functions that are about to be called.
A fixed keep-alive policy also fails to account for the differences between functions.
| Function behavior | Problem with fixed warm-keeping | |---|---| | Invoked every minute | If the retention period is too short, cold starts keep happening | | Invoked every 30 minutes | If the retention period is too long, memory is wasted most of the time | | Goes quiet after a short burst | The function stays warm unnecessarily after the burst ends | | Triggered by irregular events | A simple time-based rule can’t easily predict the next invocation |
In the end, keeping instances alive longer to reduce cold starts increases memory waste. Removing them quickly to save memory increases cold starts.
The Core Serverless Challenge Isn’t “How Long,” but “When”
To solve this problem properly, functions can’t all be managed the same way. The key questions are:
- When is this function likely to be invoked next?
- Is it worth preparing an execution environment in advance?
- If memory is limited, which function should be removed first?
- How should functions be distributed across workers to keep things balanced?
In other words, running serverless effectively isn’t simply a matter of keeping functions alive longer. It’s about keeping the right functions, at the right time, in the right place.
That’s where prediction-based scheduling becomes important. By analyzing a function’s invocation history, it’s possible to distinguish regular calls, bursts of closely spaced calls, and calls that tend to follow another function. This can reduce cold starts without blindly increasing memory.
In the next section, we’ll look at how SPES-Ext addresses this balancing challenge: how it understands function invocation patterns and brings prewarming, eviction, and worker placement together in a single policy.
Reading the Rhythm of Serverless Function Invocations: When Will the Next Request Arrive?
The number of function invocations alone doesn’t tell us when the next request will arrive. Even with the same 100 invocations, 100 clustered within a minute call for a very different response than 100 evenly spread across a day.
In a Serverless environment, what matters isn’t simply invocation frequency, but the rhythm that emerges between invocations. A request that arrives after a short pause may signal that the same burst is still underway. By contrast, an invocation after a long silence is more likely to mark the start of a new burst.
SPES-Ext analyzes precisely these “gaps.”
Waiting Time Matters More Than the Interval Between Serverless Invocations
Conventional analysis focuses on the time between two invocations—in other words, the inter-arrival time. But this alone can’t fully distinguish a stream of consecutive invocations from a long idle period.
For example, suppose a function is invoked as follows:
Invocation → short gap → invocation → invocation → long gap → invocation
The short gap between the second and third invocations may indicate that the function is still within an active workload. If the execution environment is removed at this point, the next request is likely to experience a cold start.
The situation is different when a long period passes with no requests after a series of consecutive invocations. During this period, keeping the function warm may waste memory.
To distinguish between these cases, SPES-Ext uses Waiting Time (WT). Waiting Time doesn’t simply measure “how long it’s been since the last invocation.” It tracks continuous periods without invocations to assess whether the current gap is more like:
- A brief pause between bursts that are still in progress
- A predictable wait that appears in a recurring pattern
- A long idle period after the previous workload has ended
- An irregular gap that makes the next invocation difficult to predict
This distinction is key to helping a Serverless scheduler decide whether to keep a function warm, reload it in advance, or evict it from memory.
How to Tell When a Serverless Burst Ends—and the Next One Begins
From SPES-Ext’s perspective, function invocations aren’t just individual points; they form clusters along a timeline. Clusters of invocations concentrated within a short period can be viewed as bursts or waves.
Why does this perspective matter? The answer is clear.
| Invocation pattern | Simple keep-alive policy | SPES-Ext’s interpretation | |---|---|---| | Another invocation arrives after a short gap | May be evicted when the timer expires | Keep warm, considering the possibility that it’s part of the same burst | | Invocations recur at regular intervals | Relies on a fixed timeout | Predict the next invocation using past waiting times | | Long idle period | May unnecessarily occupy memory | Treat it as a signal that the burst has ended and raise eviction priority | | Sudden spike in invocations | Cold starts occur if the function isn’t ready | Consider prewarming based on similar patterns and correlations |
For example, imagine a function that runs a batch job at a certain time every day. If the intervals between invocations are generally consistent, SPES-Ext can estimate the next invocation time using the median of past waiting times or the values that occur most often.
A function that receives a stream of orders over a short period, on the other hand, requires a different approach. Just because there’s a short gap after the first invocation doesn’t mean the execution environment should be removed immediately. Follow-up requests are likely to arrive.
Serverless Prediction Also Means Knowing “When to Turn It Off”
When people talk about predictive scheduling, they often think only of prewarming. But in Serverless operations, the harder question isn’t just “When should we turn it on in advance?” It’s also “What should we turn off first?” when memory is limited.
SPES-Ext considers a function’s waiting time, predicted time until its next invocation, prediction confidence, and memory usage together. It protects functions whose next invocation is imminent and whose patterns are stable. Functions with a distant predicted invocation and low prediction confidence become candidates for eviction.
In other words, a gap isn’t simply a period of inactivity. To SPES-Ext, it’s an important operational signal that helps determine whether to prepare for the next request or reclaim the memory currently in use.
A good scheduler in a Serverless environment doesn’t just watch for the moment an invocation occurs—it also knows how to read the silence between invocations.
Should You Prewarm or Unload a Serverless Function? How Priorities Shape Its Lifecycle
When memory runs low, is it really best to unload the function that has been around the longest?
With a traditional FIFO policy, the answer is close to “yes.” Removing functions in the order they were loaded—or in the order they have gone unused—keeps the implementation simple. But in a Serverless environment, simply having been in memory for a long time is not enough to make a function a good candidate for eviction.
For example, if a payment function that has been idle for an hour is likely to run right after an order-processing function is called 30 seconds from now, removing it now could soon lead to a cold start. Conversely, even a function that was just loaded may not deserve scarce memory if its call pattern is unclear and the forecast is unreliable.
SPES-Ext tackles this problem through priority-based function lifecycle management.
In Serverless, “How Old Is the Function?” Is Not the Most Important Question
The key idea behind SPES-Ext is not to view function instances simply as warm or cold. Instead, it continuously tracks the following information for each function:
- Whether it is currently loaded in memory
- How much time has passed since its last invocation
- When its next invocation is expected
- How reliable that prediction is
- How much memory the function uses
- Whether it is associated with calls to other functions
- Whether it is currently running or idle
With this information, the scheduler can identify not merely the “oldest function,” but the function least worth keeping in memory right now.
Suppose there are two functions:
| Function | Last invocation | Predicted next invocation | Prediction confidence | Memory | Decision | |---|---:|---:|---:|---:|---| | Payment function | 20 minutes ago | In 1 minute | High | 256 MB | Keep | | Test notification function | 2 minutes ago | Unpredictable | Low | 512 MB | Evict first |
With FIFO alone, the payment function—called 20 minutes ago—might be evicted first. SPES-Ext, however, keeps the payment function because it is likely to be called in a minute, and frees memory by evicting the test notification function first—even though it uses more memory and its next invocation is uncertain.
This is the key to reducing both Serverless cold starts and wasted memory.
Serverless Prewarming: Wake Functions Just Before They’re Called
SPES-Ext does not keep every function warm all the time. Instead, it predicts the next invocation and prepares the execution environment only when that invocation is approaching.
In the paper’s experiments, the prewarming window was set to θprewarm = 2 minutes. In other words, if a function is predicted to be called within roughly two minutes, its instance is loaded into memory ahead of time.
Current time ──────────────── Predicted invocation
← 2 minutes →
Prewarming begins
This strategy differs from a simple keep-alive policy:
- Fixed keep-alive: Keep every function loaded for 10 minutes after its last invocation.
- SPES-Ext: Prepare only the functions likely to be needed soon.
A fixed keep-alive policy has the advantage of requiring no predictions, but it can leave memory occupied by functions that are never called. SPES-Ext, by contrast, narrows down which functions to prewarm by using each function’s invocation intervals, burst patterns, recurring cycles, and workflow correlations.
For example, a reconciliation function that runs around 9 a.m. every day can be prepared starting at 8:58. If a payment function typically follows an order function within a few seconds, the order function’s execution itself can signal that it is time to wake the payment function in advance.
Serverless Eviction: What Should Be Unloaded First?
When memory runs low, the scheduler must make room for new functions. Instead of treating every function equally, SPES-Ext calculates priorities and selects which functions to evict.
In general, the following are more likely to be evicted first:
- Functions with a long time until their next invocation
- Functions whose invocation predictions are unreliable
- Functions with highly variable invocation intervals
- Functions that consume a lot of memory
- Idle functions that are not currently running
It is equally clear which functions should be protected from eviction as much as possible:
- Functions currently handling a request
- Functions predicted to be called soon
- Functions with regular invocation histories and reliable predictions
- Functions expected to run next as a result of another function’s invocation
This policy goes beyond the simple rule of “first in, first out.” For a Serverless platform, the likelihood of a cold start on the next request matters more than the memory space itself.
An old function is not necessarily a low-value function.
SPES-Ext evicts the function least likely to help with future requests.
Why Invocation Patterns Change the Priority
SPES-Ext interprets each function’s invocation history not simply as a count, but as a pattern of time intervals between calls. In particular, it analyzes periods without invocations as waiting times, distinguishing short gaps between individual requests from long idle periods after a burst ends.
This distinction directly affects eviction decisions:
- A function that continues to receive calls after short gaps is worth keeping warm.
- A function that receives a concentrated burst of calls and then stays idle for a long time can be evicted soon after the burst ends.
- A function called periodically can be prewarmed just before its next execution.
- A function with little invocation history can be treated cautiously, but its priority can be lowered when memory is under pressure.
In short, a single fixed timer does not determine a function’s lifecycle in SPES-Ext. It takes each function’s distinct invocation patterns and prediction confidence into account to decide when to wake it and when to unload it.
Running Low on Memory Is Not Just a Matter of Deletion
In Serverless operations, memory pressure is not simply a situation where “something has to be deleted.” Which function is unloaded can affect the latency of the next request, overall memory efficiency, and load balance across workers.
SPES-Ext turns this choice into a priority problem:
- Protect functions whose invocations are imminent.
- Evict functions with unreliable predictions.
- Preload only the functions that are needed, at the right time.
- Preferentially place them on workers with more memory available.
The central idea is clear: Serverless efficiency does not come from keeping as many functions running for as long as possible. It comes from knowing which functions to keep alive—and for how long.
The Memory Wars Among Six Serverless Workers: Good Predictions Aren’t Enough
Preparing functions in advance doesn’t automatically make a Serverless system faster. If prewarmed execution environments pile up on a particular worker, that worker runs out of memory first while others still have room to spare. As a result, new requests may have to wait for a worker with available resources—or force the system to evict functions that were already prepared.
What makes SPES-Ext noteworthy is that it doesn’t stop at predicting when a function will be called next. The scheduler decides not only which functions to keep warm, but also which workers to place them on and what to give up when memory runs short.
It prioritizes the worker with the most free memory
When a new function execution environment needs to be loaded, SPES-Ext generally prioritizes the worker with the most memory available.
Suppose there are six workers, with the following amounts of free memory:
| Worker | Free memory | Status | |---|---:|---| | Worker A | 15% | Nearly saturated | | Worker B | 28% | High utilization | | Worker C | 46% | Moderate | | Worker D | 71% | Plenty of room | | Worker E | 39% | Moderate | | Worker F | 63% | Plenty of room |
If a new function instance needs to be prewarmed, SPES-Ext prioritizes Worker D. It may seem like a simple rule, but this choice helps prevent warm instances of multiple functions from piling up on a single worker.
Hash-based placement can keep sending the same function to a particular worker. Round-robin considers only the order of requests and doesn’t adequately account for each worker’s actual memory situation. SPES-Ext, by contrast, checks available memory at every placement decision, allowing it to distribute function instances according to the system’s current resource state.
When memory runs low, it doesn’t protect all warm functions equally
The hardest situation arises when all workers are short on memory. The Serverless platform then has to evict some existing instances to make room for a new function execution environment.
SPES-Ext doesn’t simply remove the “oldest function.” Instead, it recognizes that different functions have different future value.
It prioritizes protecting:
- Functions currently handling requests
- Functions likely to be called soon
- Periodic functions with high prediction confidence
- Correlated functions likely to run soon as the next step in a workflow
- Execution environments that have already incurred a high cold-start cost
By contrast, these are more likely to be evicted:
- Functions with a long time until their next expected call
- Functions with irregular call patterns and low prediction confidence
- Functions that were preloaded but are unlikely to be called
- Idle functions that consume a large amount of memory
- Pending instances that are not currently executing
In other words, what SPES-Ext gives up isn’t simply an old function. It gives up memory occupied by something unlikely to be needed in the near future.
The important context FIFO eviction misses
With FIFO, the function that entered memory first is the first one removed. It’s easy to implement, but it has a major limitation: it doesn’t understand the context behind Serverless call patterns.
Suppose a payment function is called regularly at a certain time each day, and its next call is predicted to arrive in a few seconds or minutes. If the function is evicted just because it has been warm for a while, the next request will have to endure another cold start.
Conversely, even a function that was just prewarmed may no longer be worth keeping in memory if its predicted call never materializes and its likelihood of being called again has fallen. SPES-Ext takes this distinction into account.
The important question isn’t “How long has this been in memory?” but “How soon will we need this memory again?”
This approach manages resources more proactively than conventional policies that treat warm instances like a cache.
Prioritizing prewarming versus incoming requests
In a memory-constrained environment, preparing for the future can conflict with handling requests in the present. For example, one function may be slated for prewarming because it’s expected to be called soon, while an actual request for another function has just arrived.
In this situation, SPES-Ext prioritizes requests that need to run immediately over prewarming. Reducing future cold starts matters, but not if it means increasing the latency of a current user request just to force advance preparation.
The priority order can be summarized as follows:
Protect requests currently running
↓
Place functions that have been called now
↓
Prewarm functions likely to be called soon
↓
Keep warm instances with low prediction confidence
SPES-Ext’s prewarming is therefore not unconditional preemption. It’s more like a conditional investment in future requests, made only within the memory the system can currently afford.
What the six-worker experiment revealed
The paper evaluated SPES-Ext’s placement policy in an environment with six workers. One of the key metrics was Normalized Worker Variance, which captures differences in the amount of free memory across workers.
If a particular worker stays busy while others sit idle, the variance is high. Conversely, if memory usage stays relatively balanced across workers, the variance is low.
SPES-Ext reported an average reduction of 52.49%–96.14% in the worker load-balancing metric compared with the alternatives. This is more than just an improvement in finding an idle worker. It reflects placement decisions that combine each function’s likelihood of being called, eviction priority, and available memory.
However, these results come from simulations using Azure Functions invocation traces. In a real-world deployment, factors such as container image size, runtime initialization time, CPU usage, concurrency limits, and network conditions would also need to be considered.
Ultimately, it’s about choosing what to keep—and what to give up
If every function could always stay warm in a Serverless environment, cold starts could be reduced. But memory is finite, and each worker has a limit on how much it can handle.
SPES-Ext confronts this practical constraint directly. It invests memory in functions likely to be called, aggressively evicts those less likely to be needed, and places new instances on the workers with the most room to spare.
Good predictions are only the starting point. The performance of a real Serverless platform depends on the scheduling strategy that decides where to place those predictions, which instances to protect, and what to give up.
Beyond Serverless Performance Metrics: The Next Stage of Serverless Operations
SPES-Ext’s experimental results are certainly impressive. It reduced the 75th-percentile cold-start rate by 80%, significantly cut memory waste caused by idle instances, and even reduced load imbalance across multiple workers.
But these figures should not be taken as a guarantee of performance in every production environment. The results were derived from simulations using Azure Functions invocation traces, while real-world operating environments involve many more variables:
- Container image pull times
- Initialization costs for different language runtimes
- Network and storage latency
- Concurrency limits and CPU contention
- Differences in memory usage and execution time across functions
- Sudden traffic changes and prediction failures
In particular, the perceived impact of cold starts can vary between runtimes with high initialization costs—such as Java, .NET, and Python—and lightweight JavaScript functions. Workloads that stray from the assumption that “every function finishes within a minute,” such as GPU tasks, large-file conversions, and long-running workflows, also require separate validation.
Even so, the direction proposed by SPES-Ext is important. The core of Serverless operations is no longer just keeping functions warm for longer. Going forward, we need to be able to answer questions like:
When is this function likely to be called again?
Is it worth occupying memory right now?
Which worker should it be placed on to keep the overall platform stable?
SPES-Ext aims to answer these questions by considering not just invocation frequency, but also waiting time, invocation bursts, prediction confidence, correlations between functions, and available memory on each worker.
How Operational Priorities Are Changing
Traditional Serverless operations have been relatively straightforward: create an execution environment when a function is invoked, then remove it after a set period of time. A longer keep-alive period reduces cold starts but increases memory costs. A shorter period saves memory but adds latency to the first request.
The approach proposed by SPES-Ext breaks down this fixed trade-off on a function-by-function basis.
| Traditional operating approach | Predictive Serverless operating approach | |---|---| | Apply the same keep-alive period to every function | Adjust retention time based on each function’s invocation patterns | | Remove the oldest instances first | Remove instances least likely to be called again | | Create an execution environment only after invocation | Prewarm shortly before an invocation is expected | | Use simple load distribution | Place functions based on each worker’s available memory and priority | | Make decisions independently for each function | Use invocation relationships between functions in a workflow |
In other words, the goal is not to “keep more functions running at all times.” It is to prepare only the functions that are truly needed, at the moment they are needed, on the most suitable workers.
Practical Conditions to Check Before Adoption
A scheduler like this is not necessarily needed in every environment. If there are few functions, traffic is straightforward, and memory is plentiful, a fixed keep-alive policy may be the simpler and more reliable choice.
By contrast, SPES-Ext’s approach may be especially valuable in environments such as:
- Private FaaS environments running many functions with limited memory
- Edge Serverless environments that distribute functions across multiple edge nodes
- Workflows with clear invocation paths between functions, such as ordering, payments, and notifications
- Event-processing platforms where periodic and burst traffic occur together, such as IoT systems
- Multitenant environments where memory usage becomes concentrated on specific workers
In practice, it is safer to roll out the approach incrementally rather than changing platform-wide policies all at once. First, measure invocation logs, cold-start rates, memory occupancy duration, and memory imbalance across workers. Then, begin with limited prewarming for regularly invoked functions with high prediction accuracy, and compare the improvements in latency against the memory waste caused by failed predictions.
The Key Is Not Prediction, but a Controllable Balance
Predictions can be wrong. Preloading a function that is never called wastes memory, while missing a function that is about to be called leads to a cold start. A good Serverless scheduler, then, should not simply improve prediction accuracy—it should be a policy for controlling the cost of prediction failures.
SPES-Ext removes functions with low prediction confidence or distant next invocations first, and gives immediate-execution requests priority over prewarming. This prioritization reflects a practical operating principle: rather than trying to predict every request perfectly, protect the most important requests with limited resources.
Ultimately, the next stage of Serverless is not scale-to-zero itself. It is closer to predictive execution-environment management: understanding function invocation patterns and application workflows, then continually finding the right balance between memory, latency, and worker distribution. SPES-Ext is still a research-stage technology that requires further validation, but it offers a clear example of the direction Serverless platforms are heading.
Comments
Post a Comment