Feedback Control For programmers and other strangers
description
Transcript of Feedback Control For programmers and other strangers
Feedback ControlFor programmers
and other strangers
Philipp K. JanertPrincipal Value, LLC
Feedback Control
•What is feedback control?
•Why should I care?
Definition
Feedback Control:
An automated method
to choose a system’s configuration parameters
in order to achieve a desired behavior
in the presence of uncertainty and change.
Examples
Example 1: Cache
Configuration Variable (Input):
Size (Max number of items)
Monitored Metric (Output):
Hit rate (Success Rate)
Examples
Example 2: Sever Farm
Configuration Variable (Input):
Number of Instances Online
Monitored Metric (Output):
Average Response Time
Examples
Example 3: Waiting Queue
Configuration Variable (Input):
Number of Consumer Instances
Monitored Metric (Output):
Average Holding Time (or: Queue Length)
Examples
Example 4: Workflow
Configuration Variable (Input):
Release Rate or Flow Rate (Number of items released per period)
Monitored Metric (Output):
Length of Downstream Queue (Number of items pending)
Examples
Example 5: Graphics Engine
Configuration Variable (Input):
Graphics Resolution (Pixels per Game Object)
Monitored Metric (Output):
Memory Consumption
In Common…
Cache SizeServer Instances
Queue ConsumersFlow Rate
Graphics Resolution
Hit RateResponse TimeWaiting TimeQueue LengthMemory Consumption
1. System transforming Input to Output2. Desired Outcome3. Uncertainty4. Change
Feedforward
1.Figure it out (Algorithmic-Deterministic)
2.Trial and Error (Heuristic)
3.Change on Demand (Firedrill…)
Difficulty: How to control in the face of uncertainty and change?
Schedule
System
Feedback
Poor-Man’s Solution:
1. Pick some value
2. Check the output
3. Apply a correction
4. Repeat!
Trial and Error: It’s no longer a bug, now it’s a feature!
Feedback Loop Architecture
r : Reference Value (“Setpoint”)
e : Tracking Error
u : Input (Configuration Parameter)
y : Output (Tracked Metric)
Controller Plant u r ye = r - y
Feedback Loop Architecture - Cache
What does the Controller Do?
•Apply a correction in the correct direction…
•… and of approximately the right size.
Controller Cache SizeSetpoint Hit Rate Error
Feedback Loop Architecture - Cache
Challenge:
Correction must be approximately the right size
•Too large: instability and oscillation
•Too small: slow and insufficient response
Controller Cache (1000)Sizer = 0.8 Hit Rate y = 0.7 e = r - y
Review, Part 1
What is Feedback and Why should I care?
An automated method
to choose a system’s configuration parameters
in order to achieve a desired behavior
in the presence of uncertainty and change.
Review, Part 2
How does feedback work?
Feedback works by repeatedly comparing the output to the setpoint,
and applying a corrective action in the correct direction.
What are the challenges?
Corrections must be approximately the right size:
•Small enough to avoid instability and oscillation
•Large enough to provide sufficiently quick response and compensation
Controller Implementation
Feedback controllers can be simple,
because of the self-correcting nature of the loop architecture.
(Feedforward controllers tend to be complex, by contrast.)
Controller Plant InputSetpoint Output Error
Controller Implementation
Typical Choice: Cumulative Error (“Integral Control”)
cumul += error
action = gain * cumul
Controller Plant InputSetpoint Output Error
Controller ImplementationIntegral Controller
Controller gain k = 1000
Time Step Setpoint r
Error e = r –y Cumulative c Size k*c Hit Rate y
0 0.8 0 0
1 0.8 0.8 0.8 800 0.6
2 0.8 0.2 1.0 1000 0.7
3 0.8 0.1 1.1 1100 0.8
4 0.8 0.0 1.1 1100 0.8
n 0.8 1.2 1200 0.9
n+1 0.8 -0.1 1.1 1100 0.8
Controller Implementation
PI Controller (Proportional-Integral Controller)
cumul += error
action = kp * error + ki * cumul
With two gain parameters: kp and ki (proportional and integral)
95% of all installed controllers are PI Controllers!
Controller Tuning
How does one find values for the gain parameters?
•Theoretical Description (if available)
•Inspection
•Experiments and Formulas (Heuristics)
Why is this better than finding the system parameters directly?
•Controller gains need only be known approximately.
•Feedback architecture gives robustness to change.
Results - Cache
Results - Cache
Results - Cache
Summary
Feedback Control is an automated method
to choose a system’s configuration parameters
in order to achieve a desired behavior
in the presence of uncertainty and change.
Feedback works by repeatedly comparing the output to the setpoint,
and applying a corrective action in the correct direction.
Summary
Stable systems rely on feedback everywhere…• Electrical Engineering• Aeronautics• Process Control• Biological Processes• Economy• Relationships• …
… isn’t it time we programmers give it a try?
Philipp K. JanertPrincipal Value, LLC