Improve Horizon Support
Opened this issue · 3 comments
Background
I've been working with @nckrtl on optimizing Horizon support
Related Discord Discussion
https://discord.com/channels/910287105714954251/1235899514867683430
@nckrtl: I just added some ToDos for myself above. Any other ideas that need to be added to this list, let me know.
Next week I will be partially out of the office, but I will start diving into this when I return the week after 👍
Looks complete to me. Still need to verify assumptions as discussed on Discord. Will give it this weekend a try.
Alright, I did a test and can confirm everything is working as expected with setting the horizon docker service order to start-first
in docker-compose, but there are a few more requirements which need to be set properly in the Laravel project:
-
In the horizon config file
horizon.php
you must set thetimeout
key of your queue config to an higher amount than your job may run. So if your job may run 5 minutes (300 seconds) thetimeout
should be at least set to301
-
In queue.php the
retry_after
key on your redis connection should be set higher than the timeout amount you set in your horizon config. Else your job will get retried too soon and it will get interrupted before it finished. So setting it to302
should be sufficient but i'd recommend adding some margin (same goes for thetimeout
btw. -
In docker-compose the
stop_grace_period
should be set to an high enough amount, with 5 minute jobs 300 seconds should be sufficient but it wouldn't hurt to set this to 1 hour.
Because of the start-first a new container will start upon a new deployment while the old one will stay active and finish until horizon terminates gracefully. Made a video to demo it all. Might take a bit before the quality is bumped enough by YT for it to be watchable.