In the cloud-computing era, many technologies like Puppet, chef, ansible, etc arose to take care of setting up, maintaining and provisioning virtual machine clusters. However these tools do not prove to be practical for cases where the user wants to test a deployment or try a small experiment involving many VMs in the cloud. Additionally they lack interactiveness and the user is unable to hijack or influence the deployment process during runtime. Python iCE is a tool that aims to enable interactive cloud experimentation. It can deploy VM clusters in EC2-compatible public clouds and allow the user to manage them through SSH. It formalises an experiment as a Python script with fabric tasks which can run on every or selected VMs in a cluster. It also integrates with IPython and it has its own shell that allows for interactive handling of the VMs. iCE is built with well-established Python libraries like IPython, boto and fabric.
iCE comes with a lightweight agent that registers a VM to an experiment’s pool. This agent will run automatically for VMs deployed with iCE but users can manually run it on already running VMs to utilise them through iCE. Its IPython shell facilitates the development and execution of experiments. Its main goal is to bring the ease of use and interactiveness of single-machine SSH sessions to virtual clusters.
1. NATIONAL AND KAPODISTRIAN UNIVESITY OF ATHENS
DEPARTMENT OF INFORMATICS AND TELECOMMUNICATIONS
iCE
Interactive cloud experimentation
in Python
George Lestaris
@glestaris
PyCon UK
20 September 2015
Coventry
Slides URL
http://bit.ly/iCE-PyConUK
2. /me
• University of Athens, Greece
• iCE is part of my Bachelor thesis
• Software engineer in Pivotal, London
• Cloud Foundry Container technology
• ex-CERNois
2iCE: Interactive cloud experimentation in Python
3. The original problem (1/2)
• Most applications deployed in public cloud (AWS)
use multiple VMs
• these VMs run services
• that communicate with each other
• in different rates
3iCE: Interactive cloud experimentation in Python
4. The original problem (2/2)
4iCE: Interactive cloud experimentation in Python
• So network performance (intra-cluster
communication) within the same availability zone is
very interesting and important
Web
Web
DB
Load balancer
DB
Web
Don’t really care
High bandwidthLow latency
5. Questions
• How do we measure intra-cluster network
performance?
• How consistent it is through time?
• Can we make predictions on the network
performance? - classification
• But remember requirements change all the time
5iCE: Interactive cloud experimentation in Python
6. The clique experiment (1/2)
6iCE: Interactive cloud experimentation in Python
• Run a number of VMs that send packets to each other
• Spawn n nodes in the same availability zone and same security
group and subnetwork
• Run transfers between each pair
• Measure speed and monitor consistency of the
results
• Is classification of VM-pairs into classes of “network
distance” possible?
7. The clique experiment (2/2)
7
In the mathematical area of
graph theory, a clique is
subset of vertices of an
undirected graph, such that
its induced
subgraph is complete;
that is, every two
distinct vertices in the
clique are adjacent.
Definition by Wikipedia
"VR complex" by David Eppstein - Own work.
Licensed under Public Domain via Commons
iCE: Interactive cloud experimentation in Python
8. Here classification seems easy
8iCE: Interactive cloud experimentation in Python
Slow
class
Fast
class
9. Back to the example
9iCE: Interactive cloud experimentation in Python
D
C
B
F
A
E
Fast class
Slow class
10. Gauss, is that you?
10iCE: Interactive cloud experimentation in Python
11. Gauss, is that you?
11iCE: Interactive cloud experimentation in Python
• I need to run this experiment many times
• On different times of the day, different days of the week
• The results should be analysed and plotted
• If there is a classifier it needs to be fed with results
• The resulting model needs validation against any new results
• Automation, automation, automation
12. There will be iCE
12
because you shouldn’t run
experiments by hand
http://github.com/glestaris/iCE
13. iCE
• A tool that enables interactive experimentation.
• Experiment: a Python script file with:
• tasks: run remotely in each VM of the experiment
• runners: orchestrates tasks
• Interactive Shell
• AWS integration
13iCE: Interactive cloud experimentation in Python
14. Components
• Registry: VMs (instances) that participate in an
experiment are registered under experimentation
sessions
• Shell: facilitates spawning EC2 VMs and running
experiments
• AWS integration: create and delete EC2 VMs that will
register themselves to iCE
• Experiments: loads and runs experiments in remote
instances
14iCE: Interactive cloud experimentation in Python
15. • Registry: VMs (instances) that participate in an
experiment are registered under experimentation
sessions
• Shell: facilitates spawning EC2 VMs and running
experiments
• AWS integration: create and delete EC2 VMs that will
register themselves to iCE
• Experiments: loads and runs experiments in remote
instances
15iCE: Interactive cloud experimentation in Python
Half of it, for free
eve (Flask / Werkzeug) & requests
Fabric
boto
IPython
18. Creating VMs
18iCE: Interactive cloud experimentation in Python
$> ice-shell
[DEBUG] Session id = 55fd40c4d8476f00211e12ae
* ********************************************************************
* Welcome to iCE version v2.0.0!
* You may leave this shell by typing `exit` or pressing Ctrl+D
* Type `h <Command>` to get usage information for a given command,
* or `h` for looking into a brief description of all commands.
* ********************************************************************
$> ec2_create -n 5 -t t2.micro
[DEBUG] Reservation r-149d56ed for 5 instances was created
+-----------------+---------------+-----------------+-------------+----------+
| Id | AMI Id | Instance type | Public IP | Status |
+-----------------+---------------+-----------------+-------------+----------+
| Reservation: r-149d56ed |
+-----------------+---------------+-----------------+-------------+----------+
| i-6989d3c4 | ami-6e7bd919 | t2.micro | None | pending |
|[...] |
+-----------------+---------------+-----------------+-------------+----------+
Experimentation
session
19. Waiting for VMs to come up
and register
19iCE: Interactive cloud experimentation in Python
$> inst_wait -n 5
[DEBUG] 0 instances found, sleeping for 5 seconds...
[...]
[INFO] Instances are ready!
$> inst_ls
[INFO] Found 5 instances
+--------------------------+--------------+----------------------------------+
| Id | Public IP | Cloud Id |
+--------------------------+--------------+----------------------------------+
| 55fd45b2d8476f00211e12b5 | 54.77.34.67 | eu-west-1.compute.amazonaws.com |
| [...] |
+--------------------------+--------------+----------------------------------+
$> ec2_ls
[DEBUG] Reservation r-149d56ed for 5 instances was created
+-----------------+---------------+-----------------+-------------+----------+
| Id | AMI Id | Instance type | Public IP | Status |
+-----------------+---------------+-----------------+-------------+----------+
| Reservation: r-149d56ed |
+-----------------+---------------+-----------------+-------------+----------+
| i-298cd684 | ami-6e7bd919 | t2.micro | 54.76.34.228| running |
| [...] |
+-----------------+---------------+-----------------+-------------+----------+
20. A simple experiment (1/2)
20iCE: Interactive cloud experimentation in Python
import ice # iCE package
from fabric import api as fab # Fabric API
@ice.Runner
def run(hosts):
"""A sample iCE runner. It gets the hostnames of all instances and
prints them out.
:param dict hosts: Dictionary of ice.entities.Instances objects.
"""
# Get hostnames of all instances, through fab.execute
# First argument: Python function
# Second argument: List of hosts
# It returns a dictionary with the task result as value.
hostnames = fab.execute(get_hostname, hosts)
# Prints
for key in hostnames:
print hostnames[key]
21. 21
@ice.Task
def get_hostname(hosts):
"""A simple iCE task. It returns the FQDN hostname of the remote
instance.
:param dict hosts: Dictionary of ice.entities.Instances objects.
:rtype: str
:return: The FQDN hostname.
"""
# Get the FQDN hostname from each node
hostname = fab.run('hostname -f')
return hostname
A simple experiment (2/2)
iCE: Interactive cloud experimentation in Python
22. Loading and running an experiment
22iCE: Interactive cloud experimentation in Python
$> exp_load ./experiments/simple.py
[DEBUG] About to load module 'simple' from path '/Users/george/di_dev/Thesis/iCE/
experiments'
[INFO] Module `./experiments/simple.py` is successfully loaded!
$> exp_ls simple
> Module `simple`:
Runners:
* run: A sample iCE runner. It gets the hostnames of all instances and
prints them out. [...]
Tasks:
* get_hostname: A simple iCE task. It returns the FQDN hostname of the remote
instance. […]
$> exp_run simple
[ec2-user@ec2-54-77-17-214.eu-west-1.compute.amazonaws.com] run: hostname -f
[ec2-user@ec2-54-77-17-214.eu-west-1.compute.amazonaws.com] out: ip-172-31-6-35.eu-
west-1.compute.internal
[...]
ip-172-31-6-35.eu-west-1.compute.internal
ip-172-31-6-36.eu-west-1.compute.internal
[...]
23. Instead of a conclusion
• Start with a research problem that interests you, make
some basic assumptions
• Be lazy and automate things
• always be ready to rerun experiments and
reproduce results
• Use what is there
• Hope for the best and don’t be afraid to
hit the wall fast
23iCE: Interactive cloud experimentation in Python
Talk / iCE
feedback