This is a book about feedback controlnot a topic that programmers (among others) tend to know much about. This is a pity, because feedback control was originally devised to solve a problem that should be all too familiar to software engineers, especially those who are working on enterprise systems. Feedback control is a way to make sure that large, complicated systems run reliably, even when subject to external disturbances, and to make efficient use of constrained resources.
If you are looking for a system that can spin up some additional servers when traffic in your data center spikes and take them down again when the rush is over, then you have come to the right place.
What Is Feedback?
Feedback works by constantly comparing the actual behavior of a system to its desired behavior. If the actual behavior differs from the desired one, a corrective action is applied to counteract the deviation and drive the system back to its target. This process is repeated constantly, as long as the system is running.
One appealing feature of feedback control is that it requires relatively little knowledge about the controlled system. As long as one knows which direction to nudge the system when it has gotten off course, one can build a feedback loop. For this reason, feedback is an attractive technique for controlling large, complex, and opaque systems.
Moreover, feedback systems are self-correcting even in the presence of external disturbances. Because the systems behavior is monitored and adjusted all the time, a feedback system naturally and automatically responds to changes in operating conditions. No need to make special provisions to activate additional servers for rush hour: the feedback controller will notice the increase in load and spin up further instances until the desired quality of service is met. It will also take the instances down again, once the rush has passed, in proportion to the lightening load.
One needs to be careful, though, since control actions that are either too large or improperly timed can overcorrect a disturbance. Instead of reducing the difference between the desired and the actual behavior, such control actions replace a deviation in one direction with another deviation in the opposite direction. In the worst case, the amplitude of these deviations grows with each step until the system becomes dysfunctional or, often literally, blows up!
To avoid this outcome, control theory has developed specific experiments for analyzing a systems behavior. The results from these experiments can then be used to design and tune control loops that are safe to operate and that will track a reference value accurately and reliably.
Why This Book?
Feedback control has a long and successful history in applications to electronic circuits, industrial processes, and vehicular engineering. But it can do more. Feedback is self-correcting, so it can keep a system on target even if conditions change unpredictably. Feedback requires only limited knowledge about the process to be controlled; hence it can be applied to situations involving complex and opaque systems, such as those typical of enterprise environments.
In this book we will study the application of feedback principles to several software engineering problems, such as the optimal sizing of a cache, the management of a server farm, the control of waiting queues or buffers, and more. In all these examples, feedback will help us to make efficient use of scarce or expensive resources and to do so in the face of changing conditions.
But applying feedback principles to computer systems raises different questions than one typically encounters in the traditional application areas. The laws describing the behavior of computer systems are much less constrained than those for systems in the physical world; so we will rely more on experimental measurements and phenomenological descriptions than on theoretical analysis. (This is similar to the situation one finds in the application of feedback methods to industrial processes.) At the same time, computer systems offer a greater variety of control signals than most physical assemblies do; we therefore have greater freedom in choosing the best signal to use and hence must be aware of the trade-offs involved. We will pay particular attention to such questions.
Feedback control has been barely explored as a design paradigm for software systems. I hope to convince you that feedback control has much to offer in this regard and is, in fact, the correct solution to many problems that software engineers commonly face.
How to Read This Book
It can be difficult for an outsider to learn about feedback. Textbooks and articles use specialized terminology and examples from existing application areas, which sometimes obscures the underlying concepts. The problems that arise in the classical application areas are not necessarily the same problems that are of greatest interest to programmers. One also needs to be aware that many textbooks on feedback control are primarily concerned with the mathematical manipulations that underlie control theory and so give less attention to conceptual development or practical implementation questions.
This book takes a different approach. Theoretical development, important and beautiful as it may be, has been relegated to consists of a collection of case studies: specific problems involving computer systems that are solved using feedback methods. For each case study, a number of different approaches and their trade-offs are discussed in some detail.
The case studies are the heart of the book. I suggest beginning with the introductory (Theory) as the need for additional information arises. (The sequence of case studies is arranged roughly in order of increasing complexity.)
All case studies are realized as computer simulations, and the code is available from the books website. The code is intentionally simple and straightforward so that it can be easily extended and modified. Experimenting with simulations is an excellent way to build intuition for the sometimes surprising behavior of closed-loop systemsand to build the necessary confidence that this feedback stuff really works !
Conventions Used in This Book
The following typographical conventions are used in thisbook:
ItalicIndicates new terms, URLs, email addresses, filenames, andfile extensions.
Constant width
Used for program listings, as well as within paragraphs torefer to program elements such as variable or function names,databases, data types, environment variables, statements, andkeywords.
Constant width bold
Shows commands or other text that should be typed literally bythe user.
Constant width italic
Shows text that should be replaced with user-supplied valuesor by values determined by context.
Tip
This icon signifies a tip, suggestion, or general note.
Caution
This icon indicates a warning or caution.
Using Code Examples
This book is here to help you get your job done. In general, if thisbook includes code examples, you may use the code in your programs anddocumentation. You do not need to contact us for permission unless yourereproducing a significant portion of the code. For example, writing aprogram that uses several chunks of code from this book does not requirepermission. Selling or distributing a CD-ROM of examples from OReillybooks does require permission. Answering a question by citing this bookand quoting example code does not require permission. Incorporating asignificant amount of example code from this book into your productsdocumentation does require permission.