0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 00:47:50 +01:00
posthog/bin/start-worker
Karl-Aksel Puulmann bbd41ef04a
Use -Ofair for celery workers (#5063)
From https://medium.com/@taylorhughes/three-quick-tips-from-two-years-with-celery-c05ff9d7f9eb

> By default, preforking Celery workers distribute tasks to their worker processes as soon as they are received, regardless of whether the process is currently busy with other tasks.
> If you have a set of tasks that take varying amounts of time to complete — either deliberately or due to unpredictable network conditions, etc. — this will cause unexpected delays in total execution time for tasks in the queue.

This is 100% the case for us. This should "load balance" the tasks
better across workers.
2021-07-12 13:52:05 +03:00

12 lines
325 B
Bash
Executable File

#!/bin/bash
set -e
# this kills all processes when the last one terminates
trap 'kill $(jobs -p)' EXIT
# start celery worker with heartbeat (-B)
celery -A posthog worker -B --scheduler redbeat.RedBeatScheduler --without-heartbeat --without-gossip --without-mingle -Ofair &
# start celery plugin worker
./bin/plugin-server