How to calculate the power consumption of a VM?

有些话、适合烂在心里 提交于 2019-12-29 09:37:15

问题


Respected researchers, i want to calculate the power consumed by the virtual machines of a physical server in a cloud datacenter. please help me i will be very thankful for this appreciation.


回答1:


 /**
     * The cost of each byte of bandwidth (bw) consumed.
     */
    protected double costPerBw;

    /**
     * The total bandwidth (bw) cost for transferring the cloudlet by the
     * network, according to the {@link #cloudletFileSize}.
     */
    protected double accumulatedBwCost;

    // Utilization
    /**
     * The utilization model that defines how the cloudlet will use the VM's
     * CPU.

This segment are taken from Cloudlet.java.line 212. This may be helpful.

Or, as you set each VM properties you can calculate the power consumption.

//VM description
            int vmid = 0;
            int mips = 250;
            long size = 10000; //image size (MB)
            int ram = 2048; //vm memory (MB)
            long bw = 1000;
            int pesNumber = 1; //number of cpus
String vmm = "Xen"; //VMM name

This segment taken from CloudSimExample3.java line 64




回答2:


CloudSim Plus has a built-in feature to compute VM's power consumption. The method below shows how to use such a feature. You can get the complete example here.

private void printVmsCpuUtilizationAndPowerConsumption() {
    for (Vm vm : vmList) {
        System.out.println("Vm " + vm.getId() + " at Host " + vm.getHost().getId() + " CPU Usage and Power Consumption");
        double vmPower; //watt-sec
        double utilizationHistoryTimeInterval, prevTime = 0;
        final UtilizationHistory history = vm.getUtilizationHistory();
        for (final double time : history.getHistory().keySet()) {
            utilizationHistoryTimeInterval = time - prevTime;
            vmPower = history.vmPowerConsumption(time);
            final double wattsPerInterval = vmPower*utilizationHistoryTimeInterval;
            System.out.printf(
                "\tTime %8.1f | Host CPU Usage: %6.1f%% | Power Consumption: %8.0f Watt-Sec * %6.0f Secs = %10.2f Watt-Sec\n",
                time, history.vmCpuUsageFromHostCapacity(time) *100, vmPower, utilizationHistoryTimeInterval, wattsPerInterval);
            prevTime = time;
        }
        System.out.println();
    }
}


来源:https://stackoverflow.com/questions/53942714/how-to-calculate-the-power-consumption-of-a-vm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!