A service that crashes at once and restarts at once will fill the journal, so I set the limits on purpose.
[Unit]
StartLimitIntervalSec=60
StartLimitBurst=5
[Service]
Restart=on-failure
RestartSec=5
Restart=on-failure restarts after a non-zero exit, a signal, a timeout or a watchdog expiry, but not after a clean stop. RestartSec=5 waits five seconds between attempts. With the default window of 10 seconds, five starts never fit inside it when the pause is five seconds, so the service would restart forever. A 60 second window fixes that: after more than five starts in 60 seconds systemd marks the unit failed and stops trying. The two StartLimit settings belong in [Unit], not [Service]. Clear the failed state with systemctl reset-failed myapp.service.
Further reading: systemd.unit manual page