Feedback Control a Computer Systemʼs Perspective

 Introduction  Applying input to cause system variables to conform to desired values called  What is feedback control? the reference.

 Why do computer systems need feedback control?  Cruise-control car: f_engine(t)=?  speed=60 mph  Control design methodology  E-commerce server: Resource allocation?  T_response=5 sec  System modeling  Embedded networks: Flow rate?  Delay = 1 sec  Performance specs/metrics  Computer systems: QoS guarantees  Controller design  Summary

Feedback (close-loop) Control Open-loop control

 Compute control input without continuous variable measurement Controlled System  Simple Controller  Need to know EVERYTHING ACCURATELY to work right  Cruise-control car: friction(t), ramp_angle(t) control control manipulated  E-commerce server: Workload (request arrival rate? resource input Actuator consumption?); system (service time? failures?) function variable  Open-loop control fails when

 We donʼt know everything error sample controlled  We make errors in estimation/modeling + Monitor  Things change - variable

reference

Why feedback control? Open, unpredictable environments Feedback (close-loop) Control

 Measure variables and use it to compute control input

 More complicated (so we need control theory)  Deeply embedded networks: interaction with physical environments  Continuously measure & correct  Number of working nodes  Cruise-control car: measure speed & change engine force  Number of interesting events  Ecommerce server: measure response time & admission control  Number of hops  Embedded network: measure collision & change backoff window  Connectivity  Feedback control theory makes it possible to control well even if  Available bandwidth  We donʼt know everything  Congested area  We make errors in estimation/modeling   Things change Internet: E-business, on-line stock broker  Unpredictable off-the-shelf hardware

1 Why feedback control? Advantage of feedback control theory We want QoS guarantees

 Deeply embedded networks  Adaptive resource management heuristics

 Update intruder position every 30 sec  Laborious design/tuning/testing iterations  Report fire <= 1 min  Not enough confidence in face of untested workload  E-business server  Queuing theory

 Purchase completion time <= 5 sec  Doesnʼt handle feedbacks  Throughput >= 1000 transaction/sec  Not good at characterizing transient behavior in overload  The problem: provide QoS guarantees in open, unpredictable  Feedback control theory

environments  Systematic theoretical approach for analysis and design  Predict system response and stability to input

Outline Control design methodology

 Introduction  What is feedback control?  Why do todayʼs computer systems need feedback control? Controller  Control design methodology Modeling Design  System modeling analytical Dynamic model Root-Locus Control algorithm  Performance specs/metrics system IDs  Controller design PI Control  Summary Satisfy

Requirement Performance Specifications Analysis

System Models Dynamic Model

 Computer systems are dynamic  Linear vs. non-linear (differential eqns) Linear vs. non-linear (differential eqns)  Current output depends on “history”  Deterministic vs. Stochastic  Characterize relationships among system variables • Differential equations (time domain)  Time-invariant vs. Time-varying

 Are coefficients functions of time? •• • • a2 y(t) + a1 y(t) + a0 y(t) = b1 u(t) + b0u(t)  Continuous-time vs. Discrete-time • Transfer functions (frequency domain)  System ID vs. First Principle Y(s) = G(s)U(s)

b1s + b0 c1 c2 G(s) = 2 = + a2s + a1s + a0 s ! p1 s ! p2 • Block diagram (pictorial)

R(s) C(s) G(s) Y(s) -

2 Example Utilization control in a video server Model Differential equation

 Periodic task Ti corresponding to each video stream i • Error: E(t)=Us-U(t)  c[i]: processing time, p[i]: period t  Stream iʼs requested CPU utilization: u[i]=c[i]/p[i] U (t) (R ( ) R ( ))d  Total CPU utilization: U(t)=Σ{k}u[k], {k} is the set of active streams • Model (differential equation): = ! a # " c # # # =0  Completion rate: Rc(t)= (Σ{kc}u[m])/Δt, where {m} is the set of terminated video streams during [t, t+Δt] • Controller C? E(t) ⇒ Ra(t)  Unknown

 Admission rate: Ra(t)= (Σ{ka}u[j])/Δt, where {j} is the set of admitted streams during [t, t+Δt] Ra(t)  U Problem: design an admission controller to guarantee U(t)=Us regardless of Rc(t) - s C? U(t) CPU

Rc(t)

A Diversion to Math A Diversion to Math System representations

 Three ways of system modeling  Laplace transform of a signal f(t)

• Time domain: ; differential equations. " t F(s) = L[ f (t)] = f (t)e#st dt u(t) g(t) y(t) y(t) = g(t)*u(t) = g(t "# )u(# )d# ! ! 0# 0 • s (frequency) domain: multiplication where s=σ+iω is a complex variable. U(s) G(s) Y(s) Y (s) = G(s)U (s) • Laplace transform is a translation from time-domain to s-domain • Block diagram: pictorial • Differential equation ⇒ Polynomial function •• • • a2 y(t) + a1 y(t) + a0 y(t) = b1 u(t) + b0u(t)

s-domain is a simple & powerful “language” for control analysis b1s + b0 ! Y (s) = 2 •U (s) a2s + a1s + a0

A Diversion to Math A Diversion to Math Laplace transform Transfer function

 Basic translations  Modeling a linear time-invariant (LTI) system  Impulse function f(t)=δ(t) ⇔ F(s)=1  G(s) = Y(s)/U(s) ⇒ Y(s) = G(s)U(s)  Step signal f(t)=a•1(t) ⇔ F(s)=1/s  Ramp signal f(t)=a•t ⇔ F(s)=a/s2  Exp signal f(t)=eat ⇔ F(s)=1/(s-a)  Sinusoid signal f(t)=sin(at) ⇔ F(s)=a/(s2+a2)  Composition rules

 Linearity L[af(t)+bg(t)] = aL[f(t)]+bL[g(t)] U(s) G(s) Y(s)  Differentiation L[df(t)/dt] = sF(s) – f(0-)  Integration L[∫tf(τ)dτ] = F(s)/s

E.g., a second order system with poles p1 and p2

b1s + b0 c1 c2 G(s) = 2 = + a2s + a1s + a0 s ! p1 s ! p2

3 A Diversion to Math A Diversion to Math Poles and Zeros Time response vs. pole location  The response of a linear time-invariant (LTI) system Stable Unstable

m m"1 bms + bm"1s +...+ b0 F(s) = n n"1 ans + an"1s +...+ a0 m $i=1(s " zi ) C1 C2 Cn = K n = + +...+ $i=1(s " pi ) s " p1 s " p2 s " pn n pit # f (t) = !Cie i=1

pt {pi} are poles of the function and decide the system behavior •f’(t) = e , p = a+bj

A Diversion to Math Back to Block diagram Our utilization control example

 A pictorial tool to represent a system based on transfer functions and signal • Error: E(t)=U -U(t) flows s t  Represent a feedback control system • Model (differential equation): U (t) = !(Ra (# ) " Rc (# ))d# # =0

• Controller C? E(t) ⇒ Ra(t) R(s) C(s) G (s) Y(s) - o R (t) U a - s C(s)G (s) C? G o c = U(t) R(s) Gc(s) Y(s) 1+ C(s)Go (s) CPU Y (s) = Gc (s)R(s)

Rc(t)

Model Control design methodology Transfer func. & block diag.

• CPU is modeled as an integrator t Ra (s) " Ra (s) 1 U (t) = #(Ra ($ ) " Rc ($ ))d$ !U (s) = ! Go (s) = Controller $ =0 s s  Inputs: reference Us(s) = Us/s; completion rate Rc(s) Modeling Design  Close-loop system transfer functions analytical Dynamic model Root-Locus Control algorithm  U (s) as input: G (s) = C(s)G (s)/(1+C(s)G (s)) s 1 o o system IDs PI Control  Rc(s) as input: G2(s) = Go(s)/(1+C(s)Go(s))  Output: U(s)=G1(s)Us/s+G2(s)Rc(s) Satisfy

Requirement Performance Specifications Rc(s) Analysis

Ra(s) C(s) Go Us/s U(s)

4 Design Goals Performance Specs: bounded input,bounded output stability Performance Specifications

 Stability  BIBO stability: bounded input results in bounded output.  A LTI system is BIBO stable if all poles of its transfer function are in the LHP ( p ,  Transient response ∀ i Re[pi]<0).  Steady-state error  Robustness  Disturbance rejection  Sensitivity m &i=1(s % zi ) C1 C2 Cn Y (s) = G(s)U (s) = K n = + +...+ &i=1(s % pi ) s % p1 s % p2 s % pn n pit $ y(t) = 'Cie i=1

pit t#! Note: Cie """#! if Re[ pi ] > 0

Performance Specs Performance specifications Stability

Controlled variable Overshoot Stable Unstable Steady state error±ε% Reference

Transient State Steady State

Time Settling time

Example: Control & Response in an Email Server (IBM) Performance Specs Steady-state error

Response  (queue length) Steady state (tracking) error of a stable system

ess = lime(t) = lim(r(t) ! y(t)) Good t t Control Bad #" #" (MaxUsers) r(t) is the reference input, y(t) is the system output. • How accurately can a system achieve the desired state? • Final value theorem: if all poles of sF(s) are in the open left-half of the s-plane, then lim f (t) = lim sF(s) t!" s!0 Slow Useless • Easy to evaluate system long term behavior without solving it

ess = lime(t) = lim sE(s) t!" s!0

5 Performance Specs Performance Specs Robustness Steady-state error

 Disturbance rejection: steady-state error caused by external Steady state error of a CPU-utilization control system disturbances  Can a system track the reference input despite of external disturbances? U(t)  Denial-of-service attacks  Sensitivity: relative change in steady-state output divided by the relative change of a system parameter Us ess=-20%  Can a system track the reference input despite of variations in the system?  Increased task execution times  Device failures

Performance Specs Control design methodology Goal of Feedback Control

 Guarantee stability

 Improve transient response  Short settling time Controller  Small overshoot Modeling  Small steady state error Design Dynamic model Control algorithm  Improve robustness wrt uncertainties analytical Root-Locus system IDs  Disturbance rejection PID Control  Low sensitivity Satisfy

Requirement Performance Specifications Analysis

Controller Design Controller Design PID control CPU Utilization Control

 Proportional-Integral-Derivative (PID) Control • CPU is modeled as an integrator t R (s) " R (s) 1 x(t) = Ke(t) ! C(s) = K U (t) = (R ($ ) " R ($ ))d$ !U (s) = a a ! G (s) = • Proportional Control # a c s o s t $ =0 KK  Inputs: set-point Us(s) = Us/s ; task completion Rc(s) x(t) KK e( )d C(s) i • Integral control = i " # # ! =  Close-loop system transfer functions 0 s  • Us(s) as input: G1(s) = C(s)Go(s)/(1+C(s)Go(s))  R (s) as input: G (s) = G (s)/(1+C(s)G (s)) • Derivative control x(t) = KKd e(t) ! C(s) = KKd s c 2 o o  C(s)=? to achieve zero steady-state error: U(t) → Us • Classical controllers with well-studied properties and tuning rules

Rc(s)

E(s) X(s) Ra(s) C(s) Go R(s) C(s) G (s) Y(s) Us/s U(s) - o

6 Proportional Control Proportional Control Stability Steady-state error

 Proportional Controller  Assume completion rate Rc(t) keeps constant for a time period longer than the settling time: Rc(s)=Rc/s  ra(t)=Ke(t); C(s) = K  Transfer functions  System response is

 Us/s as input: G1(s) = K/(s+K)  Rc(s) as input: G2(s) = 1/(s+K) U G (s) R G (s) KU ! R U (s) = s 1 + c 2 = s c  Stability s s s(s + K)  Pole p0 = -K<0 ⇔ System is BIBO stable iff K>0  Note: System may shoot to 100% if K<0! • Compute steady-state err using final value theorem,

KU s ! Rc Rc Rc limU (t) = lim sU (s) = lim = U s ! " ess = ! < 0 t#$ s#0 s#0 s + K K K

Rc(s) • P-control cannot achieve the desired CPU utilization Us; instead it will end up lower by Rc/K Oops! Ra(s) C(s) Go Us/s U(s) • The larger the proportional gain K is, the closer will CPU utilization approach to Us

CPU Utilization Proportional-Integral Control Proportional Control Stability

 Proportional Controller

 ra(t)=K(e(t)+Ki•∫te(τ)dτ) C(s) = K(1+Ki/s) U(t)  Transfer functions 2  Us/s as input: G1(s) = (Ks+KKi)/(s +Ks+KKi) Us 2  Rc(s) as input: G2(s) = s/(s +Ks+KKi) ess=-20%  Stability

 Poles Re[p0]<0, Re[p0]<0 ⇔ System is BIBO stable iff K>0 & Ki>0

Rc(s)

Ra(s) C(s) Go Us/s U(s)

Proportional Control CPU Utilization Steady-state error Proportional-Integral Control

 Assume completion rate Rc(t) keeps constant for a time period longer than the settling time: Rc(s)=Rc/s U(t)  System response is Mp= Us 0 e =0 U sG1(s) RcG2 (s) (KU s + Rc )s + KKiU s ss U (s) = + = 2 s s s(s + Ks + KKi ) • Compute steady-state err using final value theorem,

(KU s + Rc )s + KKiU s limU (t) = lim sU (s) = lim 2 = U s ! ess = 0 t"# s"0 s"0 s + Ks + KKi

• PI control can accurately achieve the desired CPU utilization Us √ • Control analysis gives design guidance ts tr tp

7 Controller Design Discrete Control Summary & pointers

 PID control: simple, works well in many systems  More useful for computer systems  P control: may have non-zero steady-state error  Time is discrete; sampled system  I control: improves steady-state tracking  denoted k instead of t  D control: may improve stability & transient response  Main tool is z-transform  Linear continuous time control  Root-locus design  Frequency-response design  f(k) → F(z) , where z is complex  State-space design  Analogous to Laplace transform for s-domain  G. F. Franklin et. al., Feedback control of dynamic systems

" Z[ f (k)] = F(z) = ! f (k)z #k k =0

Discrete Modeling Root Locus analysis of Discrete Systems

 Difference equation  Stability boundary: ||z|=1|=1 (Unit circle)

 V(m) = a1V(m-1) + a2V(m-2) + b1U(m-1) + b2U(m-2)  Settling time = distance from Origin -1 -2 -1 -2  z domain: V(z) = a1z V(z) + a2z V(z) + b1z U(z) + b2z U(z)  2 Speed = location relative to Im axis  Transfer function G(z) = (b1z + b2)/(z -a1z - a2)  V(m): output in mth sampling window  Right half = slower  U(m): input in mth sampling window  Left half = faster  Order n: #sampling-periods in history affects current performance  SP = 30 sec, and n = 2  Current system performance depends on previous 60 sec

Effect of discrete poles Feedback control works in CS

Im(s)  U.Mass: network flow controllers (TCP/IP – RED)  IBM: Lotus Notes admission control Higher-frequency  UIUC: Distributed visual tracking response  UVA Longer settling time  Web Caching QoS  Apache Web Server QoS differentiation  Active queue management in networks  Processor thermal control  Online data migration in network storage (with HP) Stable Re(s)  Real-time embedded networking  Control middleware Unstable |z|=1  Feedback control real-time scheduling

Intuition : z = eTs

8 Advanced Control Topics Issues for Computer Science

 Robust Control  Most systems are non-linear  Can the system tolerate noise?  But linear approximations may do  Adaptive Control  eg, fluid approximations  Controller changes over time (adapts)  First-principles modeling is difficult  MIMO Control

 Multiple inputs and/or outputs  Use empirical techniques  Stochastic Control  Mapping control objectives to feedback control loops  Controller minimizes variance  ControlWare paper  Optimal Control  Deeply embedded networking  Controller minimizes a cost function of error and control energy  Nonlinear systems  Massively decentralized control problem  Neuro-fuzzy control  Modelling  Challenging to derive analytic results  Node failures

9