PostHog / plugin-server

Service to process and save PostHog events, supporting JS/TS plugins at that
https://posthog.com
8 stars 5 forks source link

Out of connections on postgresql #385

Closed macobo closed 3 years ago

macobo commented 3 years ago

Sentry error: https://sentry.io/organizations/posthog/issues/2225546229/?project=5592816&query=is%3Aunassigned+is%3Aunresolved

[___3] 13:22:35 🟡 Can not start job queue producer "graphile": remaining connection slots are reserved for non-replication superuser connections
error Parser.parseErrorMessage(pg-protocol.dist:parser)
remaining connection slots are reserved for non-replication superuser connections

This might be because either:

Worth looking into:

macobo commented 3 years ago

Seems like we're running Aurora Postgresql directly on RDS, with no pgbouncer.

Here you can see our connection usage over last week:

image

While there are connection limits on it, it seems we've set it to autoscale. Here's the "number of instances" count over the last week:

image

Looking at other metrics, seems like we're doing very little traffic through it. Seems like we might need to tweak this instance setup?

cc @fuziontech - mind documenting the existing setup and handing off the "fix" to tiina or me?

fuziontech commented 3 years ago

Fixed! We added a PGBouncer service between Aurora and Graphile https://github.com/PostHog/private-infra/tree/main/aws/infra/services/pgq-pgbouncer