280 likes | 447 Views
Feedback Control For programmers and other strangers. Philipp K. Janert Principal 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
E N D
Feedback ControlFor programmersand other strangers • Philipp K. Janert • Principal Value, LLC
Feedback Control • Whatis feedback control? • Why should I care?
Definition Feedback Control: An automatedmethod 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 Size • Server Instances • Queue Consumers • Flow Rate • Graphics Resolution Hit Rate Response Time Waiting Time Queue Length Memory Consumption • System transforming Input to Output • Desired Outcome • Uncertainty • Change
Feedforward • Figure it out (Algorithmic-Deterministic) • Trial and Error (Heuristic) • Change on Demand (Firedrill…) Difficulty: How to control in the face of uncertainty and change? Schedule System
Feedback Poor-Man’s Solution: • Pick some value • Check the output • Apply a correction • 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) r e = r - y u y Controller Plant
Feedback Loop Architecture - Cache What does the Controller Do? • Apply a correction in the correct direction… • … and of approximately the right size. Setpoint Error Size Hit Rate Controller Cache
Feedback Loop Architecture - Cache Challenge: Correction must be approximately the right size • Too large: instability and oscillation • Too small: slow and insufficient response r = 0.8 e = r - y Size Hit Rate y = 0.7 Controller Cache (1000)
Review, Part 1 What is Feedback and Why should I care? An automatedmethod 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.) Setpoint Error Input Output Controller Plant
Controller Implementation Typical Choice: Cumulative Error (“Integral Control”) cumul += error action = gain * cumul Setpoint Error Input Output Controller Plant
Controller Implementation Integral Controller Controller gain k = 1000
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.
Summary Feedback Control is an automatedmethod 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. Janert Principal Value, LLC janert@principal-value.com