Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 67

Raj Kumar Goel Institute of Technology, Ghaziabad

LABORATORY MANUAL

Faculty Name : Mr Pawan Pandey Department : CSE

Course Name : Cloud Computing Lab Course Code : KCS751A

Year/Sem : 4th/7
th
NBA Code : C406

Email ID : pawanfcs@rkgit.edu.in Academic Year : 2021-22

Department of Computer Science and Engineering


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

VISION OF THE INSTITUTE

To continually develop excellent professionals capable of providing sustainable solutions to


challenging problems in their fields and prove responsible global citizens.

MISSION OF THE INSTITUTE

We wish to serve the nation by becoming a reputed deemed university for providing value based
professional education.

VISION OF THE DEPARTMENT

To be recognized globally for delivering high quality education in the ever changing field of computer
science & engineering, both of value & relevance to the communities we serve.

MISSION OF THE DEPARTMENT

1. To provide quality education in both the theoretical and applied foundations of Computer Science
and train students to effectively apply this education to solve real worldproblems.
2. To amplify their potential for lifelong high quality careers and give them a competitive advantage
in the challenging global workenvironment.

PROGRAM EDUCATIONAL OUTCOMES (PEOs)

PEO 1: Learning: Our graduates to be competent with sound knowledge in field of Computer
Science &Engineering.
PEO 2: Employable: To develop the ability among students to synthesize data and technical
concepts for application to software product design for successful careers that meet the
needs of Indian and multinationalcompanies.
PEO 3: Innovative: To develop research oriented analytical ability among students to prepare them
for making technical contribution to the society.
PEO 4: Entrepreneur / Contribution: To develop excellent leadership quality among students
which they can use at different levels according to their experience and contribute for
progress and development in thesociety.
.

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

PROGRAM OUTCOMES (POs)

Engineering Graduates will be able to:

PO1: Engineering knowledge: Apply the knowledge of mathematics, science,


engineering fundamentals, and an engineering specialization to the solution of complex
engineeringproblems.

PO2: Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineeringsciences.

PO3: Design/development of solutions: Design solutions for complex


engineering problems and design system components or processes that meet the specified
needs with appropriate consideration for the public health and safety, and the cultural,
societal, and environmentalconsiderations.

PO4: Conduct investigations of complex problems : Use research-based


knowledge and research methods including design of experiments, analysis and interpretation
of data, and synthesis of the information to provide validconclusions.

PO5: Modern tool usage: Create, select, and apply appropriate techniques,
resources, a n d modern engineering and IT tools including prediction and modelling to complex
engineering activities with an understanding of thelimitations.

PO6: The engineer and society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineeringpractice.

PO7: Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainabledevelopment.

PO8: Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineeringpractice.

PO9: Individual and team work: Function effectively as an individual, and as a member
or leader in diverse teams, and in multidisciplinarysettings.

PO10: Communication: Communicate effectively on complex engineering activities with the


engineering community and with society at large, such as, being able to

Department of Computer Science & Engineering

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
comprehend and write effective reports and design documentation, make effective
presentations, and give and receive clearinstructions.

PO11: Project management and finance: Demonstrate knowledge and


understanding of the engineering and management principles and apply these to one’s
own work, as a member and leader in a team, to manage projects and in
multidisciplinary environments.

PO12: Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.

PROGRAM SPECIFIC OUTCOMES (PSOs)

PSO1: The ability to use standard practices and suitable programming environment to develop
softwaresolutions.

PSO2: The ability to employ latest computer languages and platforms in creating innovative career
opportunities.

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
Department of Computer Science & Engineering

COURSE OUTCOMES (COs)

CO406.1 Able to understand and install tools for cloud environment


CO406.2 Able to run basic programs on cloudsim
CO406.3 Able to implement task scheduling algorithms in Cloud system

CO406.4 Able to simulate the configuration on Cloud Analyst

CO406.5 Able to use Cloud Computing in real time applications

CO-PO MAPPING
NBA
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2
CODE
C406.1
3 3 3 3 2 2 2 3 3 3 3
C406.2
3 2 3 3 3 2 2 3 3 3 3
C406.3
3 2 3 3 2 1 2 2 3 3 3 3
C406.4
2 2 3 3 3 1 2 2 3 2 3
C406.5
2 2 3 3 3 1 2 2 3 2 3

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page 5


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

LIST OF EXPERIMENTS

Sr. No. Title of experiment Corresponding CO

1 To understand the NIST cloud models, types of service and C406.1


deployment models and prerequisite to install the same.

2 Install CloudSim and run code to create Datacentre with C406.2


multiple VM
3 Write code to create a datacentre with multiple VM and C406.2
multiple host

4 Simulate a cloud scenario using CloudSim and run cloudlets C406.3


with different configuration

5 Implement SJF algorithm in cloudlet scheduling in Cloudsim C406.3

6 Install CloudAnalyst and simulate various Datacentre, VM C406.4


configuration.

7 Case Study on AmazonEC2/Microsoft Azure. C406.5

8 Deploy application on commercial cloud(Google cloud C406.5


platform)

Department of Computer Science & Engineering

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page 6


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

DO’S AND DONT’S

DO’s

1. Conform to the academic discipline of thedepartment.


2. Enter your credentials in the laboratory attendanceregister.
3. Read and understand how to carry out an activity thoroughly before coming to the
laboratory.
4. Ensure the uniqueness with respect to the methodology adopted for carrying out the
experiments.
5. Shut down the machine once you are done usingit.

DONT’S

1. Eatables are not allowed in thelaboratory.


2. Usage of mobile phones is strictlyprohibited.
3. Do not open the system unitcasing.
4. Do not remove anything from the computer laboratory withoutpermission.
5. Do not touch, connect or disconnect any plug or cable without your faculty/laboratory
technician’spermission.

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page 7


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

GENERAL SAFETY INSTRUCTIONS

1. Know the location of the fire extinguisher and the first aid box and how to use them in caseof
anemergency.

2. Report fires or accidents to your faculty /laboratory technicianimmediately.

3. Report any broken plugs or exposed electrical wires to your faculty/laboratory


technicianimmediately.

4. Do not plug in external devices without scanning them for computerviruses.

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page 8


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

GUIDELINES FOR LABORTORY RECORD PREPARATION

While preparing the lab records, the student is required to adhere to the following guidelines:

Contents to be included in Lab Records:


1. Coverpage
2. Vision
3. Mission
4. PEOs
5. POs
6. PSOs
7. COs
8. CO-PO-PSO mapping
9. Index
10. Experiments
Aim
Source code
Input-Output

A separate copy needs to be maintained for pre-lab written work


The student is required to make the Lab File as per the format given on the next two pages.

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page 9


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

Raj Kumar Goel Institute of Technology, Ghaziabad

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Cloud Computing LAB (KCS-751A)

Name
Alok Kumar Singh

Roll No. 1803310034

“C”-C1
Section- Batch

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

INDEX

ExpNo. Experiment Name Date of Date of Faculty

Conduction Submission Signature

1. To understand NIST 15/09/2021 22/09/2021

2. To Install Cloudsim and run code 22/09/2021 29/09/2021

3. To code to Create a Datacentre 29/09/2021 06/10/2021

4. To simulate a cloud scenario 06/10/2021 20/10/2021

5. To Implement SJF Algorithm 20/10/2021 27/10/2021

6. To Install CloudAnalyst 27/10/2021 03/11/2021

7. Case study on Amazon EC2 03/11/2021 10/11/2021

8. To Deploy App on Cloud 10/11/2021 17/11/2021

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

GUIDELINES FOR ASSESSMENT

Students are provided with the details of the experiment (Aim, pre-experimental questions, procedure
etc.) to be conducted in next lab and are expected to come prepared for each lab class.
Faculty ensures that students have completed the required pre-experiment questions and they complete
the in-lab programming assignment(s) before the end of class. Given that the lab programs are meant
to be formative in nature, students can ask faculty for help before and during the labclass.
Students’ performance will be assessed in each lab based on the following Lab Assessment
Components:
AC1: Written Work (Max. marks = 5)
AC2: Fundamental Knowledge to conduct Experiment (Max. marks = 5)
AC3: Experiment Completed Successfully (Max. marks = 5)
AC4: Questions Answered (Max. marks = 5)
AC5: Punctuality (Max. marks = 5)

In each lab class, students will be awarded marks out of 5 under each component head, making
it total out of 25marks.

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

Department of Computer Science & Engineering

Cloud Computing Lab (KCS751A)

EXPERIMENT – 1

1. To understand the NIST cloud models, types of service and deployment models and
prerequisite to install thesame.

Refer Document “NIST Cloud Computing Models.pdf”

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
Experiment No 2:

Install CloudSim and run code to create Datacentre with multiple VM

CloudSim is a framework for modelling and simulating cloud computing infrastructure and services.
In this DIY we will see how to install CloudSim in Windows easily and efficiently. A more detailed
description, APIs and research papers related to CloudSim can be found here. Let us begin.

Step 1: Setting up the Prerequisites

1. First of all we need to download the CloudSim and latest version of the Java Development Toolkit
(JDK). These can be foundhere:

● CloudSim3.0.3

● JDK latest version forWindows

Note: It is advisable that you must download the appropriate version of the JDK for your system i.e.
x86 version for x86 systems and x64 version for x64 systems.

2. CloudSim requires a working JRE, so install theJDK.

3. Now its time to install the CloudSim. Unpack the downloaded 'CloudSim-3.0.3.tar.gz' or
'CloudSim-3.0.3.zip' (let the name of the unpacked folder be 'cloudsim-3.0.3'). As you can see there is
no executable file inside the folder so there is no special program to install the CloudSim. Later if you
want to remove the CloudSim, then remove the whole 'cloudsim-3.0.3'directory.

Step 2: Setting up the Environment

Now comes the critical part, the most important part of the CloudSim setup is the setting up the paths
to different classes and jar files correctly or you won't be able to run your programs efficiently.

1. The first path to be set is the 'Path' variable which will contain the location of executable java files
such as 'javac' and 'java' and will be used by the CloudSim while compiling and running a CloudSim
or Javaprogram.

2. The second path to be set is the 'CLASSPATH' variable which will contain the location of the class
files and will be used by the CloudSim while executing an application. So we have to set three
consecutive values first one for location of JDK executables, second one is the location of jar files
provided in the CloudSim and is used exclusively by the CloudSim applications and third one is the
location where we have stored ourprograms.

To set the paths go to the properties of 'My Computer' —>'Advanced system settings' —>'Advanced'
tab —>'Environment Variables...' —>under the 'System variables' —>'New...' —>in the popped up
box set the 'Variable name' and 'Variable Value' as shown and click 'OK'.

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

Variable name Variable value

Path C:\Program Files\Java\jdk1.8.0_11\bin;

CLASSPATH C:\Program Files\Java\jdk1.8.0_11\bin; C:\Users\

Dhyan\Desktop\cloudsim-3.0.3\jars\*; C:\Users\

Dhyan\Desktop\cloudsim-3.0.3\examples;

Note: We have to close all the opened command prompt windows, if any.

Step 3: Testing the Setup (Compiling and Executing a CloudSim Application)

Finally now we can test whether our installation is successful or not. CloudSim includes some test
example programs in the 'CloudSim\examples\gridsim\' folder that we can use to test our setup.

1. Compiling a CloudSim program: If you have followed this DIY then compiling a CloudSim
program is pretty straightforward; the basic syntax for compilation is just similar to that of Java
programs i.e.javac filename.java or javacfile_location\filename.java. Let us compile the
Example2.java included in 'CloudSim\examples\gridsim\example02\' folder. We will now run the
following command in a new commandprompt

javac C:\Users\Dhyan\Desktop\cloudsim- 3.0.3\examples\org\cloudbus\cloudsim\examples\CloudSimExample1.java

2. Running the compiled program: The syntax for running a compiled CloudSim program is similar
to that of running a program in Java i.e. java filename. In our case we have to type (see image1)

java org.cloudbus.cloudsim.examples.CloudSimExample1

OR if you want to save the output of your program to a file you can use the following

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

java org.cloudbus.cloudsim.examples.CloudSimExample1 > output.txt

Note: The examples given in the CloudSim uses the concept of packages hence it is advisable to go
through the basics of packages in Java for a better understanding of the above stated commands.

Image 1. Testing the Setup.

Some Important Points

● It is important to set the CLASSPATH correctly, if you make any mistake you might get a
class not found error and if you want to supply the classpath externally while compiling

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
using -cp or -classpath; then for some reason it might not work and you would still get the same errors.
Remember to change the 2nd and 3rd CLASSPATH values if you later decide to move the jar files of the CLoudSim
You can also use CloudSim with the EclipseIDE.

/*
* Title: CloudSimToolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling andSimulation
* of Clouds
* Licence: GPL -http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009, The University of Melbourne,Australia
*/

package org.cloudbus.cloudsim.examples;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
importjava.util.List;

import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;

/**
* A simple example showing how tocreate
* a datacenter with one host and runtwo
DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V SEM) Page 17
Raj Kumar Goel Institute of Technology,
* cloudlets on it. The cloudlets runin
* VMs with the same MIPSrequirements.
* The cloudlets will take the same timeto
* complete theexecution.
*/
public class CloudSimExample2 {

/** The cloudlet list. */


private static List<Cloudlet>cloudletList;

/** The vmlist. */


private static List<Vm>vmlist;

/**
* Creates main() to run thisexample
*/
public static void main(String[] args)

{ Log.printLine("Starting

CloudSimExample2...");

try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 1; // number of cloud users
Calendar calendar= Calendar.getInstance();
booleantrace_flag = false; // mean traceevents

// Initialize the CloudSim library


CloudSim.init(num_user, calendar,trace_flag);

// Second step: Create Datacenters


//Datacenters are the resource providers in CloudSim. We need at list one of them to run a
CloudSim simulation
@SuppressWarnings("unused")
Datacenter datacenter0 = createDatacenter("Datacenter_0");

//Third step: Create Broker


DatacenterBroker broker = createBroker();
int brokerId = broker.getId();

//Fourth step: Create one virtual machine


vmlist = new ArrayList<Vm>();

//VM description
int vmid = 0;
int mips = 250;
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page
Raj Kumar Goel Institute of Technology,
long bw = 1000;
int pesNumber = 1; //number of cpus

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
String vmm = "Xen"; //VMM name

//create two VMs


Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());

vmid++;
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());

//add the VMs to the


vmListvmlist.add(vm1);
vmlist.add(vm2);

//submit vm list to the broker


broker.submitVmList(vmlist);

//Fifth step: Create two Cloudlets


cloudletList = new ArrayList<Cloudlet>();

//Cloudlet properties
int id = 0;
pesNumber=1;
long length = 250000;
long fileSize = 300;
long outputSize = 300;
UtilizationModelutilizationModel = new UtilizationModelFull();

Cloudlet cloudlet1 = new Cloudlet(id, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet1.setUserId(brokerId);

id++;
Cloudlet cloudlet2 = new Cloudlet(id, length, pesNumber, fileSize, outputSize,
utilizationModel, utilizationModel, utilizationModel);
cloudlet2.setUserId(brokerId);

//add the cloudlets to the list


cloudletList.add(cloudlet1);
cloudletList.add(cloudlet2);

//submit cloudlet list to the broker


broker.submitCloudletList(cloudletList);

//bind the cloudlets to the vms. This way, the broker


// will submit the bound cloudlets only to the specific VM
broker.bindCloudletToVm(cloudlet1.getCloudletId(),vm1.getId());
broker.bindCloudletToVm(cloudlet2.getCloudletId(),vm2.getId());

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

// Sixth step: Starts the simulation


CloudSim.startSimulation();

// Final step: Print results when simulation is over


List<Cloudlet>newList = broker.getCloudletReceivedList();

CloudSim.stopSimulation();

printCloudletList(newList);

Log.printLine("CloudSimExample2 finished!");
}
catch (Exception e)
{ e.printStackTrace
();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}

private static Datacenter createDatacenter(String name){

// Here are the steps needed to create a PowerDatacenter:


// 1. We need to create a list to store
// ourmachine
List<Host>hostList = new ArrayList<Host>();

// 2. A Machine contains one or more PEs or CPUs/Cores.


// In this example, it will have only one core.
List<Pe>peList = new ArrayList<Pe>();

int mips = 1000;

// 3. Create PEs and add these into a list.


peList.add(new Pe(0, new PeProvisionerSimple(mips))); // need to store Pe id and MIPS
Rating

//4. Create Host with its id and list of PEs and add them to the list of machines
int hostId=0;
int ram = 2048; //host memory (MB)
long storage = 1000000; //host storage
int bw = 10000;

hostList.add
(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page
Raj Kumar Goel Institute of Technology,
peList,

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
new VmSchedulerTimeShared(peList)
)
); // This is our machine

// 5. Create a DatacenterCharacteristics object that stores the


// properties of a data center: architecture, OS, listof
// Machines, allocation policy: time- or space-shared, timezone
// and its price (G$/Pe timeunit).
String arch = "x86"; // system architecture
String os = "Linux"; // operating system
String vmm = "Xen";
double time_zone= 10.0; // time zone this resourcelocated
double cost= 3.0; // the cost of using processing in thisresource
double costPerMem= 0.05; // the cost of using memory in this resource
double costPerStorage=0.001; // the cost of using storage in thisresource
double costPerBw=0.0; // the cost of using bw in this resource
LinkedList<Storage>storageList =newLinkedList<Storage>(); //we are not addingSAN
devices by now

DatacenterCharacteristics characteristics = new DatacenterCharacteristics(


arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage, costPerBw);

// 6. Finally, we need to create a PowerDatacenter object.


Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}

return datacenter;
}

//We strongly encourage users to develop their own broker policies, to submit vms and
cloudlets according
//to the specific rules of the simulated scenario
private static DatacenterBrokercreateBroker(){

DatacenterBroker broker = null;


try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

/**
* Prints the Cloudlet objects
* @param list list ofCloudlets
*/
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;

String indent=" ";


Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent +
"Data center ID" + indent + "VM ID" + indent + "Time" + indent + "Start Time" +
indent + "Finish Time");

DecimalFormatdft = new DecimalFormat("###.##");


for (int i = 0; i< size; i++) {
cloudlet = list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent + indent);

if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS){
Log.print("SUCCESS");

Log.printLine( indent + indent + cloudlet.getResourceId() + indent + indent + indent +


cloudlet.getVmId() +
indent + indent + dft.format(cloudlet.getActualCPUTime()) + indent + indent +
dft.format(cloudlet.getExecStartTime())+
indent + indent + dft.format(cloudlet.getFinishTime()));
}
}

}
}

Experiment 3.

Write code to create a datacentre with multiple VM and multiple host

/*
* Title: CloudSimToolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling andSimulation
* of Clouds
* Licence: GPL -http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009, The University of Melbourne,Australia
*/

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
package org.cloudbus.cloudsim.examples;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
importjava.util.List;

import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerSpaceShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;

/**
* A simple example showing how tocreate
* two datacenters with one host eachand
* run two cloudlets onthem.
*/
public class CloudSimExample4 {

/** The cloudlet list. */


private static List<Cloudlet>cloudletList;

/** The vmlist. */


private static List<Vm>vmlist;

/**
* Creates main() to run thisexample
*/
public static void main(String[] args)

{ Log.printLine("Starting

CloudSimExample4...");

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
try {
// First step: Initialize the CloudSim package. It should be called

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
// before creating any entities.
int num_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance();
booleantrace_flag = false; // mean traceevents

// Initialize the GridSim library


CloudSim.init(num_user, calendar,trace_flag);

// Second step: Create Datacenters


//Datacenters are the resource providers in CloudSim. We need at list one of them
to run a CloudSim simulation
@SuppressWarnings("unused")
Datacenter datacenter0 = createDatacenter("Datacenter_0");
@SuppressWarnings("unused")
Datacenter datacenter1 = createDatacenter("Datacenter_1");

//Third step: Create Broker


DatacenterBroker broker = createBroker();
int brokerId = broker.getId();

//Fourth step: Create one virtual machine


vmlist = new ArrayList<Vm>();

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

//create two VMs


Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());

vmid++;
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());

//add the VMs to the


vmListvmlist.add(vm1);
vmlist.add(vm2);

//submit vm list to the broker


broker.submitVmList(vmlist);

//Fifth step: Create two Cloudlets


cloudletList = new ArrayList<Cloudlet>();

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

//Cloudlet properties
int id = 0;
long length = 40000;
long fileSize = 300;
long outputSize = 300;
UtilizationModelutilizationModel = new UtilizationModelFull();

Cloudlet cloudlet1 = new Cloudlet(id, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet1.setUserId(brokerId);

id++;
Cloudlet cloudlet2 = new Cloudlet(id, length, pesNumber, fileSize, outputSize,
utilizationModel, utilizationModel, utilizationModel);
cloudlet2.setUserId(brokerId);

//add the cloudlets to the list


cloudletList.add(cloudlet1);
cloudletList.add(cloudlet2);

//submit cloudlet list to the broker


broker.submitCloudletList(cloudletList);

//bind the cloudlets to the vms. This way, the broker


// will submit the bound cloudlets only to the specific VM
broker.bindCloudletToVm(cloudlet1.getCloudletId(),vm1.getId());
broker.bindCloudletToVm(cloudlet2.getCloudletId(),vm2.getId());

// Sixth step: Starts the simulation


CloudSim.startSimulation();

// Final step: Print results when simulation is over


List<Cloudlet>newList = broker.getCloudletReceivedList();

CloudSim.stopSimulation();

printCloudletList(newList);

Log.printLine("CloudSimExample4 finished!");
}
catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}

private static Datacenter createDatacenter(String name){

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

// Here are the steps needed to create a PowerDatacenter:


// 1. We need to create a list to store
// ourmachine
List<Host>hostList = new ArrayList<Host>();

// 2. A Machine contains one or more PEs or CPUs/Cores.


// In this example, it will have only one core.
List<Pe>peList = new ArrayList<Pe>();

int mips = 1000;

// 3. Create PEs and add these into a list.


peList.add(new Pe(0, new PeProvisionerSimple(mips))); // need to store Pe id and MIPS
Rating

//4. Create Host with its id and list of PEs and add them to the list of machines
int hostId=0;
int ram = 2048; //host memory (MB)
long storage = 1000000; //host storage
int bw = 10000;

//in this example, the VMAllocatonPolicy in use is SpaceShared. It means that only one
VM
//is allowed to run on each Pe. As each Host has only one Pe, only one VM can run on
each Host.
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerSpaceShared(peList)
)
); // This is our first machine

// 5. Create a DatacenterCharacteristics object that stores the


// properties of a data center: architecture, OS, listof
// Machines, allocation policy: time- or space-shared, timezone
// and its price (G$/Pe timeunit).
String arch = "x86"; // system architecture
String os = "Linux"; // operating system
String vmm = "Xen";
double time_zone= 10.0; // time zone this resourcelocated
double cost =3.0; // the cost of using processing in thisresource
double costPerMem= 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in thisresource
double costPerBw= 0.0; // the cost of using bw in thisresource
DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page
Raj Kumar Goel Institute of Technology,
LinkedList<Storage>storageList = new LinkedList<Storage>(); //we are not adding SAN
devices by now

DatacenterCharacteristics characteristics = new DatacenterCharacteristics(


arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage, costPerBw);

// 6. Finally, we need to create a PowerDatacenter object.


Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}

return datacenter;
}

//We strongly encourage users to develop their own broker policies, to submit vms and cloudlets
according
//to the specific rules of the simulated scenario
private static DatacenterBrokercreateBroker(){

DatacenterBroker broker = null;


try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}

/**
* Prints the Cloudletobjects
* @param list list ofCloudlets
*/
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;

String indent=" ";


Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent +
"Data center ID" + indent + "VM ID" + indent + "Time" + indent + "Start
Time" + indent + "Finish Time");

DecimalFormatdft = new DecimalFormat("###.##");

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
for (int i = 0; i< size; i++)
{ cloudlet =
list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent + indent);

if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS){
Log.print("SUCCESS");

Log.printLine( indent + indent + cloudlet.getResourceId() + indent +


indent + indent + cloudlet.getVmId() +
indent + indent +
dft.format(cloudlet.getActualCPUTime()) + indent + indent +
dft.format(cloudlet.getExecStartTime())+
indent + indent + dft.format(cloudlet.getFinishTime()));
}
}

}
}

Experiment No 4:

Simulate a cloud scenario using CloudSim and run cloudlets with different configuration

/*
* Title: CloudSimToolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling andSimulation
* of Clouds
* Licence: GPL -http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009, The University of Melbourne,Australia
*/

package org.cloudbus.cloudsim.examples;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;

import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page
Raj Kumar Goel Institute of Technology,
importorg.cloudbus.cloudsim.Storage;

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerSpaceShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;

/**
* A simple example showing how tocreate
* two datacenters with one host eachand
* run cloudlets of two users onthem.
*/
public class CloudSimExample5 {

/** The cloudlet lists. */


private static List<Cloudlet> cloudletList1;
private static List<Cloudlet> cloudletList2;

/** The vmlists. */


private static List<Vm> vmlist1;
private static List<Vm> vmlist2;

/**
* Creates main() to run thisexample
*/
public static void main(String[] args)

{ Log.printLine("Starting

CloudSimExample5...");

try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 2; // number of cloud users
Calendar calendar = Calendar.getInstance();
booleantrace_flag = false; // mean traceevents

// Initialize the CloudSim library


CloudSim.init(num_user, calendar,trace_flag);

// Second step: Create Datacenters


//Datacenters are the resource providers in CloudSim. We need at list one of them
to run a CloudSim simulation
@SuppressWarnings("unused")
Datacenter datacenter0 = createDatacenter("Datacenter_0");

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
@SuppressWarnings("unused")
Datacenter datacenter1 =createDatacenter("Datacenter_1");

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

//Third step: Create Brokers


DatacenterBroker broker1 = createBroker(1);
int brokerId1 =broker1.getId();

DatacenterBroker broker2 = createBroker(2);


int brokerId2 =broker2.getId();

//Fourth step: Create one virtual machine for each broker/user


vmlist1 = newArrayList<Vm>();
vmlist2 = newArrayList<Vm>();

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

//create two VMs: the first one belongs to user1


Vm vm1 = new Vm(vmid, brokerId1, mips, pesNumber, ram, bw, size, vmm,
new CloudletSchedulerTimeShared());

//the second VM: this one belongs to user2


Vm vm2 = new Vm(vmid, brokerId2, mips, pesNumber, ram, bw, size, vmm,
newCloudletSchedulerTimeShared());

//add the VMs to the vmlists


vmlist1.add(vm1);
vmlist2.add(vm2);

//submit vm list to the broker


broker1.submitVmList(vmlist1);
broker2.submitVmList(vmlist2);

//Fifth step: Create two Cloudlets


cloudletList1 = new ArrayList<Cloudlet>();
cloudletList2 = new ArrayList<Cloudlet>();

//Cloudlet properties
int id = 0;
long length = 40000;
long fileSize = 300;
long outputSize = 300;
UtilizationModelutilizationModel = new UtilizationModelFull();

Cloudlet cloudlet1 = new Cloudlet(id, length, pesNumber, fileSize,outputSize,


utilizationModel, utilizationModel,utilizationModel);

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
cloudlet1.setUserId(brokerId1);

Cloudlet cloudlet2 = new Cloudlet(id, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet2.setUserId(brokerId2);

//add the cloudlets to the lists: each cloudlet belongs to one user
cloudletList1.add(cloudlet1);
cloudletList2.add(cloudlet2);

//submit cloudlet list to the brokers


broker1.submitCloudletList(cloudletList1);
broker2.submitCloudletList(cloudletList2);

// Sixth step: Starts the simulation


CloudSim.startSimulation();

// Final step: Print results when simulation is over


List<Cloudlet> newList1 = broker1.getCloudletReceivedList();
List<Cloudlet> newList2 = broker2.getCloudletReceivedList();

CloudSim.stopSimulation();

Log.print("=============>User"+brokerId1+" ");
printCloudletList(newList1);

Log.print("=============>User"+brokerId2+" ");
printCloudletList(newList2);

Log.printLine("CloudSimExample5 finished!");
}
catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}

private static Datacenter createDatacenter(String name){

// Here are the steps needed to create a PowerDatacenter:


// 1. We need to create a list to store
// ourmachine
List<Host>hostList = new ArrayList<Host>();

// 2. A Machine contains one or more PEs or CPUs/Cores.


// In this example, it will have only one core.
List<Pe>peList = new ArrayList<Pe>();

int mips=1000;

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
// 3. Create PEs and add these into a list.
peList.add(new Pe(0, new PeProvisionerSimple(mips))); // need to store Pe id and MIPS
Rating

//4. Create Host with its id and list of PEs and add them to the list of machines
int hostId=0;
int ram = 2048; //host memory (MB)
long storage = 1000000; //host storage
int bw = 10000;

//in this example, the VMAllocatonPolicy in use is SpaceShared. It means that only one
VM
//is allowed to run on each Pe. As each Host has only one Pe, only one VM can run on
each Host.
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerSpaceShared(peList)
)
); // This is our first machine

// 5. Create a DatacenterCharacteristics object that stores the


// properties of a data center: architecture, OS, listof
// Machines, allocation policy: time- or space-shared, timezone
// and its price (G$/Pe timeunit).
String arch = "x86"; // system architecture
String os = "Linux"; // operating system
String vmm = "Xen";
double time_zone= 10.0; // time zone this resourcelocated
double cost =3.0; // the cost of using processing in thisresource
double costPerMem= 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in thisresource
double costPerBw= 0.0; // the cost of using bw in this resource
LinkedList<Storage>storageList = new LinkedList<Storage>(); //we are not addingSAN
devices by now

DatacenterCharacteristics characteristics = new DatacenterCharacteristics(


arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage, costPerBw);

// 6. Finally, we need to create a PowerDatacenter object.


Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList), storageList,0);
DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page
Raj Kumar Goel Institute of Technology,
} catch (Exception e) {
e.printStackTrace();
}

return datacenter;
}

//We strongly encourage users to develop their own broker policies, to submit vms and cloudlets
according
//to the specific rules of the simulated scenario
private static DatacenterBrokercreateBroker(int id){

DatacenterBroker broker = null;


try {
broker = new DatacenterBroker("Broker"+id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}

/**
* Prints the Cloudletobjects
* @param list list ofCloudlets
*/
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;

String indent=" ";


Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent +
"Data center ID" + indent + "VM ID" + indent + "Time" + indent + "Start
Time" + indent + "Finish Time");

DecimalFormatdft = new DecimalFormat("###.##");


for (int i = 0; i< size; i++){
cloudlet =list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent + indent);

if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS){
Log.print("SUCCESS");

Log.printLine( indent + indent + cloudlet.getResourceId() + indent +


indent + indent + cloudlet.getVmId() +
indent + indent +
dft.format(cloudlet.getActualCPUTime()) + indent + indent +
dft.format(cloudlet.getExecStartTime())+

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
indent + indent + dft.format(cloudlet.getFinishTime()));
}
}

}
}

Experiment No 5:

Implement SJF algorithm in cloudlet scheduling in Cloudsim.

package
examples.org.
cloubus.
cloudsim.exa
mples;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
/**
* An example showing how to create
* scalable simulations.
*/
public class Simulation {
/** The cloudlet list. */
private static List<Cloudlet>cloudletList;
/** The vmlist. */

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
private static List<Vm>vmlist;
private static List<Vm>createVM(int userId, int vms) {
//Creates a container to store VMs. This list is passed to the
broker later
LinkedList<Vm> list = new LinkedList<Vm>();
//VM Parameters
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
int mips = 1000;
long bw = 1000;
int pesNumber = 1; //number of cpus
String vmm = "Xen"; //VMM name
//create VMs
Vm[] vm = new Vm[vms];

for(int i=0;i<vms;i++){
vm[i] = new Vm(i, userId, mips, pesNumber, ram,
bw, size, vmm, new CloudletSchedulerSpaceShared());
//for creating a VM with a space shared scheduling
policy for cloudlets:
//vm[i] = Vm(i, userId, mips, pesNumber, ram, bw,
size, vmm, new CloudletSchedulerSpaceShared());
list.add(vm[i]);
}
return list;
}
private static List<Cloudlet>createCloudlet(int userId, int
cloudlets){
// Creates a container to store Cloudlets
LinkedList<Cloudlet> list = new LinkedList<Cloudlet>();
//cloudlet parameters
long length = 1000;
long fileSize = 300;
long outputSize = 300;
int pesNumber = 1;
UtilizationModelutilizationModel = new
UtilizationModelFull();
Cloudlet[] cloudlet = new Cloudlet[cloudlets];
for(int i=0;i<cloudlets;i++){
Random r= new Random();
cloudlet[i] = new Cloudlet(i, length
+r.nextInt(2000), pesNumber, fileSize, outputSize, utilizationModel,
utilizationModel, utilizationModel);
// setting the owner of these Cloudlets
cloudlet[i].setUserId(userId);
list.add(cloudlet[i]);
}
} return list;
DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS,V SEM) Page35
Raj Kumar Goel Institute of Technology,
////////////////////////// STATIC METHODS ///////////////////////
/**
* Creates main() to run this example
*/
public static void main(String[] args) {
Log.printLine("Starting CloudSimExample6...");
try {
// First step: Initialize the CloudSim package. It
should be called
// before creating any entities.
int num_user = 3; // number of grid users
Calendar calendar = Calendar.getInstance();
booleantrace_flag = false; // mean trace events
// Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag);
// Second step: Create Datacenters
//Datacenters are the resource providers in
CloudSim. We need at list one of them to run a CloudSim simulation
Datacenter datacenter0 =
createDatacenter("Datacenter_0");
Datacenter datacenter1 =
createDatacenter("Datacenter_1");
//Third step: Create Broker
DatacenterBroker broker = createBroker();
int brokerId = broker.getId();
//Fourth step: Create VMs and Cloudlets and send
them to broker
vmlist = createVM(brokerId,10); //creating 20 vms
cloudletList = createCloudlet(brokerId,40); //
creating 40 cloudlets
broker.submitVmList(vmlist);
broker.submitCloudletList(cloudletList);
// Fifth step: Starts the simulation
CloudSim.startSimulation();
// Final step: Print results when simulation is over
List<Cloudlet>newList =
broker.getCloudletReceivedList();
CloudSim.stopSimulation();
printCloudletList(newList);
//Print the debt of each user to each datacenter
datacenter0.printDebts();
datacenter1.printDebts();
Log.printLine("CloudSimExample6 finished!");
}
catch (Exception e)
{
e.printStackTrace();
Log.printLine("The simulation has been terminated
due to an unexpected error");
DESI
GN AND S LAB (RCS-552) Manual (CS, VSEM) Page36
Raj Kumar Goel Institute of Technology,
}
}
private static Datacenter createDatacenter(String name){
// Here are the steps needed to create a PowerDatacenter:
// 1. We need to create a list to store one or more
// Machines
List<Host>hostList = new ArrayList<Host>();
// 2. A Machine contains one or more PEs or CPUs/Cores.
Therefore, should
// create a list to store these PEs beforecreating
// aMachine.
List<Pe> peList1 = new ArrayList<Pe>();
int mips = 1000;
// 3. Create PEs and add these into the list.
//for a quad-core machine, a list of 4 PEs is required:
peList1.add(new Pe(0, new PeProvisionerSimple(mips))); //
need to store Pe id and MIPS Rating
peList1.add(new Pe(1, new PeProvisionerSimple(mips)));
peList1.add(new Pe(2, new PeProvisionerSimple(mips)));
peList1.add(new Pe(3, new PeProvisionerSimple(mips)));
//Another list, for a dual-core machine
List<Pe> peList2 = new ArrayList<Pe>();
peList2.add(new Pe(0, new PeProvisionerSimple(mips)));
peList2.add(new Pe(1, new PeProvisionerSimple(mips)));
//4. Create Hosts with its id and list of PEs and add them to
the list of machines
int hostId=0;
int ram = 2048; //host memory (MB)
long storage = 1000000; //host storage
int bw = 10000;
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList1,
new VmSchedulerTimeShared(peList1)
)
); // This is our first machine
hostId++;
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList2,
DESIGN AND ANALYSIS OF ALGORITHMS LAB new VmSchedulerTimeShared(peList2)
(RCS-552) Manual (CS, V SEM)
Page 37
Raj Kumar Goel Institute of Technology,
)
); // Second machine
//To create a host with a space-shared allocation policy for
PEs to VMs:
//hostList.add(
// new Host(
// hostId,
// newCpuProvisionerSimple(peList1),
// newRamProvisionerSimple(ram),
// newBwProvisionerSimple(bw),
// storage,
// newVmSchedulerSpaceShared(peList1)
// )
// );
//To create a host with aoportunistic space-shared allocation
policy for PEs to VMs:
//hostList.add(
// new Host(
// hostId,
// newCpuProvisionerSimple(peList1),
// newRamProvisionerSimple(ram),
// newBwProvisionerSimple(bw),
// storage,
// new
VmSchedulerOportunisticSpaceShared(peList1)
// )
// );
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, listof
// Machines, allocation policy: time- or space-shared,time
zone
// and its price (G$/Pe timeunit).
String arch= "x86"; // systemarchitecture
String os="Linux"; // operatingsystem
String vmm = "Xen";
double time_zone= 10.0; // time zone thisresource
located
double cost =3.0; // the cost of using processingin
this resource
double costPerMem= 0.05; // the cost ofusing
memory in this resource
double costPerStorage= 0.1; // the cost of usingstorage
in this resource
double costPerBw= 0.1; // thecost
of using bw in this resource
LinkedList<Storage>storageList = new
LinkedList<Storage>(); //we are not adding SAN devices by now
DatacenterCharacteristics characteristics = new
DatacenterCharacteristics(
ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V SEM)
DESIGN Page
Raj Kumar Goel Institute of Technology,
arch, os, vmm, hostList, time_zone, cost, costPerMem,
costPerStorage, costPerBw);
// 6. Finally, we need to create a PowerDatacenter object.
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics,
new VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
//We strongly encourage users to develop their own broker policies,
to submit vms and cloudlets according
//to the specific rules of the simulated scenario
private static DatacenterBrokercreateBroker(){

DatacenterBroker broker = null;


try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}
/**
* Prints the Cloudlet objects
* @param list list of Cloudlets
*/
@SuppressWarnings("deprecation")
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;
String indent=" ";
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent
+
"Data center ID" + indent + "VM ID" +
indent + indent + "Time" + indent + "Start Time" + indent + "Finish Time"
+indent+"userid"+indent);
DecimalFormatdft = new DecimalFormat("###.##");
for (int i = 0; i< size; i++) {
cloudlet = list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent
+ indent);
if (cloudlet.getCloudletStatus() ==
Cloudlet.SUCCESS){
ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V SEM)
DESIGN Page
Raj Kumar Goel Institute of Technology,
Log.print("SUCCESS");
Log.printLine( indent + indent +
cloudlet.getResourceId() + indent + indent + indent + cloudlet.getVmId() +
indent + indent + indent +
dft.format(cloudlet.getActualCPUTime()) +
indent + indent +
dft.format(cloudlet.getExecStartTime())+ indent + indent + indent +
dft.format(cloudlet.getFinishTime())+indent +cloudlet.getUserId());

}
}
}
}

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
Experiment No 6:

Install CloudAnalyst and simulate various Datacentre, VM configuration.

CloudAnalyst

Cloud Analyst is a tool developed at the University of Melbourne whose goal is to support evaluation of
social networks tools according to geographic distribution of users and data centers. In this tool,
communities of users and data centers supporting the social networks are characterized and, based on their
location; parameters such as user experience while using the social network application and load on the
data center are obtained/logged

RUN cloudanalyst Simulator

1.DownloadCloudAnalyst

http://www.cloudbus.org/cloudsim/CloudAnalyst.zi

2. Extract Files from the Zip file which will give following folderstructure

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

CLOUDANALYST FOLDER STRUCTURE

If you want to Run from Command line then

RUN CLOUDANALYST FROM COMMANDLINE

1. Or click on run.batfile

2. Done!!!

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

RUN CLOUDANALYST FROM COMMAND LINE: DASHBOARD

1. Click on Show Region Boundaries:

RUN CLOUDANALYST FROM COMMAND LINE: DASHBOARD – REGIONS

Click on CONFIGURE Simulation

Here you can configure:

· Data Center Configuration


D ESIGN AND ANALYSIS OFALGORITHMS LAB (RCS-552) Manual (CS, V SEM) 3
Raj Kumar Goel Institute of Technology,
o Physical Hardware Details of Data center

CLOUDANALYST – PHYSICAL HARDWARE DETAILS OF DATA CENTER

You will get:

CLOUDANALYST – DATA CENTER CONFIGURATIONS

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

CLOUDANALYST – DATA CENTER CONFIGURATIONS DETAILS

CLOUDANALYST – DATA CENTER CONFIGURATIONS – COPY

· Advanced

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

CLOUDANALYST – ADVANCED CONFIGURATIONS

· User Base: models a group of users and generates traffic representing theusers.

· Application Deployment Configurations (Cloudlets)

o Service BrokerPolicy

CLOUDANALYST – SERVICE BROKER CONFIGURATIONS

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

CLOUDANALYST – MAIN CONFIGURATIONS

1. You can Save this Configuration as well in case you want to use it later. It is storedas
.sim file. XML data is generated and saved as Sim file.

CLOUDANALYST – SAVE CONFIGURATIONS

1. Saved configuration can be loaded anytime easily intoCloudAnalyst

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

CLOUDANALYST – LOAD CONFIGURATIONS

So you need to enter data each time you want to run simulation.

1. I have created 2 DC in different region, each with 20 physicalhost

CLOUDANALYST – CONFIGURATIONS – DATA CENTERS IN DIFFERENT REGIONS

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

CLOUDANALYST – CONFIGURATIONS – ROUND ROBIN LOAD BALANCING POLICY

6 User bases and each in different region; 25 VMs are allocated to fulfil requests from all user
bases from both the Data Center

CLOUDANALYST – CONFIGURATIONS – USER BASE AND REGIONS

1. Once your are done with Configuration; click onDone!!!

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,
CLOUDANALYST – CONFIGURATIONS – INTERNET CHARACTERISTICS

Click on

CLOUDANALYST – CONFIGURE INTERNET CHARACTERISTICS

1. RunSimulation

CLOUDANALYST – RUN SIMULATION

1. Simulation Results Window willOpen

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

CLOUDANALYST – SIMULATION RESULTS

Close it.

1. Main Window will give allstatistics

CLOUDANALYST – SIMULATION STATISTICS

1. If you will try to run Simulation again then it will giveError

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

CLOUDANALYST – SIMULATION ERROR

Click on Exit

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

Experiment no. 7
Case Study on AmazonEC2/Microsoft Azure

Therearemanycloudcomputingprovidersavailableinindustry.Fewcompaniesareleadinginthisislisted below.
 Amazon Elastic Compute Cloud(EC2)
 Microsoft Azure ServicesPlatform
 Google AppEngine
 Salesforce.com
 AkamaiEdgePlatform
 IBM Computing on Demand(CoD)
 RackspaceCloud
 Terremark
 NetSuite

I. UNDERSTANDINGAMAZON ELASTICCOMPUTECLOUD
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in
the cloud. It is designed to make web-scale computing easier for developers. Amazon EC2’s simple web
service interface allows you to obtain and configure capacity with minimal friction. It provides you with
complete control of your computing resources and lets you run on Amazon’s proven computing
environment. Amazon EC2 reduces the time required to obtain and boot new server instances to minutes,
allowing you to quickly scale capacity, both up and down, as your computing requirements change. Amazon
EC2 changes the economics of computing by allowing you to pay only for capacity that you actually use.
Amazon EC2 provides developers the tools to build failureresilientapplications and isolate themselves from
commonfailure scenarios.

Components of Amazon EC2:

The above Figure shows all components of Amazon ElasticCompute Cloud.

1) Elastic Compute Units:The Elastic Compute Unit (ECU) was introduced by Amazon EC2 as an
abstraction of computer resources.Amazon’s Definition of ECU notes “We use several benchmarks and
tests to manage the consistency and predictability of the performance of an EC2 Compute Unit.OneEC2
Compute Unit provides the equivalent CPU capacity of a 1.0-1.2 GHz 2007 Opteron or 2007Xeon
processor.

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


SEM)
Raj Kumar Goel Institute of Technology,

Amazon EC2 instances types are grouped into six families:


Standard
Micro
High-Memory
High CPU
Cluster Compute
Cluster GPU

3) EC2 StorageTypes

Elastic Block Storage (EBS): This is persistent, network-based storage called Elastic Block
Store(EBS), which can be attached to running instances or also used as a persistent boot
medium.
Instance Storage: This is local storage, which is non-persistent and data will be lost after an instance
terminates .

4) Elastic IPAddresses

Amazon's Elastic IP Address feature is similar to static IP address in traditional data centers, with one
key difference. A user can programmatically map an Elastic IP Address to any virtual machine instance
without a network administrator's help and without having to wait for DNS topropagate the new binding.
In this sense an Elastic IP Address belongs to the account and not to a virtual machineinstance. It exists
until it is explicitly removed. It remains associated with the account, even while it is associated with no
instance.

5) AmazonCloudWatch

Amazon CloudWatch is a web service that provides monitoring for AWS cloud resources and
applications, starting with Amazon EC2. It provides you with visibility into resource utilization,
operational performance, and overall demand patterns—including metrics such as CPU utilization, disk
reads and writes, and network traffic. You can get statistics, view graphs, and set alarms for your metric
data. To use Amazon CloudWatch, simply select the Amazon EC2 instances that you’d like to monitor.
You can also supply your own business or application metric data. Amazon CloudWatch will begin
aggregating and storing monitoring data that can be accessed using web service APIs or Command Line
Tools.
6) AutomatedScaling

Auto Scaling allows you to automatically scale your Amazon EC2 capacity up or down according to
conditionsyou define. With Auto Scaling, you can ensure that the number of Amazon EC2 instances you’re
using scales up seamlessly during demand spikes to maintain performance, and scales down automatically
during demand lulls tominimize costs.
Auto Scaling is particularly well suited for applications thatexperience hourly, daily, or weekly variability in
usage. Auto Scaling is enabled by Amazon CloudWatch and available at no additional charge beyond
Amazon CloudWatch fees .

II.DUESNIDGNERASNTDAANNDALINYGSISWOIFNDALOGWOSRIATZHUMRSELAWBin(RdCowS-

s55A2z)uMreanisuaMl(iCcrSo,sVofStE'sMap)plicationPpalagtefo5r4mforthe
Raj Kumar Goel Institute of Technology,

WindowsAzureto build a web application that runs and stores itsdata in Microsoft datacenters. You can
use Windows Azureonlyto store data, with the applications that use that datarunning on-premises (that is,
outside the public cloud). Youcanuse Windows Azure to help on-premises applicationsconnect with each
otherortomapbetweendifferentsetsofidentityinformationorinotherways.Becausetheplatformoffersa
widerangeofservices,allofthesethings—andmore—are possible.

A. COMPONENTS OF WINDOWS AZURE

To understand what Windows Azure offers, it's useful to group its services into distinct categories and you
need to know what its components do. Figure 4 shows one waytodo this

.
Components of Windows Azure
Cloud Applications

Windows Azure provides two types of roles:


Web roles: A web role is designed for code that talks directly with web browsers or other HTTP
clients i.e. it depends on IIS, Microsoft's webserver. For example, ASP.NET or PHP application.
Worker roles: A worker role is more general, designed to run a variety or different type of code.
For example, application that processes lots of data in parallel.
Each role instance is really just a virtual machine (VM) running a flavor of Windows Server and each
one executesin a Windows Azure datacenter.

Load Balancing on a Windows Azure application:


If the load increases, maybe you've acquired a largenumber of new users all at once.
If the load decreases, another request can shrink the number of instances. And because Windows
Azure charges you by the hour for each instance, you pay only for the capacity you need.

2) DataManagement

EveryWindowsAzureapplicationrunsinoneormoreVMs.EachVMhaslocalstorage,whichan application
isfreetouse.
Windows Azure provides five data management options:
SQL Azure
Tables
DEWSIiGnNdoAwNsDAAzuNrAeLBYloSbISsOStForaAgLeGSOerRvIiTceHMSLAB(RCS-552)Manual(CS,VSEM)Pag
Import / Export
Raj Kumar Goel Institute of Technology,

Azure File Service

3) Networking:
Azure runs today in many datacenters spread across the world. When you run an application or store
data, you canselect one or more of these datacenters to use. You can alsoconnect to these datacenters in
various ways using the services below.

Virtual Network
Traffic Manager
Express Route

4) Identity and Access Control:


Working with identity is part of most applications.
Knowing who a user is lets an application decide l Oracle Relational Database
Database for Azure in SQL
how it should interact with that user. Azure Support Server
provides services to help track identity as well as Virtualiz XEN Virtualization Hyper V – Hypervisor
integrate it with identity storesyou may already be ation Technology based virtualization
Technolo Technology
using. gy
Active Directory IDE SDK is available for SDK is available for
Multi Factor Authentication Support Eclipse Eclipse and visual
studio.

5) Messaging andIntegration

No matter what it's doing, code frequently needs to interact with other code. In some situations, all that's
needed is basic queued messaging. In other cases, more complex interactions are required. Azure provides a
few different ways to solve these problems. Figure 4 illustrates the choices.
Storage Queue
Service Bus Queue
Service Bus Relay
Service Bus Topics
Biz Talk Hybrid Connection
Biz Talk Service

III. COMPARISON BETWEEN MICROSOFTZAURE VS AMAZONEC2


As many companies have large amounts of information stored on computers, the need for memory is
essential. Cloud computing removes the need to install dedicated software to the computer, thereby
reducing the amount of memory needed. . Azure and EC2 conceptually do thesame thing. Both EC2 and
Microsoft Azure cloud computing technologies allow the expansion of the virtual machines or VMs used
for applications – both in number and power. Both services work on the basis of the Virtual Machine
model. Amazon EC2 and Azure areboth marketers of applications through independent software vendors
(ISV).

We will compare Microsoft Azure and Amazon EC2 withfew parameters.


1) General comparison of Amazon EC2 andMicrosoftAzure.
DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page
Raj Kumar Goel Institute of Technology,
General Comparison of EC2 and Azure

Feature Amazon EC2 Microsoft


Azure
Administration
 Access  FedRAMP
& Compliance
Management
Details  HIPAA
 Compliance Compliant
Monitoring
 ISO27001
 Detailed Certified

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

2) Pricecomparison

Feature Amazon Microsoft Azure


EC2
Base Plan $0.11/hour $0.02 / hour
Price
Virtual CPU 1 VCPU’s -
Core
RAM 3,840MB 768MB
Disk Space 4 GB 20 GB
Subscription  Hourl  Hourl
Option yRate yRate
 Monthly
/
Fixed
Rate
 Reserve
d
Instanc
es
 Spot
Instanc
es

Price Comparison
3) Administration andSupport

Feature Amazon EC2 Microsoft Azure


Types Amazon provides Microsoft
of all three types of Azur
Cloud cloud computing e provides all three
Comput ieSasS, PasS and types of cloud
i ng IasS, but major computing ieSasS,
Provide player in IaaS. PasS and IasS, but
d. major player in
PaaS.
Relation SQL, MySQL SQL Azure –
a and

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

 Java  Java

 PHP  Node

 Python  PHP

 Ruby  Python

 Ruby
Middleware  Tomcat ----
Frameworks  Django  Drupal

 Drupal  Symfony

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


 SSAE16
Audited
RajKum arGFacoileitly titute of Technology,
Ins
Support Services
 24/7  24/7
Available
 Forums  Forums

 Online/Self-  LiveChat
Serve
Resources  Phone

Administration and Support service comparison.

4) Specification

Feature Amazon EC2 Microsoft Azure


Server OS Types  Linux
 Linux
 Windows
 Windows
Preconfigured
 Amazon  CentOS
Operating Systems
Linux
 FreeBSD
 CentOS
 openSUSE
 Debian Linux

 Oracle  Oracle
Enterpris Enterprise
eLinux Linux

 Red Hat  SUSE


Enterpris Enterprise
eLinux Linux

 SUSE  Ubuntu
Enterpris
eLinux  Windows
Server
 Ubuntu

 Windows
Server
Available
 .NET  .NET
Runtimes

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

Specification Comparison
IV. CONCLUSION

ADVANTAGES OFAMAZONEC2

EC2 is cheaper, at least to start. One can get an EC2 Windows 2008 R2 Server instance up and
running for about $40 per month.
EC2 is familiar. The nice thing about EC2 is it’s like having your own Windows Server without
buying the hardware. I can do anything I want to it; I just have to remote desktop intoit.
EC2’s biggest strength: it’s conceptually simple. Anyone who’s ever used any VM software is
going to be able to grasp what it does immediately. There’s no learning curve, just instant
gratification

ADVANTAGES OF MICROSOFT WINDOWS AZURE

Azure may be cheaper than EC2 in the long run. Azure is a zero maintenance solution. You just
deploy your application and Microsoft takes care of the software, patches and backups. There’s a
cost to maintenance which has to be taken into account when using EC2 compared to Azure. The
problemisthatcostisabithardtocalculate.

Scalability with Windows Azure is seamless. There’s a good chance this application will grow to
have many users and consume a massive amount of data. If it does, adding additional machines
with Windows Azure is as simple as changing a value in the configurationfile.

It’s completely integrated with Visual Studio. Once set up, deploying changes from Visual Studio to
Windows Azure is just a coupleclicks.

Azure does more for you than EC2 does for the same price – management of the underlying OS and
application server are included in addition to management of thehardware.

Many start-up companies are interested in cloud computing but they are facing a real dilemma as they hear
different (positive and negative) views from different sources. This is understandable as this technology is in
its infant stage. Most of the startup companies, which are in the process of making a decision to adopt some
Cloud Computing technology, e.g. Microsoft Azure or Amazon EC2, find thisto be a difficult decision.

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page


Raj Kumar Goel Institute of Technology,

Experiment No. 8
Deploy application on commercial cloud(Google cloud platform)

Before you begin

 Create a Cloud project with an App Engineapp.


 Write a Node. js web server ready to deploy on AppEngine.
 Install Cloud SDK, which provides the gcloud command-line tool. Ensure gcloud is configured to use the
Google Cloud project you want to deployto.

Deploying the app to App Engine

To upload the guestbook app, run the following command from within the appengine-guestbook-python directory of
your application where the app.yaml and index.yaml files are located:

gcloud app deploy app.yamlindex.yaml

Optional flags:

 Include the --project flag to specify an alternate Cloud Console project ID to what you initialized as the default in
the gcloud tool. Example: --project[YOUR_PROJECT_ID]
 Include the -v flag to specify a version ID, otherwise one is generated for you. Example: -v[YOUR_VERSION_ID]

The Datastore indexesmight take some time to generate before your application is available. If the indexes are still in
the process of being generated, you will receive a NeedIndexError message when accessing your app. This is a
transient error, so try a little later if at first you receive this error.

To learn more about deploying your app from the command line, see Deploying a Python App.

Viewing your deployed application

To launch your browser and view the app at

https://PROJECT_ID.REGION_ID.r.appspot.com, run the following command:

gcloud app browse

DESIGN AND ANALYSIS OF ALGORITHMS LAB (RCS-552) Manual (CS, V Page

You might also like