Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Playing Games In The Clouds

Playing Games In The Clouds

What does haggling at a garage sale have to do with load balancing in distributed systems? How does bidding in an art auction relate to cloud service orchestration? Familiarity with the ideas and technologies involved in cloud computing is becoming ever more important for developers. This talk will demonstrate how you can use game theory — the study of strategic decision making — to design more efficient, and innovative, distributed systems.

A talk at RailsConf, GORUCO, and Brighton Ruby 2015.

Nadia Odunayo

April 22, 2015
Tweet

More Decks by Nadia Odunayo

Other Decks in Programming

Transcript

  1. PLAYING GAMES IN THE CLOUDS
    Nadia Odunayo
    @nodunayo

    View Slide

  2. View Slide

  3. View Slide

  4. What is the centre of an atom called?
    (5%)
    Nucleus

    View Slide

  5. Which tyre was it?
    (95%)

    View Slide

  6. –John von Neumann
    “Real life consists of bluffing, of little tactics of
    deception, of asking yourself what is the other man
    going to think I mean to do. And that is what games
    are about in my theory.”

    View Slide

  7. 1. Instructions
    2. GAME ONE : Bargaining
    3. GAME TWO : Auction
    4. ADAPTING the Rules
    5. Game over

    View Slide

  8. 1. Instructions
    2. GAME ONE : Bargaining
    3. GAME TWO : Auction
    4. ADAPTING the Rules
    5. Game over

    View Slide

  9. Game Theory is the study of strategic interactions
    between rational agents.

    View Slide

  10. JOHN NASH
    1928-2015

    View Slide

  11. WHAT IS A GAME?
    Split the
    money!
    Take the
    money and
    run!

    View Slide

  12. WHAT IS A GAME?

    View Slide

  13. Task distributor
    ?
    ?
    A

    B


    View Slide

  14. 1. Instructions
    2. GAME ONE : Bargaining
    3. GAME TWO : Auction
    4. ADAPTING the Rules
    5. Game over

    View Slide

  15. View Slide

  16. How will surplus be split between agents?
    Bargaining Theory asks:

    View Slide

  17. Gemma gets all
    of the sweets
    You get all of the
    sweets
    The bag of sweets is split in
    half between you and
    Gemma
    Gemma’s payoff
    Your payoff
    Payoff set
    0,0
    Nash bargaining solution point

    View Slide

  18. What has Distributed Systems got to do with it?
    You ask:

    View Slide

  19. We can use Bargaining Theory to think about how
    resources should be allocated within a distributed
    system.

    View Slide

  20. HOW CAN WE MODEL THIS?


    View Slide

  21. HOW CAN WE MODEL THIS?


    I can complete
    5 jobs every
    second!
    Oh! I can only
    complete 2.
    :-(

    View Slide

  22. HOW CAN WE MODEL THIS?


    I’ll take 1 job!
    Me too!

    View Slide

  23. HOW CAN WE MODEL THIS?


    I got 4 jobs!!
    WAT?!
    :-(
    Yay! Only 1 job
    to do!

    View Slide

  24. THE PROBLEM
    T = 4 jobs/sec
    5 jobs/sec

    A

    2 jobs/sec

    B


    View Slide

  25. Task distributor
    ?
    ?
    5 jobs/sec

    2 jobs/sec

    A

    B

    4 jobs/sec


    View Slide

  26. We want to distribute the jobs in such a way that
    optimally minimises overall execution time.

    View Slide

  27. Each computer has the following payoff (happiness)
    function:
    log(x - y)
    Computer’s job processing rate Rate of jobs arriving at computer
    THE PROBLEM

    View Slide

  28. THE PROBLEM
    Number of jobs per
    second
    Happiness

    View Slide

  29. The function we want to maximise is:
    THE PROBLEM
    yA+ yB = 4
    where
    log(5 - yA) + log(2 - yB)
    Computer A’s
    job processing
    rate
    Rate of jobs
    arriving at
    computer A
    Computer B’s
    job processing
    rate
    Rate of jobs
    arriving at
    computer B

    View Slide

  30. THE SOLUTION
    log(5 - yA) + log(2 - yB)
    Jobs to send to computer A
    Total happiness
    3.5

    View Slide

  31. Task distributor
    3.5 jobs /sec
    0.5 jobs/sec
    2 jobs/sec

    5 jobs/sec

    A

    B


    View Slide

  32. Computer B’s
    payoff
    Computer A’s
    payoff
    Payoff set
    0,0
    Nash Bargaining Solution point
    3.5 jobs to computer A,
    0.5 jobs to computer B
    Optimal response time = 1.33s
    yA = 3.8 jobs/sec
    yB = 0.2 jobs/sec
    Response time = 1.39s
    yA = 3.3 jobs/sec
    yB = 0.7 jobs/sec
    Response time = 1.36s
    THE SOLUTION

    View Slide

  33. A NASH BARGAINING SOLUTION
    Approaching load balancing with Game Theory
    leads us to Nash Bargaining solutions.
    We can use the results to develop algorithms that
    dynamically and efficiently distribute jobs.

    View Slide

  34. 1. Instructions
    2. GAME ONE : Bargaining
    3. GAME TWO : Auction
    4. ADAPTING the Rules
    5. Game over

    View Slide

  35. View Slide

  36. View Slide

  37. £25 £5 £10
    lucy wins and
    pays
    £10
    lucy mark helen

    View Slide

  38. how should an agent bid?
    Auction Theory asks:

    View Slide

  39. A strategy is dominant if that strategy gives the
    player their highest possible payoff regardless of
    what the other players do.

    View Slide

  40. It is the dominant strategy to bid truthfully in a second-price
    auction.
    $5 mark
    $25 lucy
    $10 Helen
    Payoff = true value - b2
    $15
    $0
    $0

    View Slide

  41. It is the dominant strategy for agents to bid truthfully in a second-
    price auction.
    $5 mark
    $25 lucy
    $10 Helen
    $0
    $-16
    $0
    $5 mark
    $25 lucy
    $26 Helen
    Payoff = true value - b2
    $15
    $0
    $0
    Payoff = true value - b2

    View Slide

  42. We can use Auction Theory to reveal the resource
    capabilities of machines within a distributed system.

    View Slide

  43. HOW CAN WE MODEL THIS?


    View Slide

  44. HOW CAN WE MODEL THIS?


    I have lots of
    memory, but I’m
    not telling
    anyone!
    I can’t remember
    a thing!
    :-(

    View Slide

  45. HOW CAN WE MODEL THIS?


    I’ve got like
    5GB of
    memory…
    I honestly have
    just 1GB…

    View Slide

  46. HOW CAN WE MODEL THIS?


    Why have I got
    to run all of the
    jobs?
    Yay! No work
    to do!

    View Slide

  47. THE PROBLEM
    bidA bidB
    15GB
    A

    10GB
    B

    View Slide

  48. Task distributor
    A

    B

    Auctioneer
    Computers,
    give me your
    bids!
    bidA
    bidB

    View Slide

  49. THE PROBLEM
    Let’s focus on the computer A’s payoff:
    15GB
    If a bid is not submitted, the payoff is 0.

    View Slide

  50. THE PROBLEM
    Let’s focus on the computer A’s payoff:
    15GB
    If bidA < bidB, the payoff is 0.

    View Slide

  51. THE PROBLEM
    Let’s focus on the computer A’s payoff:
    15GB
    If bidA > bidB, the payoff to computer A is 15 − bidB.

    View Slide

  52. THE SOLUTION
    It is the dominant strategy for the computers to truthfully report
    their capabilities.
    15GB
    bidA = 15

    View Slide

  53. THE SOLUTION
    7
    bidA = 15
    bidB = 8
    7
    bidA = 15
    Payoff = 0
    bidB = 17
    15
    bidA = 20
    -2
    bidB = 17
    15
    bidA = 20
    bidB = 8
    7
    Payoff
    15 − bidB.

    View Slide

  54. THE SOLUTION
    7
    bidA = 15
    Payoff = 0
    bidB = 17
    15
    bidA = 11
    bidB = 17
    Payoff = 0
    bidA = 15
    bidB = 8
    7
    15
    bidA = 6
    bidB = 8
    Payoff = 0
    Payoff
    15 − bidB.

    View Slide

  55. Task distributor
    A

    B

    Auctioneer
    Computers,
    give me your
    bids!
    15
    10

    View Slide

  56. OPTIMAL JOB PLACEMENT
    Auction frameworks enable us to develop
    algorithms that distribute jobs based on accurate
    representations of the resources available in a
    system.

    View Slide

  57. 1. Instructions
    2. GAME ONE : Bargaining
    3. GAME TWO : Auction
    4. ADAPTING the Rules
    5. Game over

    View Slide

  58. View Slide

  59. -0.7 jobs
    2.3 jobs
    5.3 jobs
    ALLOCATION ALGORITHM
    A

    8 jobs/sec

    B

    5 jobs/sec

    C

    2 jobs/sec

    T = 7 jobs/sec
    Source: Grosu - Load Balancing In Distributed Systems: A Game Theoretic Approach

    View Slide

  60. 0
    2 jobs
    5 jobs
    ALLOCATION ALGORITHM
    A

    8 jobs/sec

    B

    5 jobs/sec

    C

    2 jobs/sec

    T = 7 jobs/sec
    Source: Grosu - Load Balancing In Distributed Systems: A Game Theoretic Approach

    View Slide

  61. Source: Grosu - Load Balancing In Distributed Systems: A Game Theoretic Approach

    View Slide

  62. I want three
    application
    instances.
    App placement in cloud foundry
    I have loads of
    room!
    I guess I can
    run one app.
    Don’t talk
    to me. No space
    here.
    Computers,
    give me your
    bids!
    Auctioneer
    Source: Gupta - App Placement In Cloud Foundry Diego

    View Slide

  63. App placement in cloud foundry
    Bid components
    Constraints
    Source: Gupta - App Placement In Cloud Foundry Diego

    View Slide

  64. VICKREY–CLARKE–GROVES
    Profit = Payment - Cost
    Paid by the auctioneer to
    each machine after a round
    of bidding
    The more work the
    computer has to do, the
    greater the cost
    Source: Grosu - Load Balancing In Distributed Systems: A Game Theoretic Approach

    View Slide

  65. –Nassim Nicholas Taleb
    “Antifragility is beyond resilience or robustness. The
    resilient resists shocks and stays the same; the
    antifragile gets better.”

    View Slide

  66. 1. Instructions
    2. GAME ONE : Bargaining
    3. GAME TWO : Auction
    4. ADAPTING the Rules
    5. Game over

    View Slide

  67. RESULTS
    When we know the capabilities of the machines in a
    distributed system, we can use the Nash Bargaining
    Solution to determine how we should allocate
    resources.

    View Slide

  68. RESULTS
    When we don’t know the capabilities of the
    machines in a distributed system, we can use second-
    price auctions to reveal what the capabilities are.

    View Slide

  69. LEVELLING UP
    Game Theory can help you break down complex
    problems.
    Start basic and build in more realistic assumptions.

    View Slide

  70. A WARM UP

    View Slide

  71. OTHER GAMES
    Clustering
    Cloud security
    PaaS Landscape
    Non-cooperative
    Evolutionary
    Coalition

    View Slide

  72. SOURCES
    LOAD BALANCING IN DISTRIBUTED SYSTEMS: A GAME THEORETIC APPROACH
    Daniel Grosu
    http://www.cs.utsa.edu/uploads/theses/DGrosu.pdf
    APP PLACEMENT IN CLOUD FOUNDRY DIEGO: A CLASSICAL OPTIMIZATION PROBLEM
    Amit Gupta
    http://blog.pivotal.io/cloud-foundry-pivotal/products/app-placement-in-cloud-foundry-diego-a-classical-optimization-problem
    NETWORKS, CROWDS, AND MARKETS: REASONING ABOUT A HIGHLY CONNECTED WORLD
    David Easly & Jon Kleinberg
    http://www.cs.cornell.edu/home/kleinber/networks-book/
    AUCTIONS AND BIDDING: A GUIDE FOR COMPUTER SCIENTISTS
    Simon Parsons, Juan A. Rodriguez-Aguilar, and Mark Klein
    https://cgi.csc.liv.ac.uk/~sp/publications/journals/acs.pdf

    View Slide

  73. THANK YOU!
    Nadia Odunayo
    www.nadiaodunayo.com
    @nodunayo
    WOULD YOU LIKE TO PLAY AGAIN?

    View Slide