Control Theory In Container Orchestration Vallery Lancey Lead - - PowerPoint PPT Presentation

control theory in container orchestration
SMART_READER_LITE
LIVE PREVIEW

Control Theory In Container Orchestration Vallery Lancey Lead - - PowerPoint PPT Presentation

Control Theory In Container Orchestration Vallery Lancey Lead DevOps Engineer, Checkfront Container Orchestration Fundamentals @vllry Goals of Container Management Reproducibility. Cohabitation. Auto-management of instances.


slide-1
SLIDE 1

Control Theory In Container Orchestration

Vallery Lancey Lead DevOps Engineer, Checkfront

slide-2
SLIDE 2

@vllry

Container Orchestration Fundamentals

slide-3
SLIDE 3

@vllry

Goals of Container Management

  • Reproducibility.
  • Cohabitation.
  • Auto-management of instances.
slide-4
SLIDE 4

@vllry

System Management

Traditional: a sysadmin examines the system, makes a judgement, and performs an action. Automatic: the system tracks its own state, and translates the state to some internal action.

slide-5
SLIDE 5

@vllry

Key Auto-Management Features

  • Allocate appropriate resources.
  • Manage network based on container health & state.
  • Reap unhealthy containers.
  • Maintain container headcount.
  • Auto-scale container groups.
slide-6
SLIDE 6

@vllry

Control Theory

slide-7
SLIDE 7

@vllry

What is Control Theory?

  • Engineering topic: how to manage a system using human and

internal controls.

  • Used heavily in...

○ Physical device design ○ Plant/factory management ○ Electrical engineering

slide-8
SLIDE 8

@vllry

A Controller

  • Inputs dictate what the controller should do (setpoint).
  • Outputs dictate what the controlled process should do.
slide-9
SLIDE 9

@vllry

Open Loop Controllers

  • A controller with only inputs and outputs is an open loop

controller.

  • Can’t respond to feedback from the controlled process.
slide-10
SLIDE 10

@vllry

Closed Loop Controller

  • Contains feedback from the process to the controller.
  • The controller is able to self-correct to achieve the desired
  • utcome.
slide-11
SLIDE 11

@vllry

slide-12
SLIDE 12

@vllry

The Math is Unfortunate

  • Control theory is split into linear (PV changes linearly with

control) and nonlinear problems.

  • Most of our problems are nonlinear.
  • Nonlinear problems have fewer known methods, and are often

reduced to simplified linear problems.

slide-13
SLIDE 13

@vllry

Applying Control Theory To Containers

slide-14
SLIDE 14

@vllry

while True { currentState = getCurrentState() desiredState = getDesiredState() makeConform(currentState, desiredState) }

Process Variable S e t p

  • i

n t

slide-15
SLIDE 15

@vllry

Container Lifecycle: Readiness Probe

  • When a container is launched, we don’t want to serve it traffic

before it’s ready.

  • A readiness probe uses some “OK” response (EG HTTP 200) to

decide when.

  • What do we need to build this?

○ Container lifecycle status ○ Probe destination ○ Probe behaviour config

slide-16
SLIDE 16

@vllry

slide-17
SLIDE 17

@vllry

slide-18
SLIDE 18

@vllry

slide-19
SLIDE 19

@vllry

slide-20
SLIDE 20

@vllry

slide-21
SLIDE 21

@vllry

Replica Headcount

  • How do we ensure the right number of container copies exist?
  • Need to maintain the desired replica count (input).
  • Need to check the current number of containers (feedback).
  • Need to create or terminate containers accordingly (output).
slide-22
SLIDE 22

@vllry

Replication Controller

slide-23
SLIDE 23

@vllry

slide-24
SLIDE 24

@vllry

Autoscaling

slide-25
SLIDE 25

@vllry

Autoscaling Deployments

  • Need to track a specified metric (CPU use, network I/O, etc).
  • Need to increase or decrease replicas if the metric is

sufficiently above or below the target.

  • Should respond quickly and without overcompensating.
slide-26
SLIDE 26

@vllry

Bang-Bang Controller

  • Controller with upper and lower bounds, where the set point is

never exactly met.

  • Process is turned on when one extreme is hit, and turns off

when the other is hit.

slide-27
SLIDE 27

@vllry

slide-28
SLIDE 28

@vllry

slide-29
SLIDE 29

@vllry

Challenges in Designing a Controller

  • Accepting a “close enough” error, rather than thrashing.
  • Responding quickly without overcompensating.

○ Predict the right replica setpoint. ○ Account for the delay in SP->PV propagation.

slide-30
SLIDE 30

@vllry

Delayed Response

slide-31
SLIDE 31

@vllry

Bootup Time

  • Containers take time to boot (surprise!)

○ Resource allocation. ○ Image pull & app startup.

slide-32
SLIDE 32

@vllry

slide-33
SLIDE 33

@vllry

slide-34
SLIDE 34

@vllry

Accounting for the Delay

  • Must guess if no context.

○ Can wait out the grace period, or... ○ Can define some % of the grace period to overscale after.

  • Custom controllers can allow context.

○ Can have a statistical explanation of boot time. ○ Can use a custom readiness probe that shows progress (whitebox).

slide-35
SLIDE 35

@vllry

Matching Demand

slide-36
SLIDE 36

@vllry

Scale Ramp-Up

  • Scaling up quickly is especially important.
  • Typical controller approaches:

○ Immediately add enough replicas to satisfy load/replicas for current load. ○ Keep scaling up each loop, until satisfied.

  • Can we keep scaling both fast and precise?
slide-37
SLIDE 37

@vllry

slide-38
SLIDE 38

@vllry

slide-39
SLIDE 39

@vllry

PID: Proportional

The proportional component is a linear response to the magnitude

  • f the error.
slide-40
SLIDE 40

@vllry

PID: Integral

The integral component is a compensator. It responds to the magnitude and duration of the error.

slide-41
SLIDE 41

@vllry

PID: Derivative

The derivative component is a predictor of the future error, based

  • n the trend of the current error.
slide-42
SLIDE 42

@vllry

PID Controllers

  • Use the proportional, integral, and derivative components to

react, compensate, and predict for required output.

  • Each component is tuned using a constant.
slide-43
SLIDE 43

@vllry

Autoscaling With a PID Controller

  • Proportional and integral components drive scaling.
  • Integral and derivative components increase scale speed, at the

cost of overcompensating.

  • Derivative is “less accurate” but can help in sharp raises/drops.
slide-44
SLIDE 44

@vllry

Autoscaling in Kubernetes

  • Kubernetes uses a proportional controller (with a lot of checks

and balances.

  • Prioritizes gradual resolution over unstable resolution.
  • Scaling (Horizontal Pod Autoscaler) updates Deployment spec -

doesn’t touch pods itself.

slide-45
SLIDE 45

@vllry

In Summary

  • Ensure any controller has the necessary feedback to properly

achieve its outcome.

  • Strictly define expectations of any controller.
  • Build discrete, transparent, and testable controllers.
  • Ensure shared state has a single source (CP).
  • Custom controllers are common based on app behaviour and

expectations.

slide-46
SLIDE 46

@vllry

Oh Yeah, Hi!

  • I’m a software/systems person

at Checkfront (online bookings)

  • I work with Kubernetes & “cloud

stuff”.

slide-47
SLIDE 47

@vllry

Thank You!

Brian Liles & coordinators & staff Joe Beda Tim St. Clair

slide-48
SLIDE 48

@vllry

Audience Questions

@vllry