mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-25 02:49:32 +01:00
3813795d22
* chore(gunicorn): increase thread count for workers We currently run with 2 worker processes each with 4 threads. It seems occasionally we see spikes in the number of pending requests within a worker in the 20-25 region. I suspect this is due to 4 slow requests blocking the thread pool. I'd suggest that the majority of work is going to be IO bound, thus it's hopefully going to not peg the CPU. If it does then it should end up triggering the HPA and hopefully resolve itself :fingerscrossed: There is however gzip running on events, which could be intensive (suggest we offload this to a downstream at some point). If lots of large requests come in this could be an issue. Some profiling here wouldn't go amiss. Note these are the same settings between web and event ingestion workload. At some point we may want to split. I've added a Dashboard for gunicorn worker stats [here](https://github.com/PostHog/charts-clickhouse/pull/559) which we can monitor to see the effects. Aside: if would be wise to be able to specify these settings from the chart itself such that we do not have to consider chart/posthog version combos, and allow tweaking according to the deployment. * reduce to 8 threads
26 lines
718 B
Bash
Executable File
26 lines
718 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
./bin/migrate-check
|
|
|
|
# To ensure we are able to expose metrics from multiple processes, we need to
|
|
# provide a directory for `prometheus_client` to store a shared registry.
|
|
export PROMETHEUS_MULTIPROC_DIR=$(mktemp -d)
|
|
trap 'rm -rf "$PROMETHEUS_MULTIPROC_DIR"' EXIT
|
|
|
|
export PROMETHEUS_METRICS_EXPORT_PORT=8001
|
|
export STATSD_PORT=${STATSD_PORT:-8125}
|
|
|
|
exec gunicorn posthog.wsgi \
|
|
--config gunicorn.config.py \
|
|
--bind 0.0.0.0:8000 \
|
|
--log-file - \
|
|
--log-level info \
|
|
--access-logfile - \
|
|
--worker-tmp-dir /dev/shm \
|
|
--workers=2 \
|
|
--threads=8 \
|
|
--worker-class=gthread \
|
|
${STATSD_HOST:+--statsd-host $STATSD_HOST:$STATSD_PORT} \
|
|
--limit-request-line=8190 $@
|