Restart=on-failure with a fixed RestartSec= retries at the same pace forever. When a database is down for an hour, that is a lot of pointless attempts and log lines.
Since systemd 254 you can let the delay grow:
[Service]
Restart=on-failure
RestartSec=2
RestartSteps=5
RestartMaxDelaySec=5min
The first restart waits 2 seconds. With each further restart the delay grows, reaching 5 minutes after five steps, and stays there. For a unit whose ExecStart=/bin/false fails right away, systemctl show flaky -p RestartUSecNext already reports almost 4 seconds for the next wait after two restarts.
To see where a service is in its back off:
systemctl show myapp -p NRestarts -p RestartUSecNext
I find this nicer than hitting the start limit, because the service keeps trying and comes back on its own once the thing it depends on returns.
Mind the start rate limit. With short delays, StartLimitBurst= may still trip first and leave the unit failed. Raise StartLimitIntervalSec= or set it to 0 if you rely on the back off. And on older systems like Ubuntu 22.04 the settings are unknown, so systemd logs a warning and ignores them.
Further reading: systemd.service man page