1 Introduction

Cloud computing has emerged as a new paradigm for delivery of virtual resources and applications to end users in a pay-as-you-go model [1, 2]. Migrating from a traditional model to the cloud model can help to save the infrastructure investments and reduce the maintenance complexity [3, 4]. A growing number of big data application providers begin to deploy applications on virtual machines rented from the infrastructure as a service providers. The big data application providers pay for the virtual machines according to their use, likewise utilities such as electricity, gas, and water [5, 6]. When cloud computing is adopted, a major issue faced by the big data application providers is how to minimize the virtual machine rental cost while meet service requirements [7, 8].

Current infrastructure as a service providers offers diverse purchasing options for the application providers [9, 10]. There are mainly three types of purchasing options: reserved virtual machine, on-demand virtual machine and spot virtual machine. The price of spot virtual machine changes dynamically and periodically based on current demand and supply [11, 12]. The price of virtual machine is determined through an auction. If an application provider wins the bid, it obtains the right to use the virtual machines for which it bid [13]. The infrastructure as a service provider charges each hour by the last price. The virtual machine is stopped by the infrastructure as a service provider immediately when the bid is less than the current price. Therefore, spot virtual machine is suitable for large-scale divisible applications, e.g. big data analysis [14, 15]. When the virtual machine is stopped in out-of-bid condition, the infrastructure as a service provider does not charge the latest partial hour. Spot virtual machine is chosen by many big data application providers for its low rental cost per hour. Many optimal spot virtual machine purchasing approaches have been presented by the researchers [16, 17].

However, current cloud simulator can only support for reserved virtual machine purchasing and on-demand virtual machine purchasing. There is a shortage of simulators that enable researchers to evaluate the newly proposed spot virtual machine purchasing approach. To overcome these limitations of current cloud simulators, we propose SpotCloudSim, a CloudSim-based system which can support for spot virtual machine purchasing simulation. SpotCloudSim provides an extensible interface to help researchers implement the newly proposed spot virtual machine purchasing approach. In addition, SpotCloudSim can also study the behavior of the newly proposed spot virtual machine purchasing approaches. We demonstrate the capabilities of SpotCloudSim by using three spot virtual machine purchasing approaches. The results indicate the benefits of our proposed simulation system.

The rest of the paper is organized as follows. We discuss related work in Sect. 2. The background is introduced in Sect. 3. The design detail of our proposed SpotCloudSim is introduced in Sect. 4. The implementation detail of our proposed SpotCloudSim is introduced in Sect. 5. Section 6 gives an overview of our experiments. Finally, we conclude in Sect. 7.

2 Related work

In this section, related simulators are discussed. From past many years, distributed computing and Grid computing have gained widespread concern from the researches. Several simulators have been proposed to support the research and development of Grid computing. For example, SimGrid [18] and GridSim [19] are renowned grid simulators. However, none of them support for virtual and physical machine simulation, which is required by cloud computing environment.

To address the problem, a famous cloud simulator named CloudSim [20, 21] has been proposed. CloudSim is a cloud simulator developed by the CLOUDS Laboratory of University of Melbourne. CloudSim provides an extensible simulation framework that enables the simulation of cloud computing infrastructures and cloud application services. Researchers can evaluate their virtual machine purchasing approaches or resource allocation approaches by using CloudSim.

However, CloudSim still has some limitations. For example, CloudSim can only support for reserved virtual machine purchasing and on-demand virtual machine purchasing. Dynamic virtual machine pricing model cannot be supported by CloudSim. Fortunately, the extendibility of Cloudsim allows the researchers to add new features to it. Many simulators have been proposed by extending CloudSim. For example, Cloud2Sim, WorkflowSim, and CloudAuction.

Fig. 1
figure 1

Framework of CloudSim

In Cloud2Sim [22], a distributed concurrent architecture is added to simulations. By extending CloudSim, Cloud2Sim can have several virtual machines execute the same task. In addition, Cloud2Sim can elastically scale the virtual resources in the simulation.

WorkflowSim [23] can support of workflow execution in cloud datacenter. Workflow engine, workflow parser and job scheduler are implemented in WorkflowSim. The researcher can set delays and other relative attributes in WorkflowSim.

CloudAuction [24] is a little similar to our simulator. CloudAuction can handle auction based service and help to allocate virtual machines to participants based on the combinatorial double auction principle. The researchers can design an optimized auction mechanism by implementing the interface provided by CloudAuction. In addition, researchers can study whether the newly proposed mechanism can satisfy other users and providers. However, CloudAuction is not able to evaluate the spot virtual machine purchasing approach.

There are many other cloud simulators [25,26,27]. However, none of the current cloud simulator can simulate the spot virtual machine purchasing perfectly. SpotCloudSim is presented by this paper to address the problem. We will illustrate the design of SpotCloudSim in the next section.

3 Preliminaries

3.1 Framework of CloudSim

Figure 1 illustrates the framework of CloudSim. As shown in Fig. 1, CloudSim consists of four layers, which are the cloud resource layer, the cloud service layer, the virtual machine service layer, and the user interface structures layer, respectively. In CloudSim simulation, a data center consists of host servers and switches. All the host servers and switches are connected by datacenter network. The virtual machines that are placed on the same host server share the physical resource with each other. The physical resources are allocated to the virtual machines based on the allocation policies in the cloud service layer. All the allocation policies can be re-defined by the users.

3.2 Spot virtual machine purchasing

Because spot virtual machine is suitable for large-scale divisible applications, spot virtual machine is chosen by many big data application providers for its low rental cost per hour. As illustrated in Fig. 2, the price of spot virtual machine changes dynamically and spot virtual machine is purchased through an auction [28, 29]. After receives a job from the end user, the application provider decides how to bid for the spot virtual machine at the beginning of each bidding interval. When the bid is higher than the current price (t < 240), the application provider obtains the right to use the virtual machine. The job is processed by the virtual machine. When the bid is lower than the current price (t > 240), the virtual machine is immediately stopped by the infrastructure as a service provider. The job execution process is interrupted. Therefore, the computation is lost, and the job should be restarted from the beginning. In addition, the job execution time increases and the reliability is low. To overcome the problem, the checkpoint interface is provided by the infrastructure as a service provider. The application provider can employ the checkpoint mechanism to enhance the service reliability [30, 31]. When the checkpoint mechanism is adopted, the interrupted job can be restarted from the latest save checkpoint image in out-of-bid condition. Notice that the application provider can change the bid. We just take the fixed-bid strategy for example.

Fig. 2
figure 2

Execution process under dynamic pricing model

4 Design of SpotCloudSim

4.1 Framework of SpotCloudSim

As shown in Fig. 3, SpotCloudSim has added seven modules to CloudSim: rental fee charging module, spot virtual machine pricing module, spot virtual machine allocation module, out-of-bid event trigging module, purchasing decision-making module, coping strategy calculation module and experimental results displaying module. We will described the function of each module in this section.

Fig. 3
figure 3

Framework of SpotCloudSim

4.2 Rental fee charging module

The rental fee charging module charges the application provider based on the following rules: (1) The virtual machine pricing module charges each hour by the last price. (2) When the virtual machine is stopped by the infrastructure as a service provider, the virtual machine pricing module does not charge the latest partial hour. (3) The virtual machine pricing module charges the last partial hour when an application provider terminates a virtual machine. (4) The rental fee of a partial-hour is the same as a full-hour. This module is extensible. The researcher can implement his own rental fee charging rule by extending the default one.

Fig. 4
figure 4

Taking checkpoint periodically

4.3 Spot virtual machine pricing module

Because the price of the spot virtual machine changes with time, the virtual machine pricing module decides the current price for each type of virtual machine. The module can import the historical prices of Amazon spot virtual machine from .xml file, and set the current price of virtual machine based on the file.

4.4 Spot virtual machine allocation module

The spot virtual machine allocation module collects the bids from the application providers at the beginning of each bidding interval. Then, it allocates the virtual machines to the application providers based on the pre-defined rules. When the bid of an application provider is higher than the current price, the spot virtual machine allocation module allocate the virtual machines for the application provider as required. The spot virtual machine allocation module is extensible. The researcher can re-define the allocation rules as needed.

4.5 Out-of-bid event trigging module

When the bid of an application provider is less than the current price, the out-of-bid event trigging module stops the virtual machine immediately without any notice. In addition, the physical resources that have been allocated to the virtual machine are released.

Fig. 5
figure 5

Taking a checkpoint in rise price

4.6 Purchasing decision-making module

The prices of spot virtual machines fluctuate dynamically based on current demand and supply. The price of spot virtual machine is determined through an auction. An application provider can partially control the rental cost by setting the bid price. However, a lower bid price may lead to out-of-bid. Part of the computation is lost, and the total task execution time increases.

The purchasing decision-making module decides how to purchase the spot virtual machine based on the service requirements. For example, the application provider can set current bid price as the highest historical spot price if current task requires a quick response time. Otherwise, application provider can consider how to avoid high price, and purchase the spot virtual machine when the price is low. We have implement several basic purchasing decision-making strategies, such as random strategy, average price strategy and highest price strategy, in SpotCloudSim. The purchasing decision-making module is extensible. The researcher can implement his own spot virtual machine purchasing approach by extending the default ones.

4.7 Coping strategy calculation module

When an out-of-bid event happens, the virtual machine is stopped by the infrastructure as a service provider immediately without notice. The application provider should deal with the cost-reliability trade-offs. The infrastructure as a service provider, such as Amazon, provide a checkpoint interface to reduce the negative effects. Figures 4 and 5 illustrate two types of checkpoint-based strategy. In Fig. 4, a checkpoint is taken periodically. In Fig. 5, a check-point is taken when the spot price rises compared to the latest historical spot price. We add the coping strategy calculation module to support the checkpoint mechanism. We have implemented two basic checkpointing strategies in SpotCloudsim: taking checkpoint periodically and taking a checkpoint in rise price. By implementing the provided interface, the researchers can decide when to save the execution state of a virtual machine. The checkpoint interval has impact on the total rental cost. The task execution is suspended when a checkpoint is being taken. Spotcloudsim includes checkpoint as cost. Therefore, the application provider should make trade-off between the lost time for checkpoint taking and the lost time for out-of-bid.

4.8 Experimental results displaying module

Experimental results displaying module illustrates the simulation results to the user. In cloud computing environments, application providers should minimize the virtual machine rental cost while meet service requirements.

In other words, the task execution time should satisfy the service level agreement. Therefore, SpotCloudSim provides three types of performance metric to highlight the advantages and shortcomings of each spot virtual machine purchasing approach. The first performance metric type is the ability to save rental cost. This type of metric includes the rental cost (the rental fee the application provider has paid for completing each task), the total rental cost (the total rental fee the spot virtual machine purchasing approach has paid for completing all tasks). The second performance metric type is related to service level agreement satisfying. This type of metric includes the execution time (the time the spot virtual machine purchasing approach takes to complete each task), the total execution time (the total time the spot virtual machine purchasing approach takes to complete all tasks), the average lost time (the total lost time because of out-of-bid), and the out-of-bid frequency.

5 Implementation of SpotCloudSim

The class diagram of SpotCloudSim is illustrated in Fig. 6. The Bidder class represents an application provider. The Cashier class charges the application provider at the end of each charge interval. The Pricer class decides the current price for the spot virtual machines. The PriceProcesser class reads the historical spot prices from the excel file. The OBTrigger class triggers an out-of-bid event when the bid is lower than the current price. The Logger class is extended to the Recorder class. The Recorder class stores the results to the .log file and the database. The VmAllocationPolicy class is extended to the SpotVmAllocationPolicy class. The SpotVmAllocationPolicy class allocates the spot virtual machines to the application providers based on the bid and the current price. The CheckpointingScheduler class saves the state of the virtual machine based on the pre-defined strategy. We extend the class CloudSimTag and CloudSimConfig to add some configuration parameters.

We now describe the basic execution sequence of SpotCloudSim. The sequence diagrams are illustrated in Figs. 7 and 8. Figure 7 illustrates Spot virtual machine purchasing sequence. Firstly, the Bidder sets the highest acceptable per hour rental fee. Secondly, the Pricer calculates the current price of each type of spot virtual machine. For each bidder, if his bid is higher than the current price, the VmAllocationPolicy allocates the virtual machines for the application provider as required. Then, the Cashier charges the bidder at the end of each charge interval. If the bid is lower than current price and the application provider has already occupied the virtual machine, the OBTrigger stops virtual machine and releases the physical resource without notice. The Recorder stores required information to the database. Figure 8 illustrates the sequence of taking a checkpoint in rise price. The Pricer calculates the current price of each type of spot virtual machine. If the spot has changed, a price update event is sent to CheckpointScheduler. The CheckpointScheduler checks whether the price has risen. If the current price is higher than the latest historical spot price, a checkpoint-taking event is sent to relative virtual machine. The virtual machine starts to take a checkpoint as soon as the event has been received.

Fig. 6
figure 6

Class diagram of SpotCloudSim

Fig. 7
figure 7

Spot virtual machine purchasing sequence diagram

Fig. 8
figure 8

Taking a checkpoint in rise price sequence diagram

To validate and understand the effectiveness of SpotCloudSim, we conduct a set of experiments on real world spot dataset. We will discuss the experiment results in the next section.

6 Experiments

In this section, we illustrate the new features of SpotCloudSim by using three spot virtual machine purchasing approaches. Firstly, we describe the experimental setup. Then, experimental results are analyzed.

6.1 Experimental setup

All comparisons are carried out under the same experimental environment. The CPU is the Intel Core i7-5500U 2.4GHz, the RAM size is 8 GB, and the operating system is Windows 8. We experiment with three datasets: (1) dataset 1: the spot prices of eu linux m2.2xlarge, Amazon, from 2011 January 1 to 2011 January 30; (2) dataset 2: the spot prices of us suse m2.4xlarge, Amazon, from 2011 January 1 to 2011 January 30; (3) dataset 3: the spot prices of eu linux m2.4xlarge, Amazon, from 2011 January 1 to 2011 January 30. In our experiment, we generate 40 tasks. For each type of virtual machine, the task size is uniformly distributed between 200 min to 400 min. The checkpoint taking time is 2 min. We will demonstrate the capabilities of SpotCloudSim by using the following three spot virtual machine purchasing approaches:

  • HP (Highest Price): HP always selects the highest value of the historical spot prices as the bid price.

  • AP (Average Price): AP always selects the average value of the historical spot prices as the bid price.

  • RP (Random Price): RP always randomly generates a price between the highest price and the lowest price as the bid price.

Fig. 9
figure 9

Impact of the bidding strategy on the total rental cost. The figure illustrates the total rental cost of all spot virtual machine purchasing approaches under different spot price datasets

Two types of reliability enhancement strategies are employed by these approaches:

  • None: When an out-of-bid event occurs, the interrupted task is restarted from the beginning.

  • Period: A checkpoint is taken every 30 min.

We will evaluate the three spot virtual machine purchasing approaches by using the following two metric:

  • Total rental cost. The total rental rate paid by the application provider for completing all the tasks submitted by the end users. Total rental cost can be calculated as follows:

    $$\begin{aligned} Rental=\sum _{i=1}^{n}[rental(T_i)] \end{aligned}$$
    (1)

    where \(T_i\) denotes a task, and n denotes the total number of tasks. rental returns the rental rate paid by the application provider for completing \(T_i\).

  • Total execution time. The total time the approach takes to complete all the tasks submitted by the end users. Total execution time can be calculated as follows:

    $$\begin{aligned} Time=\sum _{i=1}^{n}t_{end}(T_i)- \sum _{i=1}^{n}t_{start}(T_i) \end{aligned}$$
    (2)

    where \(T_i\) denotes a task, and n denotes the total number of tasks. \(t_{start}\) is the time the task is received, \(t_{end}\) is the time the task is completed.

6.2 Impact of the bidding strategy

To study the impact of the bidding strategy on the total rental cost and the total execution time, we experiment on different spot datasets. No reliability enhancement strategy is employed. Figures 9 and 10 shows the experimental results. The experimental results in Figs. 9 and 10 show that: (1) the rental cost and the execution time are influenced by the bidding strategy; (2) HP outperforms other approaches consistently in the execution time and the rental cost; (3) AP performs poorly in the execution time and the rental cost. The average price is always lower or equal to the highest price. Therefore, the bid price of AP and RP are always lower or equal to the bid price of HP. When an application provider has a very low bid price, there is a higher chance that the bid price is lower than the final price of the spot virtual machine. The spot virtual machine frequently becomes unavailable. Therefore, the fraction of time that a virtual machine is available decreases with the decrease of the bid price. The continuous available periods of the spot virtual machine are relatively short, and the execution time becomes larger. Thats why HP outperforms AP and RP.

Fig. 10
figure 10

Impact of the bidding strategy on the total execution time. The figure illustrates the total execution time of all spot virtual machine purchasing approaches under different spot price datasets

6.3 Impact of the task number

The rental cost and the execution time are also influenced by the task number. To study the impact of the task number on the bidding results, we vary the task number from 10 to 40 with a step value of 10 in our experiment. No reliability enhancement strategy is employed. The performance of all the approaches is studied. Figures 11, 12, 13, 14, 15 and 16 show the performance of the approaches. The experimental results of Figs. 11, 12, 13, 14, 15 and 16 show that: (1) the rental cost and the execution time are significantly influenced by the task number; (2) HP still outperforms AP and RP consistently; (3) although the rental cost saved from a single task is not significant, the saved rental cost is proportional to the number of tasks. Therefore, much rental cost is saved when there are a large number of tasks.

Fig. 11
figure 11

The total rental cost of all spot virtual machine purchasing approaches under dataset 1

Fig. 12
figure 12

The total rental cost of all spot virtual machine purchasing approaches under dataset 2

Fig. 13
figure 13

The total rental cost of all spot virtual machine purchasing approaches under dataset 3

Fig. 14
figure 14

The total execution time of all spot virtual machine purchasing approaches under dataset 1

Fig. 15
figure 15

The total execution time of all spot virtual machine purchasing approaches under dataset 2

Fig. 16
figure 16

The total execution time of all spot virtual machine purchasing approaches under dataset 3

6.4 Impact of the checkpointing strategy

In this section, we study the impact of the checkpointing strategy on the total rental cost and the total execution time. The performance of all the approaches is studied. Figure 17 shows the performance of all approaches on the total rental cost. Fig. 18 shows the performance of all approaches on the total execution time. The experimental results of Figs. 17 and 18 show that: (1) the rental cost and the execution time are significantly influenced by the checkpointing strategy; (2) in AP and RP, the cost rental cost and the total execution time significantly decrease when the checkpointing strategy is employed; (3) in HP, the cost rental cost and the total execution time increase a little when the checkpointing strategy is employed.

Fig. 17
figure 17

Impact of the checkpointing strategy on the total rental cost. This figure illustrates the total rental cost of all spot virtual machine purchasing approaches under dataset 1

Fig. 18
figure 18

Impact of the checkpointing strategy on the total execution time. This figure illustrates the total execution time of all spot virtual machine purchasing approaches under dataset 1

In summary, we can conclude from the above experiments that SpotCloudSim can help to highlight the advantages and shortcomings of the spot virtual machine purchasing approaches.

7 Conclusion

In this paper, we present a CloudSim-based cloud simulator named SpotCloudSim for simulation of spot virtual machine purchasing approach. SpotCloudSim consists of the new features: (1) rental fee charging, (2) virtual machine pricing, (3) spot virtual machine allocation, (4) purchasing decision-making, (5) out-of-bid event trigging, (6) coping strategy calculation (7) experimental results displaying. We illustrate the new features of SpotCloudSim by using three spot virtual machine purchasing approaches. The experimental results show that SpotCloudSim can illustrate the advantages and shortcomings of each approach. We will provide an easy-to-use user interface for the researchers in our future work.