Coder Social home page Coder Social logo

vm-placement's Introduction

vm-placement

A script that uses genetic algorithms to determine the best placement of VMs on a series of hypervisors based on affinity rules. Disclaimer: this script is experimental and provided as-is.

Installation

Simply run:

$ pip install -r requirements.txt

Usage

To use the script, you first need to login to you OpenStack instance. You will need the rigths to list all instances from all projects:

$ source admin-openrc.sh

See the OpenStack documentation on how to create an openrc.sh file.

Then run the script:

$ ./vm-placement.py

This will produce a map of all VMs and their hypervisors. To also get the I/O diagnostics, run:

$ ./vm-placement.py --diagnostics

Before you can use the script to place the VMs on the hypervisors in an optimal fashion, you need to edit the file vm-placement.yaml to discribe affinities. There are two sorts of affinities:

  • VMs that must be placed on the same hypervisor;
  • VMs that must be placed on different hypervisors.

The setup below is used to organise the VMs in the Climate Data Store.

---
affinity:
  mars.*:
    never_with: mars.*

  .*prod.*:
    never_with: mars.*

  cdsprod-compute-.*:
    never_with: cdsprod-compute-.*

  (\w+)-compute-(\w+)-.*:
    always_with: (\w+)-download-(\w+)-.*

  (\w+)-download-(\w+)-.*:
    always_with: (\w+)-compute-(\w+)-.*

  (\w+)-brokerdb-.*:
    never_with: (\w+)-brokerdb-.*
  • VMs whose names start with mars should never be placed on the hypervisors with other VMs also starting with mars.
  • VMs that contain prod in their names must not be placed on the same hypervisors as the ones whose name starts with mars.
  • VMs with -compute- in their names should be placed on the same hypervisors as the ones with -download- in their names, assuming the parts captured by the parentheses are the same. cdsprod-compute-0001-af98 will match cdsprod-download-0001-34ba.

Then run:

$ ./vm-placement.py --placement

This will run a genetic algorithm to find the best placement based on the list of affinity provided. In addition, the algorithm will try to spread out the VMs on all the hypervisors so that the CPU usage is uniform across all the system.

The scripts supports several options, the most important ones are --generations and --population that controls the number of generation and the size of the population used by the genetic algorithm. The larger these numbers, the more likely the best solution is found.

The script will create a file called moves.sh in the current directory. This file contains a series of calls to the openstack command line tool that will move the VMs to their optimal location.

$ bash ./moves.sh

Options

For more options, use:

$ ./vm-placement.py --help

License

Apache License 2.0 In applying this licence, ECMWF does not waive the privileges and immunities granted to it by virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.

References

Ahmed Fawzy Gad. PyGAD: An Intuitive Genetic Algorithm Python Library (2021).
https://doi.org/10.48550/arXiv.2106.06158

vm-placement's People

Contributors

b8raoult avatar

Stargazers

Niranjan Anandkumar avatar

Watchers

Florian Pinault avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.