If you have a (rough) model of the system e.g. a transfer function, you can invert the model to get some initial parameters, and then fine-tune by hand.
If you don't have a model but are able to run tests [0] to collect data, you can apply any number of heuristic methods to systematically perturb the system to collect data to aid in tuning. Then fine-tune by hand.
Difficult loops e.g. MIMO (multiple input multiple output) loops that are larger than 2x2 where there's interaction between the variables (i.e. you move one variable, others move as well) require more analysis with loop-pairing techniques like RGA (relative gain analysis).[3]
For really difficult loops (or loops that have degraded over time), you can use software like Loop Pro [2]. This only makes sense if you're controlling something valuable and where loop degradation could lead to safety or performance issues. You probably don't need software to tune the PID in your espresso maker.
--
[0] Some systems are "open-loop unstable", which means they can go haywire if you perturb too much in the wrong direction. Simply blindly perturbing these types of systems is inadvisable. Process understanding/analysis is needed to avoid unstable situations.
[1] https://sites.chemengr.ucsb.edu/~ceweb/faculty/seborg/teachi...
[2] https://controlstation.com/pid-tuning/
[3] For really large MIMO systems, PID is no longer the right control mechanism. Advanced control techniques like MPC are used, where a computer repeatedly solves an numerical optimization problem at some frequency to calculate the next control moves. MPC is usually used to control chemical plants with hundreds/thousands of control variables. PID is used in local loops, whereas MPC sits on top as an optimizing layer.
Edit: Also, I learned a lesson about closed-loop systems with the launch (well, EDL) of the Curiosity rover on MARS. It's mentioned in this article [1] but the trigger to start lowering the rover on the crane wasn't some process monitoring distance from the ground...it actually had no direct notion of that. It just watched the throttle setting on the retro-rockets and started unwinding the winch when the throttles reached a reduced steady state setting...something expected once the descent stage had reached its hover altitude.
[1] (search for throttle) - https://www.planetary.org/blogs/emily-lakdawalla/2012/070607...
Totally unrelated, but the first time I saw that technique with writing on the glass and then flipping the video L-R was about 4 years ago when F5 did a good video introduction on elliptic curve cryptography [0]
They (F5) even wrote up the technical details of their Lightboard [1]
[0] https://youtu.be/dCvB-mhkT0w
[1] https://devcentral.f5.com/s/articles/lightboard-lessons-behi...
I had the same idea (ie PID loop to control system behaviour) some time ago to control traffic to external system so that it is just at the limit of throughput of that external system. The external system is really badly implemented and we had to put much effort into maximizing throughput.
In the end we are replacing HTTP requests with Kafka topics which let's the other system process as fast as possible without destabilizing. On our end we continuously monitor latency and have flow control based on consumer behaviour.