Emergency demand response in edge computing

A cloudlet is a small-scale cloud datacenter deployed at the network edge to support mobile applications in proximity with low latency. While an individual cloudlet operates on moderate power, cloudlet clusters are well-suited candidates for emergency demand response (EDR) scenarios due to substantial electricity consumption and job elasticity: mobile workloads in the edge often exhibit elasticity in their execution. To efficiently carry out edge EDR via cloudlet cluster control, two fundamental problems need to be addressed: how to incentivize the participation of cloudlet clusters and how to schedule and allocate workloads in each cluster to satisfy EDR requirements. We propose a two-stage control scheme, consisting of (i) an auction mechanism to motivate clusters’ voluntary energy reduction and select participants with the minimum social cost and (ii) an online task scheduling algorithm for chosen clusters to dispatch workloads to guarantee target EDR power reduction. Using the primal-dual optimization theory, we prove that our control scheme is truthful, individually rational, runs in polynomial time, and achieves near-optimal performance. Large-scale simulation studies based on real-world data also confirm the efficiency and superiority of our scheme over state-of-the-art algorithms.


Introduction
Cloudlet, in the form of a small datacenter, is a new computing paradigm that extends today's cloud architecture.As the middle tier of a 3-tier hierarchy: mobile or IoT devicecloudlet-cloud, cloudlet is often placed at the edge of the network to provide low-latency and high bandwidth services for nearby mobile or IoT devices [1].A cloud service provider often deploys a cluster of cloudlets to serve mobile users, since the computing power of an individual cloudlet is limited.The wide distribution of cloudlets not only increases the edge network's capacity and coverage but also brings flexibility in workload management [2,3].
It is quintessential for a power network to be stable and reliable.When an emergency happens (e.g., extreme weather conditions), supply scarcity needs to adjust immediately to avoid involuntary service interruptions [4].Besides clouds, cloudlet clusters now serve as an important force in emergency demand response (EDR).While individual cloudlet uses a moderate amount of electricity, a cluster of cloudlets consumes substantial electricity.Furthermore, edge computing tasks (e.g., video surveillance and analysis) are often elastic [5].Hence, the task execution is flexible, which means that a task can tolerate a certain level of delay.The above features make cloudlet clusters well suited to participate in EDR programs to stabilize the power grid by reducing and temporally shifting peak loads.To realize edge EDR via cloudlet cluster control, two fundamental challenges need to be addressed.First, cloudlet clusters are often operated by different service providers at their own cost.How to incentivize them to voluntarily participate in EDR is a challenging problem.An efficient market mechanism must be created to select cost-conscious participants and reward them accordingly.Second, for a chosen cloudlet cluster which receives task execution requests from mobile users online, the main issue is how to make decisions on accepting/declining tasks and schedule accepted tasks, such that the target energy reduction is satisfied and its utility is maximized?
Many efforts have been made on incentive mechanism design for demand response and task scheduling.However, they cannot be applied to edge EDR directly.Previous work either only focuses on electricity procurement [6,7] or does not consider the electricity consumption in scheduling algorithm design [8,9].More discussions can be found in Section 2. The goal of this work is to design an online control scheme for cloud clusters to participate in EDR.We propose a two-stage approach to address the above two problems.We first propose an auction mechanism to stimulate the participation of cloudlet clusters, such that (i) the auction is computationally efficient; (ii) the auction is truthful and individually rational-all participants receive non-negative and maximum utility by biding their true cost; (iii) the power reduction goal in EDR is met with minimum possible social cost.We then design an online task scheduling algorithm, tailored for a participant cloudlet cluster, to dispatch workloads to guarantee target EDR power consumption.Our algorithm has the following goals: (i) the algorithm is time efficient and makes task admission and scheduling decisions immediately upon the arrival of each task, (ii) the total power consumption in the specified EDR time window plus the local electricity generation can satisfy the EDR requirement, (iii) the utility of the cluster, which is completed tasks' value minus the cluster's operation cost, is maximized.Many edge-computing tasks have flexibility in both placement and job completion time, so their workload can be distributed across different cloudlets.In addition, they allow a certain level of delay, and the task's value depends on the degree of deadline violation.The operating cost primarily comprises of server maintenance cost and local generation cost.Our contributions are listed as follows: First, on the first stage of EDR, the smart grid acts as the auctioneer to elicit bids from cloudlet clusters.Each cluster specifies its energy reduction and corresponding remuneration it asks for.We formulate the social cost minimization problem as an integer linear program (ILP), with a constraint to satisfy the EDR reduction target.The problem is proven to be NP-hard.To solve the problem, we convert it to an equivalent ILP and adopt the primal-dual method to obtain the solution based on its dual problem.We show that our algorithm runs in polynomial time and achieves 2-approximation in social cost.We further propose a payment rule to determine winning clusters' reward, which guarantees truthfulness as well as individual rationality.
Second, we proceed to consider the second stage, where the winning cluster manages its tasks scheduling to satisfy the EDR power consumption requirement.We design an online scheduling algorithm to determine whether a task should be accepted or not, when and where the accepted task should be processed, and the amount of local electricity generation.The cluster's utility maximization problem is formulated as a convex problem.To eliminate the non-linear constraints that capture the task's temporal demand, we introduce a set of new variables for each task to represent feasible schedules.Although the new formulation has an exponential size of variables, we demonstrate that it can be solved in polynomial time.A primal-dual method is applied to the new formulation and its dual problem.Two dual variables can be interpreted as the unit workload price and the unit local generation cost, respectively.They are used as the threshold to compute the best schedule with the maximum utility for each task.The proof for feasibility, efficiency, and a good competitive ratio are conducted in our theoretical analysis.
Third, we conduct large-scale simulations based on the real-world circumstances.On the first stage of EDR, our algorithm performs better than the theoretical 2-approximation worst case, achieving nearly 1.05 in approximation ratio at a 50 clusters scale and 1.025 with 400 clusters.On the second stage of EDR, we also obtain several noticeable results: (i) our algorithm achieves a low competitive ratio (< 1.6); (ii) our algorithm beats two benchmark algorithms, a greedy algorithm based on the idea of [10] and a first-come, first-served algorithm applying the scheme in [11], in terms of cluster utility, either in different problem scales or time slots; (iii) our algorithm can control the peak usage of electricity and save up to 49.8%, 22.4% of the local generation, compared with other two algorithms, respectively; and (iv) the execution time of our algorithm grows mildly as problem scale increases, proving that our algorithm runs in polynomial time.Through extensive simulations in both theoretical and practical circumstances, we demonstrate the superiority of our method.
In the rest of this paper, we discuss related work in Section 2 and introduce the system model in Section 3. Algorithm designs for the first and second stage of edge EDR are presented in Sections 4 and 5, respectively.Section 6 evaluates the performance of proposed algorithms and Section 7 concludes the paper.

Related work
Demand response and edge EDR.Previous analyses for EDR tend to investigate the mutual impact between service providers and customers [12,13], without fully considering energy provisioning.A series of recent studies exist on the reduction goal and social welfare maximization in demand response.For instance, in [14], a storage-assisted system is considered, with batteries and plug-in vehicles helping balance between supply and user demand.Demand response in residential power allocation is investigated by Ma et al. [15], in which two types of electricity applications are analyzed.Sun et al. [16] study an eco-friendly objective for reducing diesel generation.Chen et al. [17] argue that edge computing represents a natural subject of EDR.Their work differs from ours in that they fix the execution time slot of each workload and assume a simplified linear cost for deadline violation; our model is comparatively more practical.There are also several studies on online task allocation in EDR, including [18] and [19].The former only maximizes the operator's cost while the latter ignores local generator consumption.Our work presents a general scenario in edge computing where auction and scheduling take place, targeting EDR in the provision of electricity supply and scheduling tasks online with more flexibility.
Datacenter EDR.Existing studies mainly focus on EDR with colocation data centers.Each colocation tenant submits a bid, including its energy reduction and cost, to the operator controller who provisions electricity and other services to them.Ren and Islam [20] are the first to study "split incentive" in a demand response scenario.They propose a mechanism, iCODE, based on a reverse auction.More efforts can be seen in the work of Zhang et al. [6], which designs an efficient truthful mechanism to achieve 2-approximation in colocation social cost.Zhou et al. [21] investigate a decentralized method in a geo-distributed data center.Zhou et al. [22] and Chen et al. [7] both study the FPTAS auction to design a truthful and energy-saving scheme.However, their assumptions of allocation in response to demand are barely offline situations.In our circumstance, the challenge escalates as a series of tasks arrive at the cloudlet stochastically over time.
Online Scheduling.Online scheduling is fundamental in cloud computing, where computing and storage resources are limited for task processing.Zhang et al. [8] propose a primal-dual style auction to dynamically allocate tasks into different VMs, in which the time windows of users' bids are fixed.Subsequently, Zhou et al. [9] develop the compact exponential method to handle hard and soft deadline constraints for job execution, showing more elastic than [8].Scheduling jobs online is also studied in a general way to suit every aspect of daily life.Specifically, Garg et al. [23] and Devanur et al. [24] study online scheduling jobs on unrelated machines, with the first paying attention to weighted flow time and the latter considering arbitrary power functions of the machine.Their researches share a primal-dual based framework with our model, but their problems are different from ours.Agrawal et al. [25] introduce a general version to solve online problems with a concave objective and convex constraints.However, they assume the inputs are independent and identically distributed.We study edge computing, targeting not only truthfulness and efficiency for the online mechanism appeared in cloud computing, but also the flexibility to schedule tasks in heterogeneous clusters.

System overview
We consider a community where a smart grid provisions electricity to multiple heterogeneous cloudlet clusters.Each cluster signs a contract with the grid, specifying the electricity demand in a certain time period and the corresponding payment.While the grid is only in charge of power supply, the cloudlet cluster is responsible for their own operation, i.e., considering how to schedule computing tasks, such that its utility is maximized under limited energy.Let [ X] denote the integer set {1, 2, . . ., X}.The cloudlet clusters are denoted as run in cluster i where they reside, receiving their workloads at end users via access points and transmitting them to the particular service providers.

EDR process.
According to an agreement signed by the cloudlet operators and the smart grid, when an emergency event takes place, the smart grid acts as an auctioneer and sends signals to cloudlet clusters in the community to specify the total energy reduction target E all in the following T time slots.In response, each cloudlet cluster voluntarily submits a bid.Recently, in edge computing, the tasks are mainly involved with video surveillance, whose power consumption usually varies little [26].Based on records in the past, the clusters estimate an energy reduction when the emergency takes place.Cluster i submits a bid (c i , E i ), where E i is the amount of power consumption it is willing to shed and c i is the corresponding remuneration asked for.After receiving bids from cloudlet clusters, the smart grid determines which clusters are chosen for the EDR, as well as how much it should pay for the selected clusters.Figure 1 illustrates the first stage in the EDR event.
EDR decision variable.We introduce a binary variable z i for each bid.If z i = 1, the bid submitted by cluster i is successfully chosen for EDR and earns a reward P i from the grid; otherwise, the bid is not selected for EDR.
Truthful auction.Let v i denote the true cost of E i .v i can be obtained from the previous data, usually proportional to the workload and duration.P i is the reward for winning the bid in EDR.Cluster i's utility with bidding price c i is: Each cluster is assumed to be selfish yet rational and aims to maximize its own utility.Cluster i may lie about its cost, i.e., c i = v i , if doing so leads to a higher utility.Since our goal is to minimize the social cost of the community, it is important to elicit truthful bids from clusters.

Definition 3 (Social welfare, social cost): The social welfare is the sum of the grid's utility − i∈[I] P i and clusters' utility i∈[I] (P i −v i z). Maximizing the social welfare is equivalent to minimizing the social cost i∈[I] v i z i , since payments cancel themselves.
EDR problem formulation.Our goal is to minimize the social cost in the community while ensuring the total reduction meets the EDR requirement E all .The social cost minimization problem under truthful bidding (c i = v i ) can be formulated into the following integer linear program (ILP): subject to:

Scheduling in cloudlet clusters
Computing task information.Assume that cluster i is chosen at EDR, where a total number of L i cloudlets are in the cluster.Each cloudlet l ∈[ L i ] can process at most R l workloads.Let [ J i ] denote the task set for i.Each task j in [ J i ] is expressed by a tuple: , where b ij is the value of task j if it completes before its deadline.a ij and d ij are the arrival time and the deadline for task j, w ij is the total number of time slots required to complete the task.We assume that the deadline for each task should be no longer than the end of the EDR period; otherwise, auctions must be executed again for those tasks.The workload in one time slot is λ ij , so the total workload of task j is w ij λ ij .τ ij refers to the level of deadline violation, whose penalty function is denoted by ) is a non-decreasing function, and f ij (0) = 0, defined as: Decision variable.As shown in Fig. 2, in the second stage, every cloudlet cluster operates individually and schedules computing tasks to satisfy EDR energy consumption.For simplicity, we omit i in the element of the tuple for cluster i.We introduce two additional binaries, x ij and y ijl (t), to indicate whether task j in cluster i is scheduled and whether task j is scheduled at cloudlet l at time slot t.Important notations are summarized in Table 1 for ease of reference.
Problem formulation.Cluster i aims to maximize its own utility, i.e., the sum of its reward and value minus the sum of the delay penalty, local generation cost, and main- , where P i indicates its reward, θ i is its maintenance cost.Since P i and θ i are constants, we can omit them for simplicity in our integer program.p is the per-unit local generation cost, and u g is the amount of local generation.The optimization problem is formulated as follows: x ij Task j in cluster i is accepted (1) or not (0) Task j is allocated in cluster i's l at t (1) or not (0) subject to : ) ) In the above problem, e t l denotes the electricity consumption of cloudlet l at time slot t.An empirical study on cloudlet [27] formulates the energy consumption through a linear function: e t l = N l P l idle + P l peak − P l idle j∈J λ ij y ijl (t) • PUE l , where N l represents the number of running servers in cloudlet l.P idle is the power consumption when the server is idle and P peak is the sever power when the cloudlet is fully utilized.j∈J λ ij y ijl (t) is the amount of workload.PUE l , the power usage efficiency ratio, is determined by statistical records of the ratio between the datacenter facility power and computational consumption.Next, since the EDR requires the chosen cloudlet cluster to reduce E i electricity, its expected power consumption is the original demand minus the EDR requirement, D − E.
Constraint (4a) guarantees that in each time slot, the cloudlet l has enough computing resource to execute tasks.Constraint (4b) ensures that the total power consumption does not exceed the sum of the EDR requirement and local generation.For any possible tasks to be scheduled, they should run between the arrival time and the deadline, which is described by (4c).Additionally, in (4d), we assume that each task runs on one cloudlet at most.Constraint (4e) connects two binary variables, x ij and y ijl (t), to guarantee sufficient execution.
Challenges.We notice that the first ILP (2) is the classical knapsack problem.The challenge escalates as we need to ensure truthfulness and individual rationality in the auction design.For the second problem (4), if we let u g = 0 and τ ij = 0, ∀j ∈ J, as well as ignore (4c), it becomes a knapsack problem.It is known to be NP-hard, let alone the difficulties concerning online scheduling.In Section 4, we propose a 2-approximation algorithm based on the primal-dual method to select winning clusters and compute payments for EDR event.In Section 5, we propose an online algorithm to schedule tasks while satisfying EDR requirement in the winners.

Methods for EDR auction mechanism
In Section 4.1, we propose an efficient algorithm to determine the winners and calculate payments in the first stage of EDR event.We analyze its performance in Section 4.2.

EDR auction design
In the winner determination process, we introduce a set of inequalities [28] and reformulate ILP (2) to obtain an approximate solution.Consider a set of cloudlet clusters S, i.e., S ⊂[ I], we denote (S) = E all − i∈S E i as the remaining electricity reduction goal when all bids in S are accepted.Furthermore, we define a variable, E i (S), to represent how a bid excluded from S can fill the gap between E all and (S), i.e., E i (S) = min{E i , (S)}.We reformulate ILP (2) into: subject to: Constraint (5a) states that when S ⊂[ I] is chosen, we enumerate all possible items in the rest of the set, [ I] \S, to cover the EDR target.It can be seen that all feasible integer solutions in ILP (2) are feasible in (5) and vice versa.Therefore, the two ILPs have equivalent optimal solutions.Next, we introduce dual variable m(S) to constraint (5a) and formulate the dual of (5) as: maximize subject to: Based on the primal-dual method, when the i * th constraint (6a) becomes tight, z i * in ( 5) is larger than 0. Due to the intrinsic 0 − 1 nature, z i will be automatically adjusted to 1.The basic idea is we initialize an empty set R to represent the accepted bid in accumulation and then gradually increase the value of dual variables, m(S), to reach the energy reduction objective in the aggregated accepted bids.In each round, we add one cluster to the set R until no more clusters are left or the EDR target is successfully achieved.
AMEDR aims to tighten the constraints (6a) so that the corresponding cluster is selected and its indicated variable is set to 1. First, we initialize all primal and dual variables in line 1.Line 2 states that the algorithm terminates only when the EDR demand is met.We increase the dual variable until one of the dual constraints is tight, as is shown in line 3.After calculating the minimum required value of the dual variable m(S), the corresponding cluster i * is selected, added to R in lines 3-4.Next, we design a payment rule to ensure truthfulness in lines 5-9.By picking the second smallest value, m( R) from all m(S), we find the critical bid and compute the payment based on it.Then, cost values are updated in line 10.Finally, the winner set S and their payments are found.Although many other auction mechanisms have been designed for such problems, our method has nice properties which are listed as follows.
All missing proofs can be found in the Appendix.

Theorem 3 The approximation ratio of AMEDR is 2.
Proof The primal problems (2) (5) have equivalent optimal value, OPT, with the dual problems (6).AMEDR terminates only when (R) ≤ 0. The last cluster picked by the algorithm is denoted as i n , so we have ( S\i n ) > 0.
Since every i in S\i n has a tight constraint in (6a), we reformulate the social cost among such items into: i∈ S ∀S⊂[I]:i⊂[I]\S, (S)>0 E i (S)m(S).However, due to the initialization, the non-negative variables m(S) remains zero unless S ⊂ S\i n .The equality above is simplified as S⊂ S m(S) i∈ S\S E i (S ).We further transform i∈ S\S E i (S) into , which is smaller than E all − i∈S E i +E i n (S).Moreover, it is no larger than 2 (S).Since ( S\i n ) > 0 holds, SC ≤ 2 S ⊂ S m(S) (S) ≤ 2OPT, ensuring that the approximation ratio is 2.

Truthfulness and individual rationality
Theorem 4 An auction mechanism is truthful if [29,30]: (i) as the costs submitted by clusters decrease, and z i is non-decreasing in its value; (ii) the winning bid payment is critical.
Lemma 2 Algorithm AMEDR is bid-monotonic: if cluster i * submits an alternative cost c ĩ subject to c ĩ < c i * and z i * = 1, then z ĩ = 1.

Lemma 3
The payment design in AMEDR is critical: the cost c i * submitted by winning bid i * should be not larger than the payment P i * .If i * bids c i * which is larger than P i * , i * will fail in the auction.

Theorem 5 AMEDR is a truthful auction.
Proof By combining Lemma 2, 3 and the definition in Theorem 4, we finish the proof.

Theorem 6 Algorithm AMEDR ensures individual rationality in each successful bid: the payments for bids are at least the cost of them.
Proof Lemma 3 guarantees that any bid that violates P i < c i cannot be chosen to win, and therefore, individual rationality holds during the auction.

Methods for online task scheduling
In the second stage of EDR event, supposing cluster i is selected, a primal-dual algorithm is proposed to schedule tasks in Section 5.1.The theoretical analysis is presented in Section 5.2.

Online scheduling design
Reformulation.We consider how to schedule tasks in the chosen cloudlet cluster i.To deal with non-conventional scheduling constraints in (4c) and (4e), we reformulate (4) into an equivalent convex problem.Though the new formulation is packed with an exponential number of variables, it greatly simplifies the subsequent algorithm design.The new problem is formulated as follows: maximize j∈J h∈ζ ij b ijh χ ijh − g(u) (7) subject to:

l∈[L] j∈[J] h:l∈L(h) t:t∈T(h)
) In the above program, ζ ij is the set of all feasible schedules for task j.A feasible schedule is a vector h = (x ij , {y ijl (t)} ∀l∈[L],∀t∈[T] , τ ij ) that satisfies constraints (4c) and (4e).Binary variable, χ ijh , indicates whether task j is accepted and scheduled according to schedule h (χ ijh = 1) or not (χ ijh = 0).b ijh is the task value based on schedule h, i.e., b ijh = b ij −f ij (τ ij ).T(h) and L(h) are the set of time slots and cloudlets indicating when and where task j is running based on schedule h.g(u) is the local generation cost of cluster i.We let • PUE l and u = D + u g .g(u) can be defined as a piecewise function as follows: g(u) indicates the energy consumption either below or above the EDR cap.We simplify the LHS of (4b), and let β l = (P l peak −P l idle )•PUE l .Constraints (7a) and (7b) are equivalent to (4a) and (4b).
Though we reformulate the problem into a packing structure, many challenges are still ahead of us.A primal-dual technique can be applied to solve the problem in polynomial time.By introducing dual variables Z l (t), C and φ ij , as well as relaxing χ ijh ∈ {0, 1} to χ ijh ≥ 0, the dual of the primal problem is: subject to: where g * (C) is the Fenchel conjugate [31] of the function g(u):

CD . o t h e r w i s e
Allocation and scheduling.Based on the idea of complementary slackness [32], each χ ijh has a corresponding constraint in (8a).Only when the constraint goes tight, can χ ijh be updated to 1.In that case, we automatically assign 1 to x ij and {y ijl (t)} l∈L(h),t∈T(h) before we renew dual variables φ ij , Z l (t) and C. Since φ ij in dual constraint is non-negative, we assign φ ij as the maximum value between 0 and the RHS of (8a): When φ ij > 0, dual constraint (8a) holds tight so that the related primal variable χ ijh > 0. In this case, task j is accepted, and h is the corresponding schedule for j.Otherwise, if The reason can be explained as follows: If we interpret Z l (t) as the per unit workload per unit time slot price for cloudlet l, and C as the per unit local generation cost, then the RHS of (8a) is the utility of task j.Therefore, when φ ij > 0, the utility of task j becomes positive so that the cluster is willing to process it.Note here C = 0 when the task does not exceed the EDR cap; otherwise, C = p.p is the local generation cost per unit.If there is a delay in the task completion, b ijh should contain the penalty expense; otherwise, b ijh = b ij .When the value of the RHS of ( 9) is 0, the task is rejected.Equality (9) determines the cloudlets and slots to schedule tasks for the maximum utility, which is a key to the utility maximization.

Algorithm 2 Primal-Dual Based Online Allocation PD
[ T], by default.
2: On the arrival of task j Schedule the jth task according to y ijl (t).

8: end if
We next discuss the update of Z l (t).It is natural to think that as computing resource in a cloudlet decreases, the cluster may be reluctant to allocate more workload to this cloudlet.We develop a cost function for the cloudlet to reduce the possibility of accepting a task when it is almost fully occupied.The cost function is: Where Z l (t) starts at N eσ and grows exponentially with the increase of R l (t).N refers to the minimum value per unit workload per unit slot, and σ = T min j {w ij } .By the time l is fully utilized, Z l (t) is close to M, the maximum value per unit workload per unit slot.More specifically, Calculate q(t, l) = Z l (t)λ ij . 5: end if 8: end for 9: Find l t = arg min l:(t,l)∈H q(t, l), ∀t.Add (t, l t ), ∀t to H. 10: Arrange time slots by sequence, and denote the w ij th slot as t 0 .11: for all t ∈ H : t 0 ≤ t ≤ T do 12: Select w ij − 1 slots in H with minimum q(t, l), t < t and add them to h t .Calculate Q(t ) = t∈h t q(t, l t ). 14: 16: 23: 24: For task j, given Z l (t) and C, the key step is to find the best schedule that maximizes task j's utility.The scheduling algorithm works as follows: upon the arrival of task j, we firstly fix the schedule between [ a ij , T].Since the original value of each task before the deadline is constant, we manage to calculate the resource consumption and energy expense in each plausible cloudlet and time slot.Then, in every situation, we fix the last time slot in order to find the minimal cost of the former (w ij − 1) slots.After adding the sum to the cost of the last time slot, we calculate the RHS of constraint (8a) and select the most economical one.Finally, we figure out the utility of task j according to (9) in each slot.We reject j if φ ij = 0; otherwise, j is accepted and we output the optimal schedule of task j.
Online scheduling algorithm.The online schedule algorithm PD for workload allocation in EDR is demonstrated in Algorithm 2. We input the needed variables for every cluster chosen by Algorithm 1.Initially, in line 1, all binary variables should be 0. Lines 2-8 call CORE in algorithm 3 and schedule each arriving task in the cluster.CORE computes x ij and y ijl (t) for each task while also updating dual variables Z l (t), with estimated M, N values by former data.In CORE, upon the arrival of task j, we make initialization in line 1 and add all possible tuple (t, l) in line 2. Lines 3-8 compute the cost per time slot in the feasible set.Local generation cost is added if and only if processing task j exceeds the EDR cap.Then, we choose the cloudlets with minimum costs in each time slot to be the candidates for the schedule in line 9.In line 10, we mark the w ij th slot.Lines 11-17 work as follows: by fixing the last slot for processing the task, the minimum cost of previous w ij − 1 slots should be picked up.When the completion time t violates the deadline, value for the task is diminished.Line 18 computes each possible utility and line 19 finds the max one.Lines 20-25 update binary and dual variables.If the previously selected utility is larger than 0, we accept the task and update cloudlet costs, amount of allocated resource, x ij and {y ijl (t)}; otherwise, no change is made.

Correctness and polynomial time
Theorem 7 The Algorithm PD computes a feasible solution for problems in (4) (7) and (8).
Theorem 8 PD runs in polynomial time.

Competitive ratio
The competitive ratio is defined as the upper bound ratio of the optimal objective value of (4) to the objective value achieved by PD.In reality, the ratio is always larger than 1.
We use OPT 1 and OPT 2 to denote the optimal objective values of ( 4) and (7).The equivalence between the two program indicates OPT 1 = OPT 2 .Let P 0 = 0 and D 0 = l t N eσ R l be the beginning primal and dual values.We assign different values to P j and D j in the accumulation process, until the algorithm finishes the tasks allocation by achieving P J and D J .Lemma 4 If one constant value α exists, such that (i) P j − P j−1 ≥ 1 α (D j − D j−1 ), ∀j ∈[ J], ii) P 0 = 0, D 0 ≤ OPT 2 e , the algorithm obtains e e−1 α-competitive.
Lemma 5 D 0 in PD is at most OPT 2 e under the condition that the optimal objective value of ( 4) is at least l TN σ R l .

Lemma 6
The allocation-utility relationship with α guarantees: Lemma 7 If α ensures the allocation-utility relationship for PD, then P j −P We posit that the resource consumption of the workload is much less than the existing resource capacity, which is λ ij R l , ∀j, ∀l.As a result, the differential dZ l (t) equals Z j l (t)− Z j−1 l (t).The adaptation of allocation-utility relationship is interpreted in the version: Definition 6 The allocation-utility relationship in a differential version with α is Proof According to our function, For any j, we can find an α ij holds the inequality such that Proof Combining Lemma 4-8 and the definition of allocation-utility relationship, we can figure out the competitive ratio for all tasks in [ J], and hence, the proof is completed.

Experiment setup
To simulate the whole edge system, we collect real-world data about EDR.According to a real EDR event happening in New York on August 28, 2018, which lasted for 6 h [33].Besides, the real field tests show that the EDR energy reduction rate under 25% would be tolerable for a data center to sustain the normal operation [34].As for cloudlet, it is a small-scale cloud data center with 1-40 servers [35].In this case, the typical PUE value is around 2.1 [36].As for the strike price for the EDR event, mostly it is around $1100 to $1800 per MWh [37].The EDR dispatch rate (i.e., the percentage of the number of clusters to engage in EDR event) is around 58% [38].The idle power for each server is 60 w, and the peak power is 180 w [39].The diesel price for local generation is set to 0.32$/kWh [40,41].
We use the data stated above to construct our simulations.We assume that on average, a cloudlet should have a PUE of 2.2 and contain 20 servers.And the overall energy-cutting rate (i.e., the demand for energy reduction in the EDR event) is 25% with a 6-h duration.We randomly scale the number of servers for each cloudlet from 16 to 20 and the PUE value from 1.9 to 2.5.In the experiment setting, one cluster contains 15 distributed cloudlets and is capable of executing 40 tasks.We set the length of one time slot into 10 min and divide the whole EDR process into 36 time slots.We randomly generate each cluster's bidding price based on the cutting energy amount and the unit price.The original power for one cluster is estimated to be 600 kWh according to the number and power of servers and cloudlets.In the aspect of tasks, we randomly generate the workload from 0.4x to 1.0x toward normalized 20 servers.We use the Poisson distribution to randomly set each task's arriving time and randomly generate the deadline before the EDR ends.The value of a task is proportional to its workload and the number of time slots required.We set M to be the upper bound of unit price, and N to be the lower bound because we randomly generate the unit price of each task from 0.01$ to 0.04$.
To deal with the objective value of integer programming (4), we use the MINLP solver SCIP [42] to obtain the offline optimal solution.We find the average acceptance rate is higher than 95% without using any local power generation, indicating that our experiment setting is suitable to simulate the real-world scenario.

Results and discussion
We consider several indexes to evaluate our algorithm: total social cost and approximation ratio on the first stage, and cluster utility, competitive ratio, and task acceptance rate on the second stage.Specifically, we compare four different approaches: (i) Greedy algorithm, which is based on [10], and always executes the maximum value task first in order to get optimal value; (ii) first-come, first-served (FCFS) algorithm, which always lets the early-arriving task schedules first and cannot be preempted by a later task [11]; (iii) Optimum programming, which returns the optimal offline solution; and (iv) mixed-integer programming (MIP), with PD on the second stage, which gets the optimal solution until current slot.
Performance of AMEDR. Figure 3a shows the trend of approximation ratio under different energy-cutting rates.Here, we fix the EDR dispatch rate to 60%, we can see that the ratio of AMEDR tends to converge to 1.025.This result in practice is much better than the theoretical bound.Figure 3b reflects the same result when we adjust the EDR dispatch rate.These simulations demonstrate that AMEDR has a close-to-optimal performance, especially with a large number of clusters.
Performance of PD.Firstly, we have to consider the influence of setting different M and N, the maximum and the minimum value per unit workload per unit slot, on the performance of PD.In Fig. 4a, suppose we already know all the task information and try to vary this ratio to 0.5x, 1.0x, and 1.5x.The simulation result indicates that this ratio only slightly influences the optimal value.Besides, in the simulation, this figure also reflects that competitive ratio is likely to increase as the number of tasks rises.
Figure 4b is the comparison between three online algorithms.We implement two benchmark algorithms, the Greedy algorithm and the FCFS algorithm.Figure 4c modifies the EDR duration time.We can find that the performance of PD is better than the greedy algorithm and the FCFS algorithm.Both algorithms do not take the task's elastic deadline into consideration, so they will reject some of the tasks.PD performs better because it looks for flexible scheduling.
We change the energy-cutting rate to evaluate our algorithm in a relatively extreme situation.In Fig. 4c, we can see that the cluster's utility decreases because we do not have enough power to execute all the tasks, or we have to pay the local generation cost for power replenishment.However, PD still beats the other two algorithms as well, because PD includes local generation cost if we have to replenish electricity and compare this cost with the task's utility.This utility measurement can avoid consuming power to execute low-value tasks.
In Fig. 4e, we assign different weights to the penalty function and analyze sensitivity.We find the weight of the penalty function can influence the acceptance rate.This means PD rejects the task if the delay penalty is too heavy.As for the greedy algorithm or the FCFS algorithm, they do not consider this condition but finish the task before the deadline.However, this attribute is useful in an extreme condition with substantial worthless tasks to execute.We assume there are enough cloudlets to finish all the tasks.Hence, the differences are slight in the figure .Figure 4f shows the electricity usage of different algorithms at each slot.We find that all algorithms perform well at low computation time, but PD can schedule tasks more efficiently at peak computation time.The local electricity usage of PD is 49.8%, 22.4% lower than the greedy algorithm, FCFS algorithm respectively, nearly close to the optimum.In this case, PD is more eco-friendly, compared with other algorithms.

Conclusion
In this work, we study how to enable edge emergency demand response via cloudlet clusters control.To address challenges in incentive mechanism design and task scheduling at participant cloudlet cluster, we propose a two stage control mechanism to facilitate edge EDR.In the first stage, a reverse auction, AMEDR, is proposed to select cost-efficient clusters and provide monetary remuneration to winners based on their energy reduction.We prove that AMEDR is computationally efficient, truthful, individual rational, and achieves 2-approximation in social cost.In the second stage, we design an online primaldual algorithm, PD, for chosen cluster to schedule and allocate its workload while satisfy EDR energy reduction requirement.PD runs in polynomial time and achieves a provable competitive ratio.We conduct large-scale simulations to verify the efficiency and advantages of our method over existing methods.

Fig. 1 A
Fig. 1 A demonstration of EDR via cloudlet clusters control

Fig. 2
Fig. 2 Task scheduling in the cluster

Fig. 4
Fig. 4 Performance evaluation on PD

Table 1
Major notations lEnergy consumption of cloudlet l at t u gTotal local generation