pagurus: eliminating cold startup in serverless computing

12
Pagurus: Eliminating Cold Startup in Serverless Computing with Inter-Action Container Sharing * Zijun Li, *† Quan Chen, *† Minyi Guo * Department of Computer Science and Engineering, Shanghai Jiao Tong University, China Shanghai Institute for Advanced Communication and Data Science, Shanghai Jiao Tong University, China [email protected], {chen-quan, guo-my}@cs.sjtu.edu.cn Abstract—Serverless computing provides fine-grain resource sharing between Cloud tenants through containers. Each function invocation (action) runs in an individual container. When there is not an already started container for a user function, a new container has to be created for it. However, the long cold startup time of a container results in the long response latency of the action. Our investigation shows that the containers for some user actions share most of the software packages. If an action that requires a new container can “borrow” a similar warm container from other actions, the long cold startup can be eliminated. Based on the above finding, we propose Pagurus, a runtime container management system for eliminating the cold startup in serverless computing. Pagurus is comprised of an inter-action container scheduler and an intra-action container scheduler for each action. The inter-action container scheduler schedules shared containers among actions. The intra-action container scheduler deals with the management of the container lifecycle. Our experimental results show that Pagurus effectively eliminates the time-consuming container cold startup. An action may start to run in 10ms with Pagurus, even if there is not warm container for it. I. I NTRODUCTION Adopting serverless computing, Cloud tenants submit func- tions directly without renting virtual machines of different specifications, Cloud vendors schedule the tenants’ functions automatically. For the high maintainability and testability, most hyperscalers now provide serverless computing services (such as Amazon Lambda [1], Google Cloud Function [2], Microsoft Azure Functions [3], and Alibaba Function Compute [4]). Serverless computing is perfect for the Internet services that have unstable query loads, since the tenants are charged for each query execution, instead of the long term renting. We use the terminology in Apache OpenWhisk [5], an event-driven serverless computing platform. An action repre- sents the invocation of a user function. Whenever an action is received, serverless computing runs the action using either a newly-launched container or a running warm container. The warm containers keep serving queries (warm startup) until timeout to be recycled. While containers of different actions rely on various software packages, the containers are not shared. If there is not a warm container for an action, a new cold container needs to be started for it. The long latency of booting containers, as well as the software environment and code initialization, restricts the performance of serverless computing [6], [31], [33], [34], [43]. While some actions suffer from the long container cold startup time, we observe that current serverless computing systems may launch too many containers for some other actions. For instance, they may launch too many containers for Internet services with diurnal load patterns [17], [19] (the low load is less than 30% of the peak load) at the peak load. We also observe that there are idle containers for some actions, even if loads of these actions are stable. While these warm containers are idle and wasting the system resources, they are not used by any other action because the containers for different actions install different software packages. With the development of micro-service architecture, the actions tend to use popular and common library package. For instance, by extracting likely dependencies in the projects on packages in the popular Python Package Index (PyPI) repository, 36% of imports are of 20 popular packages [32]. Actions tend to use similar software packages. In this scenario, if an action that requires cold container startup is able to utilize the idle containers of other actions, the cold startup is turned into a warm startup, its end-to-end latency can be greatly reduced. There are three main challenges in achieving the above purpose. As for the first challenge, the loads of the actions are not stable [35]. It is difficult to determine whether an action can safely lend an idle container to other actions, without affecting its own Quality-of-Service (QoS). Secondly, existing serverless computing systems do not support the “borrow” operation. Container sharing is not allowed. Thirdly, multiple renters and lenders coexist. It is non-trivial to design an efficient container sharing strategy among actions that minimizes the number of the cold startup. To tackle the above challenges, we propose Pagurus,a container management system that reduces container cold startup through adaptive inter-action container sharing. In Pagurus, the containers are classified into lender containers, executant containers and renter containers. The executant containers can only be used by the owner action itself. The lender containers can be lent to other actions, and will turn into renter containers. Pagurus proposes an enhanced container component that enables the container sharing between multiple actions and guarantees the security of users’ code. For each action, an intra-action container scheduler is adopted to man- age its executant containers, the renter containers borrowed from other actions, and the lender containers to be lent to other actions. The whole serverless computing system adopts an inter-action container scheduler to schedule the containers between the actions and handles the proactive re-packing based on the package similarity of the actions and their workloads. arXiv:2108.11240v1 [cs.DC] 25 Aug 2021

Upload: others

Post on 15-Oct-2021

3 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Pagurus: Eliminating Cold Startup in Serverless Computing

Pagurus: Eliminating Cold Startup in ServerlessComputing with Inter-Action Container Sharing

∗Zijun Li, ∗†Quan Chen, ∗†Minyi Guo∗Department of Computer Science and Engineering, Shanghai Jiao Tong University, China

†Shanghai Institute for Advanced Communication and Data Science, Shanghai Jiao Tong University, [email protected], {chen-quan, guo-my}@cs.sjtu.edu.cn

Abstract—Serverless computing provides fine-grain resourcesharing between Cloud tenants through containers. Each functioninvocation (action) runs in an individual container. When thereis not an already started container for a user function, a newcontainer has to be created for it. However, the long cold startuptime of a container results in the long response latency of theaction. Our investigation shows that the containers for someuser actions share most of the software packages. If an actionthat requires a new container can “borrow” a similar warmcontainer from other actions, the long cold startup can beeliminated. Based on the above finding, we propose Pagurus, aruntime container management system for eliminating the coldstartup in serverless computing. Pagurus is comprised of aninter-action container scheduler and an intra-action containerscheduler for each action. The inter-action container schedulerschedules shared containers among actions. The intra-actioncontainer scheduler deals with the management of the containerlifecycle. Our experimental results show that Pagurus effectivelyeliminates the time-consuming container cold startup. An actionmay start to run in 10ms with Pagurus, even if there is not warmcontainer for it.

I. INTRODUCTION

Adopting serverless computing, Cloud tenants submit func-tions directly without renting virtual machines of differentspecifications, Cloud vendors schedule the tenants’ functionsautomatically. For the high maintainability and testability, mosthyperscalers now provide serverless computing services (suchas Amazon Lambda [1], Google Cloud Function [2], MicrosoftAzure Functions [3], and Alibaba Function Compute [4]).Serverless computing is perfect for the Internet services thathave unstable query loads, since the tenants are charged foreach query execution, instead of the long term renting.

We use the terminology in Apache OpenWhisk [5], anevent-driven serverless computing platform. An action repre-sents the invocation of a user function. Whenever an action isreceived, serverless computing runs the action using either anewly-launched container or a running warm container. Thewarm containers keep serving queries (warm startup) untiltimeout to be recycled. While containers of different actionsrely on various software packages, the containers are notshared. If there is not a warm container for an action, a newcold container needs to be started for it. The long latencyof booting containers, as well as the software environmentand code initialization, restricts the performance of serverlesscomputing [6], [31], [33], [34], [43].

While some actions suffer from the long container coldstartup time, we observe that current serverless computingsystems may launch too many containers for some other

actions. For instance, they may launch too many containers forInternet services with diurnal load patterns [17], [19] (the lowload is less than 30% of the peak load) at the peak load. Wealso observe that there are idle containers for some actions,even if loads of these actions are stable. While these warmcontainers are idle and wasting the system resources, theyare not used by any other action because the containers fordifferent actions install different software packages.

With the development of micro-service architecture, theactions tend to use popular and common library package.For instance, by extracting likely dependencies in the projectson packages in the popular Python Package Index (PyPI)repository, 36% of imports are of 20 popular packages [32].Actions tend to use similar software packages. In this scenario,if an action that requires cold container startup is able toutilize the idle containers of other actions, the cold startupis turned into a warm startup, its end-to-end latency can begreatly reduced.

There are three main challenges in achieving the abovepurpose. As for the first challenge, the loads of the actionsare not stable [35]. It is difficult to determine whether anaction can safely lend an idle container to other actions,without affecting its own Quality-of-Service (QoS). Secondly,existing serverless computing systems do not support the“borrow” operation. Container sharing is not allowed. Thirdly,multiple renters and lenders coexist. It is non-trivial to designan efficient container sharing strategy among actions thatminimizes the number of the cold startup.

To tackle the above challenges, we propose Pagurus, acontainer management system that reduces container coldstartup through adaptive inter-action container sharing. InPagurus, the containers are classified into lender containers,executant containers and renter containers. The executantcontainers can only be used by the owner action itself. Thelender containers can be lent to other actions, and will turninto renter containers. Pagurus proposes an enhanced containercomponent that enables the container sharing between multipleactions and guarantees the security of users’ code. For eachaction, an intra-action container scheduler is adopted to man-age its executant containers, the renter containers borrowedfrom other actions, and the lender containers to be lent toother actions. The whole serverless computing system adoptsan inter-action container scheduler to schedule the containersbetween the actions and handles the proactive re-packing basedon the package similarity of the actions and their workloads.

arX

iv:2

108.

1124

0v1

[cs

.DC

] 2

5 A

ug 2

021

Page 2: Pagurus: Eliminating Cold Startup in Serverless Computing

……

Container image

CRIU (checkpoint-

restore in userspace)

Cold

startup

Pre-initialized

containers (LRU)

Prewarm

startup

Load balancer

(running containers)

Warm

startup

A

C

T

I

O

N

boot

restore

initialize

invoke

Controller

Execution manner

Container pool

Execution

D

A

T

A

B

A

S

E

Resultoptions

[7],[21],[36]-[38]

[5],[8],[22],[30]

[6],[17],[24],[31],[32],[39]

Fig. 1. Four possibilities to start an action in a serverless computing system.

The main contributions of this paper are as follows.• The container enhancement that enables the sharing.

We enhance the container design to support the runtimepackage re-packing. It enables the container sharing be-tween different actions.

• The design of a similarity-based container re-packingpolicy. While the containers for different actions installdifferent software packages, we analyze the similaritiesof the actions, and minimize the number of packagesinstalled for container sharing.

• The design of an efficient inter-action container shar-ing mechanism. This mechanism divides the containersinto three types, based on which Pagurus manages themin different ways and enables efficient inter-action con-tainer sharing.

Through the adaptive inter-action container sharing, Pagurusgreatly reduces the possibility that an action suffers from coldcontainer startup. Pagurus is also able to be integrated withprior work on reducing the container cold startup time tominimize the overhead of serverless computing in all the cases.

II. BACKGROUND AND RELATED WORK

A. BackgroundIn serverless computing, container act as a lightweight virtu-

alization that creates multiple isolated user-space instances foractions. The serverless platform uses containers to encapsulateand execute the queries.

Figure 1 shows the way that a user action is scheduled to runwith serverless computing. As shown in the figure, a containermust be booted/restored/initialized/invoked to host the action.If an action is invoked for the first time or there is no alivecontainer for this action, the serverless system encapsulates itand starts up a new container, initializes software environment,loads application-specific code [13], and runs the function.All these steps make up a cold startup [16], [26], and maytake several seconds. The container cold startup significantlyincreases the end-to-end latency of user queries [6], [33], [34],[43], especially the processing of a single query is often short(hundreds of milliseconds) for Internet services.

To deal with this problem, researchers also proposed touse CRIU (checkpoint-restore in user-space) [7], [40]–[42]technique that restores container images from checkpoints toreduce the cold startup time. However, it still incurs the longend-to-end latency [21]. Another approach called prewarmstartup adopted by OpenWhisk spawns stem cell containers

that are already initialized with the software environment inadvance. Though it skips the container startup and users onlyneed to perform application-specific code initialization [5], [8],[24], [32], its pre-loaded libraries can either make the imagesize too large [24], [39], or cause long startup latency for theprewarm container [18], [32].

If a container for a type of action is alive (just completethe previous invocation), a new action query of the sametype can be directly executed in the running container (warmstartup). Warm startup eliminates the container booting andinitialization, and these warm containers keep serving actionsto achieve better end-to-end latency [31]. However, warmstartups are not always possible because these warm containersmay be recycled before cold startup happens [16], [26].

B. Related Work

There are already lots of prior work on reducing the con-tainer startup latency to improve the performance of serverlesscomputing [15], [21], [25], [36]. SAND [15] separates differ-ent applications from each other via containers, while allowingfunctions of one application to run in the same container bydifferent processes. X-container [36] has been proposed as anew security paradigm for isolating cloud-native containers toachieve higher throughput. Catalyzer [21] adopts the designthat utilizes the technology of CRIU with on-demand recovery.Hendrickson [25] also proposes OpenLambda to deal with thelong function startup latency and locality consideration.

Slacker [24] and SOCK [32] share the similar idea thatcontainers are launched by generalizing zygote initializationto reduce the startup latency. To achieve function isolation,Unikernels [28], [29] can achieve less latency and betterthroughput via bypassing the kernel with unikernels in server-less environments. McGrath [31] proposed to reuse containersand create containers by introducing a queuing scheme withworkers collecting the availability in different queues.

Existing works mainly focus on seeking more lightweightvirtualization technologies to pursue lower overhead, or toreduce the container startup time for one kind of action.Our work tries to make different actions work collaborativelyto alleviate the container cold startup problem. Furthermore,Pagurus can be combined with different container technologiesto achieve less cold startup latency.

III. MOTIVATION

A. Experimental Setup

In this investigation, we use Apache OpenWhisk [5] with lo-cal cache as the representative serverless computing platform,FunctionBench [27] and Faas-Profiler [34] as the benchmarks.The experiment setup is based on a 2-node cluster where thenodes are connected with a 25Gb/s Ethernet switch. In the2-node experimental cluster, we use one node to perform thecomputing, and one node to generate the queries for execution.Table I shows the hardware and software configurations ofeach node. We use representative serverless computing bench-mark suites FunctionBench [27] and Faas-profiler [34] and theused benchmark workloads are shown in Table II.

Page 3: Pagurus: Eliminating Cold Startup in Serverless Computing

TABLE IHARDWARE AND SOFTWARE SETUPS

Configuration

Node

CPU: Intel Xeon Platinum [email protected]: 40, L3 shared cache: 32MBDRAM: 256GB, Disk: NVME SSD

Network Interface Card (NIC): 25Gb/sNetwork 25Gb/s Ethernet Switch

Software

Nginx version: nginx/1.10.3 Database: Apache/couchdb:2.3Container runtime: Python-3.7.0, Linux with kernel 4.15.0

Docker server and client version: 19.03Docker runc version: 1.0.0-rc10 Docker containerd version: 1.2.13

Memory and Timeout of serverless containers: 256MB, 60sOperating system: Linux with kernel 3.10.0

TABLE IIBENCHMARKS USED IN THIS PAPER

Benchmark Workloads Descriptiondd Convert and copy a file.float operation(fop) Float operations (sin, cos and sqrt).cloud storage (clou) Cloud storage service.mapreduce (mr) MapReduce wordcount workload.

FunctionBench video processing (vid) Video processing.linpack (lp) Solve linear equations Ax = b.matmul (mm) Matrix multiplication.k-means (kms) Model training of k-means.image resize (img) Resizes an image to several icons.

Faas-profiler couchdb (cdb) Json dump from Coucdb files.markdown2htmll (md) Renders Markdown text to HTML.

B. Breakdown of the End-to-end Latency

The end-to-end latency of processing a user’s query seri-ously affects the user experience. We make an investigationand break down the end-to-end latencies of the benchmarksfor serverless computing.

In a serverless computing system based on container tech-nology, cold container startup happens when there are no idlecontainers exist, and a user query is received. In this scenario,the system creates a new container to serve the query. Foran action, the cold container startup includes operations likeinitializing the customized execution environment. Tradition-ally, the cold startup overhead includes the container startup,the software environment of the function initialization, andapplication-specific code initialization. These operations mayincur significant extra latency. Figure 2 shows the percentagesof the time spent on the cold container startup in the end-to-end latencies of the benchmarks.

Observed from Figure 2, the cold startup overhead increasesthe end-to-end latencies of the benchmarks. In general, thecontainer cold startup time is relatively stable. In the best

dd fop img vid lp mm kms cdb clou mr md0

2

4

6

Tim

e sp

ent o

n co

ntai

ner

star

tup

and

actio

n ex

ecut

ion

container startup execution

0.4

0.6

0.8

1.0

Perc

enta

ge o

f tim

e sp

ent o

n co

ntai

ner s

tartu

p

Fig. 2. The distribution and percentages of time spent on the cold containerstartup and action execution in the end-to-end latencies of the representativebenchmarks.

1.0 1.5 2.0 2.5 3.0 3.5 4.0QPS

5

10

15

20

Num

ber o

f con

tain

ers

2

3

95%

-ile

late

ncy(

s)QoS target

(a) The number of containers launched in OpenWhisk

1.0 1.5 2.0 2.5 3.0 3.5 4.0QPS

5

10

15

20

Num

ber o

f con

tain

ers

2

3

95%

-ile

late

ncy(

s)QoS target

(b) The number of actually needed containers

Fig. 3. The number of containers launched (a) and required (b) to ensure the95%-ile latency target of an example benchmark vid.

case, the cold container startup still takes 48.2% of the end-to-end latency (cdb). While in the worst case, the cold containerstartup takes 93.8% of the end-to-end latency (dd).

If we can eliminate the container cold startup, the end-to-end latencies of the applications with serverless computingcan be greatly reduced. To this end, Cloud vendors [1]–[4],[12], [14], as well as recent works [16], [25], [30], [38] havefocused more on reducing the container startup time as wediscussed in Section II.

Even if the container cold startup time is reduced to about40ms in the best case [21], the cold startup still takes longertime than the case that the query can directly get a warm con-tainer (<10ms) [5], [34]. The increasing usage of high-levellanguage like Python, can make the cold startup even moreexpensive [15], [34]. For the latency-sensitive applicationsthat have millisecond-level latency targets, such as Internetservices, the 30ms already results in poor user experience.

C. Existence of Redundant Warm Containers

An important feature of serverless computing is elasticity.By current container startup strategy, the containers are startedup upon queries waiting in the queue, and will be recycledsoon when there is no query for a certain period (e.g., 60seconds in OpenWhisk). Therefore, whenever the runningcontainers fail to catch up with the queries waiting in thequeue, a new container must get started and experience coldstartup. In a large-scale serverless computing platform, theremay coexist a large number of actions from different users.If some actions have redundant warm containers, we envisionthat it is possible to reuse these redundant warm containers toeliminate the cold startup. To this end, we manually schedulethe container startup process to reuse the redundant warmcontainers, and check the number of containers launched andthe QoS in the metric of end-to-end latency. Figure 3 reportsour investigation results. Our investigation proves that ourassumption holds.

Page 4: Pagurus: Eliminating Cold Startup in Serverless Computing

Taking the benchmark vid as an example, Figure 3(a) andFigure 3(b) show the number of containers launched and the95%-ile end-to-end latencies of the queries in various loads,for OpenWhisk and our manual scheduling, respectively. In thefigure, the x-axis represents the query workload (Query-per-Second, QPS); the bars show the number of warm containers(corresponding to the left y-axis), and the line shows the 95%-ile latency (corresponding right y-axis).

Observed from Figure 3(a), the 95%-ile latency of thebenchmark shows the pattern of cyclic variation. This isbecause a little increase in the QPS at the saturation point willbring in a new container startup, thanks to which, lower overalllatency will be achieved. But further increasing the QPS willresult in higher overall latency. While, there is still headroombetween the 95%-ile latency and the QoS target, it is possibleto use fewer containers without violating the QoS requirement.This is exactly what we do in the manual scheduling. As shownin Figure 3(b), in some cases (the bars in black), we can safelyreduce at least one container while still achieving the 95%-ilelatency target. It proves that some applications in the serverlesscomputing platform do have some warm idle containers duringexecution. In addition, from Figure 3(b), we also observe thatthe idle container usually appears in a minimum turning pointof the latency (represented by blue circle in the figure). It isbecause that the minimum turning point usually comes with anew container startup to deal with the increasing queries in thewaiting queue. We also find that it is a common phenomenonbased on Openwhisk. Besides vid, the other benchmarks alsoproduce the similar results. On the other hand, it can be easilyanticipated that there will be even more idle containers in thecase when the query workload drops suddenly. While, it hasbeen widely witnessed and proved that real Internet servicesare with diurnal load pattern [17], [19]. Definitely, this willbring in more idle containers potentially for reuse.

D. Challenges in Reusing Containers and Ensuring QoSBased on the above analysis and investigation, there is an

opportunity to leverage the warm containers of some actions toeliminate the cold container startup of other actions. While theactions may require different software packages and executionenvironment, an action’s container is not able to be usedby another container. An action’s container has to be re-packed before it can be used by other actions. The re-packingoperation may take a relatively long time.

By extracting the packages from the benchmark suite Func-tionBench [27], we also find that 16.7% of the benchmarksimport pandas and sklearn, and some commom librarieslike numpy are even shared by 22.2% of them. This findingindicates that, different actions tend to share a high proportionof packages with others. Therefore, it is possible to builda shared container image, allowing several actions to runwithout installing extra packages. Even if in some cases thesimilarity of libraries between different actions is not high, wecan use specific designed algorithms to build some connectionbetween them. However, it is not an easy task to build a sharedcontainer image as there are still several challenges, such as• Actions are not able to share containers. While the

containers of different actions pack different software

Server

Node N

Server

Node 2

Master Node

Central controller Database

Server

Node 1 ……

Synchronize

Update

Fig. 4. The Master-Slave design of a serverless computing system.

packages, the containers of an action cannot be reusedby other actions by default.

• Container reuse brings extra time overhead. To allowother actions to run in an action’s container, the reusedcontainer is supposed to install extra packages. Inappro-priate package installation brings large time overhead thatnegates the latency reduction from the elimination of thecold container startup.

• Security concerns about inter-action container shar-ing. When containers are shared between different ac-tions, isolation is weakened. While, the security andprivacy of the actions must be ensured.

• Inter-action container reuse brings extra schedulecomplexity. While multiple actions are active concur-rently, an efficient mechanism has to be proposed tomanage the container lend and rent between the actions.

IV. DESIGN OF PAGURUS

To tackle the above challenges, we propose Pagurus, aruntime container management system for eliminating the coldcontainer startup through inter-action container sharing.

For a traditional serverless computing system, the design ofdistributed deployment is usually implemented in two ways.One is to divide the nodes into master and slave nodes.Load balancing is realized by the central controller in themaster node, and the data in the slave node (server node) issynchronized by the database, as shown in Figure 4. However,according to the previous studies, the network bandwidthbetween the server nodes and the database is usually thebottleneck of the serverless computing, and such master-slavedesign is also unpractical [25], [26], [32].

Therefore, we design Pagurus using the single node man-agement, where all nodes communicate with each other tomaintain and update local databases and files. By such means,the performance is only relevant to the computing powerof the server node. Figure 5 shows the design overview ofPagurus. For the management of shared containers betweenactions, an inter-action container scheduler is introduced. Itis also responsible for the re-packing of the containers atruntime when necessary. For each action, there is an intra-action container scheduler responsible for coordinating threecontainer pools, i.e., an executant container pool, a lendercontainer pool, and a renter container pool. Whenever a con-tainer experiences the cold startup, it is added to the executantcontainer pool by default, and will keep intact provided thatit is recognized as a warm container. When there is no queryrequesting the container for a certain period, the container willbe identified as idle and moved to the lender container pool forpossible cross-action reuse. The renter container pool reserves

Page 5: Pagurus: Eliminating Cold Startup in Serverless Computing

Renter

container pool

Executant

container pool

Lender

container pool

Inter-action container scheduler

Database

Nginx

Request

Queue

Pagurus

Code Load

Action Run

Lend and Rent

Intra-action

container

scheduler

Action-1

Renter

container pool

Executant

container pool

Lender

container pool

Intra-action

container

scheduler

Action-N

……

Customized

container

Code

Encryption

Container repacking

Fig. 5. Design of Pagurus.

the containers rent from the other actions’ lender containerpool. Once a cold startup is about to occur on an action,Pagurus allows it to first check whether it is possible to reusean existing lender container from another action to avoid coldstartup. It should be noticed that the lender actions can alsoget renter containers whenever it is re-packed by others.

To enable the container sharing, we customize the containerstructure of Pagurus with four modules, i.e., code load, actionrun, lend and rent and code encryption, as shown in Figure5. Code load and action run are the same as current server-less computing platform, responsible for code loading fromdatabase and execution monitoring when invoking actions,respectively. Lend and rent and code encryption are spe-cially introduced in Pagurus for container sharing and safetyguarantee, respectively. Lend and rent essentially consists oflend and rent functions. Lend helps the container transferredfrom executant container to lender container. Rent helps renterinherit containers and properties from lender container. Inaddition, code encryption module guarantees the containersecurity during code reload.

Container re-packing and container life-cycle managementplay critical roles in Pagurus. We will discuss the two issues inthe following two sections, respectively, with special emphasison answering the following questions:• On what conditions, we can identify a container in the

executant container pool as idle and transfer it to lendercontainer pool?

• For a set of renter candidates, how to select the appro-priate renter container in the consideration of runtimeperformance efficiency in the metric of end-to-end latencyof renter containers?

• How to guarantee the security of lender and renterwithout exposing both sides’ code and data?

V. IMAGE RE-PACKING

A. Idle Container Identification

Idle container identification and lender container genera-tion are two essential functions in the intra-action containerscheduler. To realize container sharing, it is first important toidentify the containers of an action that can be lent, i.e., idlecontainer. In the serverless system, the queries are executed bythe running containers. If the total capacity of the containersexceeds the one required to ensure the QoS of the queries

during a period, idle container arises. As we have known,whether a container can be judged as idle or not, dependson the query workload, the processing power, and the desiredQoS. Therefore, we first describe the query processing logic ofserverless computing into a producer-consumer problem, andanalyze it via queuing theory, which has been widely appliedin communication systems, computations and storage systems.

Without loss of generality, the query arrival process to acontainer can be described as Poisson process with exponen-tially distributed interval averaged as λ. The query processingtime follows an exponential distribution with average value µ,which is independent to the task arrival. The queries are fairlyallocated among the containers. Thus, we can apply M/M/nmodel [22] to analyze the processing process.

When the traffic density ρ = λnµ < 1, the system is in a

stable state. In this case, we can derive the stable distributionπk that there are k queries in the waiting queue as

πk =

(nρ)kπ0

k!, k = 1, 2, . . . , n− 1

nnρkπ0

n!, k = n, n+ 1, . . . ,

(1)

where π0 = [∑n−1k=0

(nρ)k

k! + (nρ)n

n!(1−ρ) ]−1. For brevity, the

detailed analysis is omitted. Then, we can further derive theaverage waiting time W under the stable state (i.e., ρ < 1). Noquery will be in the waiting queue if the number of queries isless than the number of containers, i.e., P{W = 0} = p{X <n}. Thus, we can derive the waiting time (i.e., the time spentin the waiting queue) distribution as

P{W =0} = p{X<n} = 1−p{X ≥ n}=1−∞∑k=n

πk

= 1−∞∑k=n

nnρk

n!π0 = 1−

πn

1− ρ,

(2)

and

P{0<W <t} =

∞∑k=n

P{w<W <t|X=k}P{X=k}

=

∞∑k=n

πk

∫ t

0

(nµ)k−n+1xk−n

Γ(k − n+ 1)e−nµx

dx

=

∫ t

0

πn

∞∑k=n

(nµxρ)k−n

(k − n)!nµe−nµx

dx

=πn

1− ρ[1− e−nµ(1−ρ)t].

(3)

Summing up (2) and (3), we obtain the general waiting timedistribution Fw(t) as

Fw(t) = P{W = 0}+ P{0 < W < t}

= 1−πn

1− ρe−nµ(1−ρ)t

, t > 0.(4)

Let TD represent the QoS target and define rreal(n) as therreal-ile latency of an action when there are n containers, andrreq as the rreq-ile latency requested by an action. So whenthe waiting time t is set as the maximum waiting time TD− 1

µ ,Fw(t)− rreq ≥ 0 will represent whether the QoS requirementcan be satisfied. Thus, we can derive the discriminant functionto determine whether the idle container of an action exists as{

rreal(n)− rreq ≥ 0

f(n− 1) = 1− rreq − πn1−ρ e

−(n−1)µ(1−ρ)(TD−1µ

) ≥ 0.(5)

Page 6: Pagurus: Eliminating Cold Startup in Serverless Computing

Both criteria in (5) need to be satisfied to identify an idlecontainer. It is necessary that rreal(n) ≥ rreq, otherwise thecurrent QoS of the action can not be satisfied when n con-tainers running in serverless platform, and the action suffersQoS violation due to cold startup. Upon QoS satisfaction,we further try to evaluate whether it is possible to removeone container from the executant container pool by checkingthe achievable QoS after the removal. If f(n − 1) ≥ 0,n − 1 containers are already enough to satisfy the QoSrequirement, and an idle container will be removed by itsintra-action container scheduler. Meanwhile, the inter-actioncontainer scheduler will re-pack the lender image for it.

Thus, the intra-action container scheduler of an action canapply the criteria in (5) to identify the idle containers forpossible reuse by the other actions, and send the correspondingcontainer information to the inter-action container schedulerfor lender container image re-packing, as will be discussed inthe next subsection.

B. Similarity-based Re-packing

Re-packing refers to adding extra dependent libraries tomaximize the possibility of reuse by the other actions asdifferent actions usually ask for containers with differentlibraries. Intuitively, we may add arbitrary more libraries tobuild a lender container for the maximal reuse. However, thiswill result in an extremely large container, leading to highoverhead. Fortunately, we notice that different actions alsoshare some libraries with different degrees. This motivates usto design a similarity-based container re-packing in Pagurus.

The inter-action container scheduler analyzes the softwareenvironment of each action, and re-packs the lender containerimage for each running intra-action container scheduler bychecking the similarities between lender actions and otheractions. To filter out actions similar to a lender action, we ap-ply collaborative filtering and adopt Nearest Neighbor Search(NNS) to calculate the similarity between two actions. Cosine-based Similarity is a well-known similarity algorithm which istraditionally used in users’ interests recommendation. We de-fine the action-L as the actions that require additional libraries,and action-NL as actions without additional libraries. Theinter-action container scheduler generates the lender containersimages by re-packing the similar images in the following steps.• Collect information about all actions. All the infor-

mation about their libraries will be recorded, includingthe name and the version of libraries. For each action,by the user’s Dockerfile, additional installed librariescan be recorded in the format {Ln} = {”lib1” :”version”, ”lib2” : ”version”}. In some cases whenusers do not declare the version of libraries, the inter-action container scheduler will take the latest version asdefault. But it will bring in the hazard of libraries versioncontradiction. For example, if userA requires lib1 with1.0 version, while userB requires lib1 with 2.0 version,neither can lease the other’s containers because of theversion contradictions.

• Create a vector to hold the libraries of each action. Foreach lender action, the scheduler first filters the actions

Inter-action container scheduler

Intra-action container scheduler

Timeline

Data collection for

image re-packing

Similarity-based

re-packing

algorithm

Re-packing

lender image

for each action

Container severing

Renter containers checkIdle container

identification

Generate lender

container from

re-packed image

Inform inter-action

container scheduler to

re-pack image for it

Return re-packed image for

intra-action container

scheduler to generating

lender container

Data collection for

image re-packing

Fig. 6. Timeline of Pagurus operations.

with common libraries with the lender action as thecandidate actions. It then checks whether the librariesin the candidate actions are inconsistent with that inlender action (e.g., version contradiction). In that case,it will be removed from the candidate actions. Finally,the scheduler takes the union set of the libraries both inthe lender action and rest candidate actions to form alibraries vector for distance calculation.

• Calculate the cosine distance between the lenderaction and the candidate actions as the similarity.The filter logic is to select the top nL values of all thesimilarities and then take the corresponding actions asrenters. If no candidate actions exist (for example, action-NL is selected as lender action), nL action-Ls withoutversion contradiction will be added in random to be therenters. Besides, a number nNL of action-NLs will alsobe selected in random as renters.

Therefore, up to nL action-Ls and nNL action-NLs willbe selected as renters, and the inter-action container schedulerwill wrap the renters’ additional libraries into the image ofthe lender action. Meanwhile, the renters’ code files will alsobe re-packed by code encryption module for safety. nL andnNL are hyper-parameters and obviously their values affectthe re-packing overhead and time. Their values should be setaccording to (6), in which case all actions can get chances tobe re-packed in lender containers.

nL = min{num(action−Ls)size(renter pool)

}, nNL = min{num(action−NLs)size(renter pool)

} (6)

Figure 6 shows the re-packing operations along timeline.The inter-action container scheduler re-packs the lender con-tainers images based on the data collection Image re-packing.The time cost in lender re-packing is hard to measure dueto the uncertainty of the libraries vector cardinality. With nodoubt that higher cardinality, i.e., more libraries for re-packing,indicates longer re-packing time. But the re-packing phase foreach lender action usually takes less than 10s for most actionsaccording to our experiments. After re-packing, the imagesare committed to different intra-action container schedulersfor creating lender containers. The overhead depends on thenumber of additional libraries to be installed. If some librariestake a relatively long time to re-pack, users will resort tosubmitting a virtual environment [9] or custom containerimage [10] to avoid the long installation time. In this case,

Page 7: Pagurus: Eliminating Cold Startup in Serverless Computing

Pagurus will adopt traditional CRIU to generate the containers,instead of re-packing.

The inter-action container scheduler deals with creatingand updating of the re-packing image, while the intra-actioncontainer scheduler is responsible for managing the containerpools, e.g., starting an executant container from default image,generating the lender container from the re-packed image. Un-less the re-packed image is updated, the container only bootsfrom it for the first time, and any subsequent container willuse CRIU to accelerate the startup. The renter container checkmodule is designed to make sure that the runtime and librariesin the intra-action container scheduler are consistent with thatin the inter-action container scheduler when performing thecontainer re-packing.

C. Security Guarantee

In Pagurus, as a lender container may be shared by severalrenter actions, a natural and inevitable concern is on thesecurity of lender container. Meanwhile, as the code files ofrenter actions need to be re-packed in the shared container,the renters’ security cannot be ignored.

For lenders’ security guarantee, Pigurus explores the state-less nature of serverless computing to clean up user codeand cache of the lender container before re-packing a lenderimage. No renter action can get any previous informationabout the action with the lender container. For renters’ securityguarantee, Pigurus encrypts the renter action’s code file bymodule code encryption first before re-packing to preventcode disclosure. The code encryption is divided into two parts.First, to protect the privacy of the users’ files name, Pagurusadopts a renaming strategy by renaming code files uniformlysuch as main .py, as adopted by OpenWhisk [11]. Then,the environment folder for user actions will be encrypted intoa ZIP file with the user password. Secondly, when a lendercontainer is generated, all the renters’ code files will coexistin this container. In this case, all the renters’ folders need tobe encrypted with inter-action container controller specifiedpassword to protect the renters’ privacy and code security inthe lender container. It should be noticed that the cleanupand code decryption are executed in inter-action containerscheduler, and therefore neither side can get any informationabout each other.

In conclusion, although Pagurus weakens the level of iso-lation, the code security and privacy required by isolation arestill ensured and satisfied. Using encryption to secure data andfiles in cloud computing is quite common in practice [20],[23], [37]. So it is acceptable for actions to adopt encryptionto address the security concern in container sharing.

VI. INTER-ACTION CONTAINER MANAGEMENT

In this section, we describe the steps of creating lender con-tainers from idle containers, and using the borrowed containerto run an action.

A. Generating a Lender Container

If an executant container of an action is identified tobe idle, its intra-action container scheduler will generate alender container from the re-packed image returned by the

Lender

container

pool

Executant

container

pool

Renter

container

pool

Intra-action

container

scheduler

Inter-action

container

scheduler

Step 1: status feedback

Step 2.1:

Executant delete

containerStep 2.2:

Lender create

container

Step 3.1: return

Lender status

Step 4: return

container status Step 3.2: return

Executant

status

Fig. 7. Generating a lender container from an idle executant container.

Action_B

Lender

container

pool

Action _B

Intra-action

container

scheduler

Inter-action

container

scheduler

Action _A

Intra-action

container

scheduler

Action _A

Renter

Container

pool

Step 1: Action _A

post cold startup

request

Step 3.2: Return

Lender Action _B

Found status

Step 6: Action_A and Action_B

return container status

Step 4.1:

Action _B delete

Lender container

Step 2: Action _A

post Lender find

request

Step 4.2:

Action_A inherit

Renter container

Step 3.1: Inform

Action _B renter

status

Step 5.1:

Return Lender

pool status

Step 5.2:

Return Renter

pool status

Fig. 8. The steps of Action B rents a container from Action A.

inter-action container scheduler. Figure 7 shows the detailedworkflow of generating a lender container.

As shown in Figure 7, the executant containers of anaction periodically feedback their status to the intra-actioncontainer scheduler. Based on the status of each container,the intra-action container scheduler identifies the redundantidle containers. Once an idle container is identified from theexecutant containers, the intra-action container scheduler re-packs the idle container to be a lender container (Step 2.1and Step 2.2). In more detail, the idle container is deletedfrom the executant container pool, and the correspondinglender container is added to the lender container pool. Thisinformation is then feedbacked to the intra-action containerscheduler (Step 3.1 and 3.2), so that the scheduler is aware ofthe change. In the last step, the intra-action container schedulerinforms the inter-action container scheduler of the change(Step 4). In this way, other actions are able to borrow thecontainer through the inter-action container scheduler.

B. Renting a Container from Other Actions

When an action ACT needs a container to run but there is nofree warm container for it, its intra-action container schedulersubmits a rent request to the inter-action container scheduler.If there exists such lender container that is already preparedfor ACT by other actions, the container is changed to be arenter container of ACT, and is put in the renter containerpool of ACT. Figure 8 shows the detailed steps of renting acontainer from other actions.

Among these steps, it is crucial to guarantee the lender’scontainer delivery and ensure the information safety of the

Page 8: Pagurus: Eliminating Cold Startup in Serverless Computing

Executant container

Lender containerRenter container

Re-generate from

the re-packed image

Inherit from other actions’

lender container

Recycled for startup

by default

Fig. 9. The state transition diagram of three containers.

lender. In Step 3, the inter-action container scheduler deletesthe code and data of actionB , as well as the other renters’code file in the lender container, and deciphers the code fileof actionA. Then inter-action container scheduler will informactionB and actionA to prepare for container transferring(Step 3.1 and Step 3.2). Once actionA’s intra-action containerscheduler receiving return container status, it will schedule thislender container to its renter container pool (Step 4.2) andactionB’s lender container pool will clear related status andinformation (Step 4.1). Meanwhile, the management privilegeof the lender container is transferred from actionB’s intra-action container scheduler to actionA’s intra-action containerscheduler.

The code cleaning of actionB and the code decryptionof actionA are executed in parallel. While the overhead ofcleaning is less than the time cost of code decryption, theoverhead of code cleaning is hidden from users.

Based on Section VI-A and VI-B, we can summarize thestate transitions for three different containers in Figure 9. Theaction is executed in the executant container by default, and allcold startup containers are managed in the executant containerpool. Lender container is transformed from an idle executantcontainer identified by its intra-action container scheduler toa shared container re-generated from the re-packed image.Renter container inherits from other actions’ lender containerto make queries get executed without container cold startup.All these containers will keep running until timeout to berecycle.

C. Recycling Containers in Different Pools

In serverless computing, when the load of an action drops,some warm containers for the action are recycled to saveresources. Recycling is done by monitoring the status of thecontainers. If a container does not receive new requests fora time period (60s in OpenWhisk), the container is recycled.The recycling is only done by setting a timeout period foreach container. If a container does not operate in the timeoutperiod, the container will be recycled. This recycling policyis not able to be used in Pagurus directly as there are threetypes of containers in Pagurus.

Therefore, we design a priority-based recycle strategy forPagurus. In this strategy, the inter-action container schedulermanages the recycling of all its containers, including executantcontainers, lender containers, and renter containers. For anaction, Pagurus recycles the renter containers before all theother containers, and recycles lender containers after all thecontainers. The design philosophy here is that an action doesnot need extra rent containers when its containers tend to be

renter container pool executant container pool lender container pool

Timeout T1 for recycle Timeout T2 for recycle Timeout T3 for recycle

T2 Timeout T2 Timeout

Priority: 1 Priority: 2 Priority: 3

T1 Timeout T3 Timeout

Recycle RecycleRecycle Recycle

Fig. 10. Recycling thee three types of containers.

Server node

ddBenchmarks

(11 kinds)fop img vid lp mm kms cdb clou mr md

Evaluated Actions (renter)Pagurus works(lender)

Actions that run with little workload

and long interarrival ratesActions that run with high worload

Benchmark A Benchmark B ……

Without prior knowledge, each

benchmark can be the lender.The rest 9(11-2) actions that experience cold

startup can rent containers from the lender

Benchmark C Benchmark X

Fig. 11. The configurations of actions running in the background.

recycled. Figure 10 shows the order of recycling containerswhen the load of an action drops.

Specifically, we set different timeout periods for the threetypes of the containers. The renter container pool has theminimum timeout period (T1 in Fig. 10). The executantcontainer does not store information and libraries for otheractions, the container recycle does not affect the schedulingof the intra-action container scheduler. The timeout period ofexecutant containers (T2 in Fig. 10) is slightly larger than thetimeout period of the lender containers. Because the lendercontainers re-pack additional libraries for multiple actions,even if executant and renter containers are all recycled, it canalso meet the invocation of the action. For the above reasons,the lender containers have the maximum timeout period (T3in Fig. 10).

In our current implementation, we set the timeout periodsfor the renter containers, executant containers, and lendercontainers to be 40s, 60s, and 120s by default.

VII. EVALUATION OF PAGURUS

In this section, we first evaluate the performance of Pagurusin reducing the end-to-end latencies of applications whenthere is no warm containers for them. Then, we discuss thepossibility of Pagurus in eliminating the cold startup, theeffect of Pagurus in supporting bursty load, and its effect inintegrating with the orthogonal techniques.

A. Experimental Setup

In the experiment, we evaluate Pagurus based on a 2-nodecluster described in Section III-A. In the 2-node experimentalcluster, they serve for inter-action container scheduler re-packing. Although we only use a small scale cluster inthis section, Section IV reveals the situation in large scaleClouds while serverless computing platforms often managethe containers on each node independently. While containersare in the process context, containers are not supposed to bemigrated to other nodes in most cases.

Page 9: Pagurus: Eliminating Cold Startup in Serverless Computing

dd fop img vid lp mm kms cdb clou mr md01234567

The

cold

star

tup

late

ncy Optimal Pagurus Restore Baseline(Openwhisk)

Fig. 12. The end-to-end latencies of the benchmarks when they suffer fromcold startup with OpenWhisk, Restore-based method, and Pagurus.

We use representative serverless computing benchmarksuites FunctionBench [27] and Faas-profiler [34] to evaluatePagurus. Table II lists the used benchmark workloads. Inthe following experiment, we set the maximum number ofcontainers in the renter pool to be 2 and randomly run twobenchmarks in the background with high loads to simulatethe real-system situation. To better understand the backgroundconfiguration, we make a schematic diagram, as shown inFigure 11. In a real system, there are some long-runningservices and some occasional queries on the same serverlesscomputing platform, and the services running in the back-ground are also uncertain. So there are total C2

11 = 55combinations of experimental configurations for Pagurus whenwe randomly select two benchmarks to be the lender. In eachexperimental configuration, we run each benchmark for 100times by invoking the benchmark once every 60 seconds. Inthis way, the benchmark suffers from the cold container startupin all the 100 tests. In the following experiment, we collectthe end-to-end latencies of the 100 tests for each benchmarkbased on the above experimental setup.

B. Reducing End-to-end Latency

We show the effectiveness of Pagurus in reducing the end-to-end latency of a benchmark in this subsection. In thisexperiment, for each benchmark, we randomly select two ofthe other 10 benchmarks to be the lenders in the backgroundfor Pagurus. We compare Pagurus with Apache OpenWhisk [5]and the restore-based method [7]. OpenWhisk creates a newcontainer for a benchmark from the corresponding containerimage and startups the new container. Restore-based methodstores the checkpoint of the container in the memory, andrestores the checkpoint from the main memory when needed.

Figure 12 shows the end-to-end latencies of the benchmarkswith OpenWhisk, Restore-based method, and Pagurus. In thefigure, the “optimal” reports the latencies of the benchmarkswhen they get warm containers directly. As shown in thefigure, all the benchmarks achieve the shortest end-to-end la-tencies with Pagurus compared with OpenWhisk and Restore-based method. In the best case where actions get lendercontainers, Pagurus reduces the end-to-end latencies of thebenchmarks by 75.6% and 51.9% compared with OpenWhiskand the restore-based method respectively. When compared tothe optimal scenario, Pagurus only introduces 0.48% longerend-to-end latency on average.

dd fop img vid lp mm kms cdb clou mr md0.0

0.2

0.4

0.6

0.8

1.0

Prob

ablit

y of

elim

inat

ing

col

d st

artu

p

Fig. 13. The probability of eliminating cold startup with Pagurus.

Pagurus greatly reduces the end-to-end latencies because itschedules the idle shared containers to speed up the actionsthat may suffer from cold container startups. If an actionquery is hosted in a shared container, the container startupphase for the query is skipped and only the user-specificcode initialization is needed. According to our measurement,Pagurus schedules a lender container to a query in less than15µs, and completes the container cleaning and application-specific code initialization in less than 10ms.

The restore-based method is also able to reduce the end-to-end latencies of the benchmarks compared with OpenWhisk.This is mainly because it eliminates the overhead of creatingthe new container images. However, it consumes large memoryspace and still results in longer end-to-end latencies of thebenchmarks compared with Pagurus.

C. Eliminating the Container Cold Startup

It is possible that there is not a renter container for anaction. For an action, the extra libraries (software libraries) itpacks determine the probability that it will skip a cold startup.The probability of eliminating the cold startup is an importantindicator that reflects the effectiveness of Pagurus.

In this experiment, for each benchmark, we run it in C210 =

45 experimental setups. For each setup, we select 2 out of the10 benchmarks as the renters. Figure 13 shows the percentagesof the C2

10 = 45 setups in which the benchmarks skip the coldcontainer startup.

Observe from Figure 13, Pagurus eliminates all the coldcontainer startup for dd, fop, lp, mm, cdb and clou, becausethese benchmarks can always rent containers from the lenders.They can always find the lenders because these benchmarksdo not require additional libraries to initialize the softwareenvironment. In this case, the container re-packing algorithmis able to pack the redundant idle containers of any actions tobe its renter containers.

For the benchmarks that require extra libraries (img, vid,kms, mr, and md), the possibility of eliminating the cold startupdepends on the libraries similarity of the lender actions andrenter actions. The more common and popular the additionallibraries required in the action, the higher the probability that itwill be re-packed by the lender actions. For instance, in 77.3%,59.1% and 57.6% of the configurations, Pagurus eliminates thecold container startup for vid, kms, and img respectively. Thisis because these benchmarks mainly use the shared Pillowand sk-learn software packages. However, for mr and md, dueto the unpopular of packages they used, lender actions takelower priority to pack it in lender containers. The decision

Page 10: Pagurus: Eliminating Cold Startup in Serverless Computing

dd fop

img

vid

lp mm

kms

cdb

clou

mr

md

mdmr

cloucdbkmsmm

lpvid

imgfopdd

0.0

0.2

0.4

0.6

0.8

1.0

colo

rbar

Fig. 14. The benchmark similarities in the container re-packing algorithm.

leads to the relatively low probabilities (34.8% and 36.4%) ofeliminating cold startup for mr and md.

To better understand this problem, Figure 14 shows theheat map of the benchmark similarities in the container re-packing algorithm. In the figure, the very small square inrow vid and column img represents the possibility that vidserves as the lender for img rental. The small square in therow img and column vid represents the possibility that vidserves as the renter for img. Observed from the figure, all thebenchmarks do not tend to re-pack containers for mr and md.These results explain the reason that Pagurus shows a relativelylow possibility in eliminating cold container startup for mr andmd. An alternative method to further resolve this problem istaking the prior knowledge into consideration. Another way isincreasing the number of renters that each lender can choose.

It should be noticed that the heat map in Figure 14 isasymmetric, because the benchmarks rely on different softwarepackages. Assume an action ACT1 relies on software packageslib1, lib2 and another action ACT2 relies on software packageslib1. In this case, the containers of ACT1 have all the packagesfor ACT2. At the same time, the containers of ACT2 only havehalf of the software packages for ACT1. The possibilities ofre-packing the containers of ACT1 for ACT2, and re-packingthe containers of ACT2 for ACT1 are different.

Renter containers can be used by multiple actions and notall the benchmarks can always skip the code container startup.

D. Integrating with Work on Reducing Cold Startup Time

While Pagurus eliminates the container cold startup, it canbe integrated with prior work proposed to reduce the containercold startup time. In this subsection, we integrate Paguruswith Restore-based method and Catalyzer [21] respectively,and report their performance. For each benchmark, we still runit in the 45 experimental setups. In each experimental setup,we launch the benchmark 100 times with an interval of 60seconds. Figure 15 shows the average container startup timefor each benchmark of the 45× 100 = 4, 500 tests.

Observed from Figure 15, Restore+Pagurus reduces theaverage container startup time of the benchmarks by 43.4%on average compared with the original Restore-based method;Catalyzer+Pagurus reduces the average container startup timeby 12.2% on average compared with Catalyzer. Pagurus isable to further reduce the average container startup time,because it is able to totally skip the container startup phase

dd fop img vid lp mm kms cdb clou mr md0

1

2

3

Cold

star

tup

late

ncy Restore

Restore+PagurusCatalyzerCatalyzer+Pagurus

Fig. 15. The average cold startup latency when Pagurus is integrated withRestore-based method, and Catalyzer respectively.

0.4 0.6 0.8 1.0 1.2End-to-end latency

0.00

0.25

0.50

0.75

1.00

CDF

matmul-Optimalmatmul-Pagurusmatmul-Restore

(a) mm

0.2 0.4 0.6 0.8 1.0End-to-end latency

0.00

0.25

0.50

0.75

1.00

CDF

image-Optimalimage-Pagurusimage-Restore

(b) img

Fig. 16. The cumulative distribution of the benchmarks’ cold startup end-to-end latencies in Pagurus and Restore.

for the benchmarks sometimes. Even if no appropriate lendercontainer returns, Pagurus will not slow down the containerstartup. Therefore, Pagurus can be integrated with prior workto further reduce the average cold startup time.

Figure 16 shows the cumulative distribution of the end-to-end latencies of mm and img with restore-based method andRestore+Pagurus. In the figure, “optimal” shows the latenciesof the benchmarks when all the containers are warm. Byintegrating Pagurus with the restore-based method, the end-to-end latencies of all the 4,500 tests of mm are greatly reduced.Meanwhile, 52.1% of the queries of img show much shorterend-to-end latencies. In mm, action queries completely skip thecontainer startup, thus overhead of cold startup is eliminated.While for img, about 52.1% of the action queries can eliminatecold startup overhead, the rest still have to experience thecontainer startup phase with the restore-based method.

For Pagurus, we can observe a large discontinuity in Fig-ure 16(b) as Pagurus helps most of the queries to skip thecontainer startup phase to reduce the latency, and only a fewof them still suffer from cold startup problem.

Traditionally, we can also integrate the prewarm startup(introduced in Section II) policy with these advanced container

dd fop img vid lp mm kms cdb clou mr md0

1

2

3

4

The

aver

age

star

tup

late

ncie

s o

f pre

warm

star

tup

polic

y

Pagurus Prewarm for each Prewarm for all

Fig. 17. The average cold startup latencies of the benchmarks with prewarmstartup policy. ’Prewarm for each’ means that each action can get oneprewarmed container, and ’prewarm for all’ means all actions can initializeone specific container created from a common cache.

Page 11: Pagurus: Eliminating Cold Startup in Serverless Computing

dd fop img vid lp mm kms cdb clou mr md0

5

10

15Th

e su

ppor

ted

burs

ty lo

ads(

QPS)

1 executant container1 renter container2 renter container

Fig. 18. The supported bursty loads of the benchmarks with Pagurus.

dd fop img vid lp mm kms cdb clou mr md0

2

4

6

Save

d M

em u

sage

(GB) 1 executant container

1 renter container2 renter container

Fig. 19. The size of the reduced memory usage to support the bursty loadswith Pagurus compared with OpenWhisk.

startup techniques. From the Figure 17, we can observe thatPagurus still performs better than ‘prewarm for all’ method.It is because that the libraries in the specific prewarmedcontainer may conflict with the user action. In this case, thesespecific prewarmed containers cannot be initialized, makinguser actions experience the cold startup. Even though the‘prewarm for each’ method shows less end-to-end latency thanPagurus due to the prewarmed containers continuously runningin the background, additional 2.75GB memory resources arerequired by it. So, although with comparatively high perfor-mance, ‘prewarm for each’ method is unpractical because ofthe extremely high resource usage.

E. Supporting Bursty Loads

Traditional serverless platforms (e.g., OpenWhisk) fail tosupport bursty workload without causing QoS violation dueto the long latency during the cold container startup. Pagurusis able to support the smooth process of the bursty workloadof an action through the inter-action container sharing.

Figure 18 shows the supported bursty loads of the bench-marks without causing the QoS violation, when Pagurus allowsthe benchmark to rent 1 or 2 more containers. Observed fromFigure 18, for all the benchmarks, Pagurus is able to support3× of the bursty loads if the benchmarks are able to rent2 more renter containers from other actions. This is mainlybecause the overhead of renting containers from other actionsis much lower than creating new containers.

Besides, Pagurus also reduces the consumed memory spaceto support the bursty loads of the benchmarks compared toOpenWhisk. To suppose the bursty load with OpenWhisk, astraightforward method is maintaining more warm containers.However, these containers consume large main memory space.On the contrary, with Pagurus, there is no need to launchadditional containers to support the bursty loads. Figure 19shows the size of the main memory space saved with Pagurus.As shown in the figure, Observed from the figure, in Pagurus,0.25GB to 3GB of the memory is saved in the case of 1 renter

TABLE IIITIME AND SPACE OVERHEADS INTRODUCED BY PAGURUS

Type Position Time/Resource OverheadEncrypted code files size Running lender container 4.3125KB

Re-packed image size Creating lender container 485MBRe-packing image time Creating lender container 6.647sCheckpoint files size Creating container 332KB

CPU overhead Re-packing container 1.61%

container, and 0.5GB to 6.75GB of the memory in the case of2 renter containers compared with OpenWhisk.

F. Overheads in Pagurus

Table III shows the overheads introduced by Pagurus. Asshown in the table, Pagurus incurs five types of overheads.In Pagurus, the lender container stores the renters’ encryptedcode files as an extra operation, and decrypt the correspondingrenter’s code file when eliminating cold startups. This ap-proach only takes 4.3125KB of space to save information andless than 10ms to decrypt, which is far less than about 200msof database transmitting. The operation of packing images isintroduced in the generation of lender containers. The extrapacked images experience creating by average 6.647s, and485MB of space is allocated for storing. The preparation oflender containers is done asynchronously and does not resultin the long end-to-end latency. Containers only need to bootfrom images for the first time. In other cases, containers getaccelerated in startup by checkpoint files which takes average332KB of space to store. Besides, the re-packed images andthe checkpoint files will be recycled when the correspondingactions are not invoked.

The most important part of the overhead is the CPU usagewhen Pagurus re-packing containers. The experiment showsthat when the inter-action container scheduler re-packs thecontainer image for an action, the average CPU utilization onthe node is only about 1.61%. After taking the communicationand synchronization between nodes into account, the re-packing phase will consume about 2.4% of the CPU resource.If we limit the CPU usage of re-packing to less than 10% ofthe server, each node can re-pack container images for about34 actions during the data collection in 1 minute. To conclude,the overhead incurred by Pagurus is negligible.

VIII. CONCLUSION

This paper presents Pagurus,a container management systemfor serverless to eliminate container cold startup by inter-actioncontainer sharing. We implement the design by introducingthree unique container pools, lender containers, executantcontainers and renter containers. The inter-action containerscheduler cooperated with intra-action container schedulersin each action, enable containers scheduled between differentactions to reduce container cold startup. The evaluation resultshows that Pagurus can significantly eliminate the cold startup.Besides, Pagurus can also be integrated with several containertechnologies to minimize the container startup overhead ofserverless computing.

Page 12: Pagurus: Eliminating Cold Startup in Serverless Computing

REFERENCES

[1] aws.amazon.com/cn/lambda. Apr., 2019.[2] cloud.google.com/functions. Apr., 2019.[3] azure.microsoft.com/en-us/services/functions. Apr., 2019.[4] https://cn.aliyun.com/product/fc. Apr., 2020.[5] openwhisk.apache.org. Apr., 2019.[6] serverless.com/blog/2018-serverless-community-survey-huge-growth-u

sage. Apr., 2019.[7] https://github.com/checkpoint-restore/criu. Apr., 2019.[8] github.com/apache/openwhisk/blob/90c20a847b9a70b43e316fd89a0a1

5ae2ee39cc4/docs/annotations.md. Apr., 2019.[9] https://github.com/apache/openwhisk/blob/master/docs/actions-python.

md. Apr., 2019.[10] https://github.com/apache/openwhisk/blob/master/docs/actions-docker.

md. Apr., 2019.[11] https://github.com/apache/openwhisk/blob/master/docs/actions-python.

md. Apr., 2019.[12] Firecracker lightweight virtualization for serverless computing.

https://aws.amazon.com/blogs/aws/firecracker-lightweight-virtualization-for-serverless-computing/. Apr., 2019.

[13] Knative. https://github.com/knative. Apr., 2019.[14] Open-sourcing gvisor, a sandboxed container runtime.

https://cloud.google.com/blog/products/gcp/open-sourcing-gvisor-a-sandboxed-container-runtime.. Apr., 2019.

[15] Istemi Ekin Akkus, Ruichuan Chen, Ivica Rimac, Manuel Stein, andKlaus Satzke. SAND: Towards high-performance serverless computing.In ATC, pages 923–935, 2018.

[16] Ioana Baldini, Paul Castro, Kerry Chang, Perry Cheng, Stephen Fink,Vatche Ishakian, Nick Mitchell, Vinod Muthusamy, Rodric Rabbah,Aleksander Slominski, et al. Serverless computing: Current trends andopen problems. In Research Advances in Cloud Computing, pages 1–20.Springer, 2017.

[17] Luiz Andre Barroso, Jeffrey Dean, and Urs Holzle. Web search for aplanet: The google cluster architecture. IEEE micro, (2):22–28, 2003.

[18] Eric A. Brewer. Kubernetes and the path to cloud native. In Proceedingsof the Sixth ACM Symposium on Cloud Computing, SoCC 2015, KohalaCoast, Hawaii, USA, August 27-29, 2015, page 167, 2015.

[19] Jeffrey Dean and Luiz Andre Barroso. The tail at scale. Communicationsof the ACM, 56(2):74–80, 2013.

[20] Xin Dong, Jiadi Yu, Yuan Luo, Yingying Chen, Guangtao Xue, andMinglu Li. Achieving secure and efficient data collaboration in cloudcomputing. In 21st IEEE/ACM International Symposium on Quality ofService, IWQoS 2013, Montreal, Canada, 3-4 June 2013, pages 195–200. IEEE, 2013.

[21] Dong Du, Tianyi Yu, Yubin Xia, Binyu Zang, Guanglu Yan, ChenggangQin, Qixuan Wu, and Haibo Chen. Catalyzer: Sub-millisecond startupfor serverless computing with initialization-less booting. In Proceedingsof the Twenty-Fifth International Conference on Architectural Supportfor Programming Languages and Operating Systems, pages 467–481,2020.

[22] Natarajan Gautam. Analysis of queues: Methods and applications. CRCPress, 2012.

[23] Vipul Goyal, Omkant Pandey, Amit Sahai, and Brent Waters. Attribute-based encryption for fine-grained access control of encrypted data. InAri Juels, Rebecca N. Wright, and Sabrina De Capitani di Vimercati,editors, Proceedings of the 13th ACM Conference on Computer andCommunications Security, CCS 2006, Alexandria, VA, USA, Ioctober30 - November 3, 2006, pages 89–98. ACM, 2006.

[24] Tyler Harter, Brandon Salmon, Rose Liu, Andrea C. Arpaci-Dusseau,and Remzi H. Arpaci-Dusseau. Slacker: Fast distribution with lazydocker containers. In 14th USENIX Conference on File and StorageTechnologies, FAST 2016, Santa Clara, CA, USA, February 22-25, 2016,pages 181–195, 2016.

[25] Scott Hendrickson, Stephen Sturdevant, Edward Oakes, Tyler Har-ter, Venkateshwaran Venkataramani, Andrea C. Arpaci-Dusseau, andRemzi H. Arpaci-Dusseau. Serverless computation with openlambda.login Usenix Mag., 41(4), 2016.

[26] Eric Jonas, Johann Schleier-Smith, Vikram Sreekanti, Chia-Che Tsai,Anurag Khandelwal, Qifan Pu, Vaishaal Shankar, Joao Carreira, KarlKrauth, Neeraja Yadwadkar, et al. Cloud programming simpli-fied: a berkeley view on serverless computing. arXiv preprintarXiv:1902.03383, 2019.

[27] Jeongchul Kim and Kyungyong Lee. Functionbench: A suite ofworkloads for serverless cloud function service. In CLOUD, pages 502–504. IEEE, 2019.

[28] Ricardo Koller and Dan Williams. Will serverless end the dominance oflinux in the cloud? In Proceedings of the 16th Workshop on Hot Topicsin Operating Systems, HotOS 2017, Whistler, BC, Canada, May 8-10,2017, pages 169–173, 2017.

[29] Anil Madhavapeddy and David J. Scott. Unikernels: the rise of thevirtual library operating system. Commun. ACM, 57(1):61–69, 2014.

[30] Filipe Manco, Costin Lupu, Florian Schmidt, Jose Mendes, SimonKuenzer, Sumit Sati, Kenichi Yasukata, Costin Raiciu, and Felipe Huici.My VM is lighter (and safer) than your container. In Proceedings ofthe 26th Symposium on Operating Systems Principles, Shanghai, China,October 28-31, 2017, pages 218–233, 2017.

[31] M. Garrett McGrath and Paul R. Brenner. Serverless computing: Design,implementation, and performance. In 37th IEEE International Confer-ence on Distributed Computing Systems Workshops, ICDCS Workshops2017, Atlanta, GA, USA, June 5-8, 2017, pages 405–410, 2017.

[32] Edward Oakes, Leon Yang, Dennis Zhou, Kevin Houck, Tyler Caraza-Harter, Andrea C. Arpaci-Dusseau, and Remzi H. Arpaci-Dusseau.SOCK: serverless-optimized containers. login Usenix Mag., 43(3), 2018.

[33] Qifan Pu, Shivaram Venkataraman, and Ion Stoica. Shuffling, fast andslow: Scalable analytics on serverless infrastructure. In 16th USENIXSymposium on Networked Systems Design and Implementation, NSDI2019, Boston, MA, February 26-28, 2019, pages 193–206, 2019.

[34] Mohammad Shahrad, Jonathan Balkind, and David Wentzlaff. Architec-tural implications of function-as-a-service computing. In Proceedings ofthe 52nd Annual IEEE/ACM International Symposium on Microarchi-tecture, MICRO 2019, Columbus, OH, USA, October 12-16, 2019, pages1063–1075, 2019.

[35] Vaishaal Shankar, Karl Krauth, Qifan Pu, Eric Jonas, ShivaramVenkataraman, Ion Stoica, Benjamin Recht, and Jonathan Ragan-Kelley.numpywren: serverless linear algebra. CoRR, abs/1810.09679, 2018.

[36] Zhiming Shen, Zhen Sun, Gur-Eyal Sela, Eugene Bagdasaryan, ChristinaDelimitrou, Robbert van Renesse, and Hakim Weatherspoon. X-containers: Breaking down barriers to improve performance and isolationof cloud-native containers. In Iris Bahar, Maurice Herlihy, EmmettWitchel, and Alvin R. Lebeck, editors, Proceedings of the Twenty-FourthInternational Conference on Architectural Support for ProgrammingLanguages and Operating Systems, ASPLOS 2019, Providence, RI, USA,April 13-17, 2019, pages 121–135. ACM, 2019.

[37] Wei-Liang Tai, Ya-Fen Chang, and Wen-Hsin Huang. Security analysesof a data collaboration scheme with hierarchical attribute-based encryp-tion in cloud computing. I. J. Network Security, 22(2):212–217, 2020.

[38] Jorg Thalheim, Pramod Bhatotia, Pedro Fonseca, and Baris Kasikci.Cntr: Lightweight OS containers. In 2018 USENIX Annual TechnicalConference, USENIX ATC 2018, Boston, MA, USA, July 11-13, 2018,pages 199–212, 2018.

[39] Eli Tilevich and Hanspeter Mossenbock, editors. Proceedings of the15th International Conference on Managed Languages & Runtimes,ManLang 2018, Linz, Austria, September 12-14, 2018. ACM, 2018.

[40] Ranjan Sarpangala Venkatesh, Till Smejkal, Dejan S. Milojicic, and AdaGavrilovska. Fast in-memory criu for docker containers. In Proceedingsof the International Symposium on Memory Systems, MEMSYS ¡¯19,pages 53–65, New York, NY, USA, 2019. Association for ComputingMachinery.

[41] Michael Vrable, Justin Ma, Jay Chen, David Moore, Erik Vandekieft,Alex C. Snoeren, Geoffrey M. Voelker, and Stefan Savage. Scalability,fidelity, and containment in the potemkin virtual honeyfarm. In Pro-ceedings of the 20th ACM Symposium on Operating Systems Principles2005, SOSP 2005, Brighton, UK, October 23-26, 2005, pages 148–162,2005.

[42] Kai-Ting Amy Wang, Rayson Ho, and Peng Wu. Replayable executionoptimized for page sharing for a managed runtime environment. InProceedings of the Fourteenth EuroSys Conference 2019, Dresden,Germany, March 25-28, 2019, pages 39:1–39:16, 2019.

[43] Liang Wang, Mengyuan Li, Yinqian Zhang, Thomas Ristenpart, andMichael Swift. Peeking behind the curtains of serverless platforms. InATC, pages 133–146, 2018.