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

DevOpsDays Minneapolis 2016: Autoscaling Containers... with Math

DevOpsDays Minneapolis 2016: Autoscaling Containers... with Math

Presented at DevOpsDays Minneapolis. http://www.devopsdays.org/events/2016-minneapolis/program/allan-espinosa/

Also shows how to write your own Autoscaler in Kubernetes

Docker and Kubernetes provide delightful APIs to show various statuses of our applications. Whether CPU, Load average, HTTP response times, etc., we have all that we need to make sure our app is running healthily. When things are on fire, we Ops people twiddle some knobs like spin up more Pods to keep things going. We mostly use our experience and knowledge of the systems that we are running to know what to do.

However, if you look at everyday things like your air conditioner and thermostat, they don't have an Ops team that gets paged to set the correct level of the coolant to set your room to the right temperature. They use some math called Control Theory to keep your room's temperature stable. In this talk, I will show how we can use the same concepts to autoscale and manage the health of our applications on Kubernetes.

Allan Espinosa

July 21, 2016
Tweet

More Decks by Allan Espinosa

Other Decks in Science

Transcript

  1. Autoscaling Containers…with Math
    @AllanEspinosa

    View full-size slide

  2. @AllanEspinosa

    View full-size slide

  3. @AllanEspinosa
    Your Distributed System
    Goal OPS Person Twiddle Server Farm CPU Utilization
    Monitoring
    Page
    Traffic

    View full-size slide

  4. @AllanEspinosa
    Your Aircon
    Set Temperature
    Thermostat
    Valve
    Coolant
    Actual Temperature
    Sensor
    The Weather

    View full-size slide

  5. @AllanEspinosa
    Autoscaling
    Target HPA Number of Pods RC Utilization
    Heapster
    Utilization
    Traffic
    http://kubernetes.io/docs/user-guide/horizontal-pod-autoscaling/

    View full-size slide

  6. @AllanEspinosa
    Control Theory
    • influencing dynamical systems
    • corrections based on feedback loops
    • math describes effectiveness

    View full-size slide

  7. @AllanEspinosa
    R. Routledge, Discoveries & Inventions of the Nineteenth Century, 13th edition, 1901.

    View full-size slide

  8. @AllanEspinosa

    View full-size slide

  9. @AllanEspinosa
    Control Theory
    • Target Output
    • Input
    • Output
    • Disturbance
    () + ()
    ()
    ()
    () ()

    ()

    View full-size slide

  10. @AllanEspinosa

    View full-size slide

  11. @AllanEspinosa

    View full-size slide

  12. @AllanEspinosa
    Linear-Time Invariant Systems



    () + () = ()
    ( + 1) = () + ()

    View full-size slide

  13. @AllanEspinosa
    Desired Properties
    • Stability
    • Accuracy
    • Settling time
    • Overshoot

    View full-size slide

  14. @AllanEspinosa
    Stability

    View full-size slide

  15. @AllanEspinosa

    View full-size slide

  16. @AllanEspinosa

    View full-size slide

  17. @AllanEspinosa

    View full-size slide

  18. @AllanEspinosa

    View full-size slide

  19. @AllanEspinosa
    Accuracy

    View full-size slide

  20. @AllanEspinosa
    Settling time

    View full-size slide

  21. @AllanEspinosa
    Overshoot

    View full-size slide

  22. @AllanEspinosa
    Controllers
    () + ()
    ()
    ()
    () ()

    () = () − ()
    () =


    u=−∞
    ( − )()

    View full-size slide

  23. @AllanEspinosa
    Proportional Control
    u
    () = u
    ()
    ()
    u
    ()

    View full-size slide

  24. @AllanEspinosa
    Proportional Control
    • inherently inaccurate
    • u
    increases overshoot and settling time

    View full-size slide

  25. @AllanEspinosa
    Integral Control
    u
    () = u
    ( − 1) + u
    ()
    • reduce steady-state error
    • increase settling times

    View full-size slide

  26. @AllanEspinosa
    Derivative Control
    u
    () = u
    [() − ( − 1)]
    • decrease settling times
    • sensitive to noise

    View full-size slide

  27. @AllanEspinosa
    Non-linearity
    40 50 60 70 80 90 100
    0.5 0.7 0.9 1.1
    Number of Replicas
    CPU Utilization

    View full-size slide

  28. @AllanEspinosa
    Summary
    • iterate on feedback
    • effectiveness of feedback
    • linear models go a long way
    • re-evaluate your models!

    View full-size slide

  29. @AllanEspinosa
    P. Janert, Feedback Control for Computer Systems, Sebastapol, CA: O’Reilly Media, 2014.
    J. Hellerstein, et. al., Feedback Control of Computing Systems, Hoboken, NJ: John Wiley & Sons,
    2004.

    View full-size slide

  30. @AllanEspinosa
    Thank You!
    @AllanEspinosa
    https://github.com/aespinosa/control-theory

    View full-size slide