1. 11
    1. 6

      Mechanical/electrical engineer here! Great idea and write up! What you describe is linear controller theory however there are some things to consider in real world applications:

      1. I-Overflow: When implementing the I-Part of the controller you should clamp the value. Otherwise it can happen that you controller overshoots, because your system isn‘t fast enough. Consider a helicopter rising to an altitude of 2000m. It can only rise with a certain velocity, which takes time. When at the top I-part of the controller is very large, because it summed up the error for the duration of the climb.
      2. Delays in system are really hard to deal with and delays cant be compensated with any controller, so its best to keep them as small as possible. In electrical systems this can be the cycle time of the microcontroller program. In general the delays should be 2 (Shannon) to 10 (optimal) times faster than the eigenfrequency of your system + controller. In your system the delay is spinning up a new worker.
      3. Cascading controllers might be overkill for this, but are a easy fix for hard to control systems.

      Then how do to judge the performance of your controller: There are two main ways. The step function response and the bode plot. Read up on them and learn to interpret them. If you see those you basically know everything about your system.

      About what the different parts of a controller do. The D-part does not look into the future. Nobody can. Instead it acts like a damper. If your system oscillate increasing this can help. Otherwise this part usually makes you system slow and can be avoided all together for system with natural damping. The proportional part is the most important part and many controllers only use this, but it can‘t reach the command variable on its own for most systems. (This might not be a goal of your controller system and therefore it a P-controller might be sufficient). Why is that? Picture the helicopter from before. If it reaches the target height the P- Part becomes 0 and the helicopter declines. After that the difference is non-zero and the helicopter rises again. If there is damping in your system the helicopter will level out somewhere below the target height where the controller output equals the hovering throttle position. To circumvent this you can use the I-Part. Which integrates the error until it is zero. However a I-heavy controller can lead to oscillations, which must not be bad unless there is a resonance. Generally there are two types of controller systems: PT1 and PT2. Unfortunately both Wikipedia entries are only available in German and I dont know the English terms. You might be able to use deepl. Usually PT1 is preferable of possible, but they are slower.

      1. 1

        Thanks for your thorough response, much appreciated!

        I tried to search for “PID controller integral clamping” and “PID controller I-overflow” but couldn’t find anything, are there better search terms I can use to find some more information about this?

        Regarding delays, am I understanding correctly that I should measure the time it takes to spin up a new worker and then make sure that the dt in the controller is 10x faster than that?

        Do you think cascading controllers would help make the system more robust to bursty traffic or sudden big increases of traffic? Or what do you mean with “hard to control systems”?

        1. 3

          Look for PID anti-windup.

          1. 1

            Yes, thats the correct term. Sorry, I wrote in a little bit of a hurry :)

        2. 1

          Since what you want to control is not a physical system the analogy might break down. It‘s about the eigenfrequency. The eigenfrequency of the controlled system should be ten times larger than the control or sensor frequency.

          The system itself has a eigenfrequency and the controlled system has a eigenfrequency. For example if you want to control the position of a mass on a spring by controlling the position of the anchorpoint a controller can change the system in a way that it becomes stiffer. The controlled system and another system with a stiffer spring can be indistinguishable.

          I dont what can be applied to your setup.

    2. 1

      I’m not knowledgeable on control theory, but my impression is that the application of a PID rather than an ad-hoc controller could be different depending on the subjective experience of being “inside” or “outside” of the system.

      By “inside” I mean in systems like altitude or temperature control, it would be important that the passengers or occupants are not shocked by sudden quick changes.

      Website traffic seems more like an “outside” experience where clients are randomly making independent requests and expecting a timely reply.

      My take is that a PID is more useful for the “inside” experience, where once a client is being served they should expect a consistent high QOS over some period of time. But an ad-hoc controller might be simpler or more effective if in the “outside” experience, the average client can expect a 0.01% of timeout for any request, but no stateful QOS is maintained for repeated requests.