Skip to main content

Connection Pooling for Onyx AI

· One min read
Stephan Hochdörfer
Head of IT Business Operations

For a few months we've been using Onyx as an internal AI chat platform. Its advanced capabilities like RAG, web search, and deep research make it a valuable tool for us.

Recently, we ran an issue with Onyx consuming about 50 idle PostgreSQL connections, which caused problems when deploying additional tools in our application cluster.

My first approach was to use pgbouncer to address the issue. However, Onyx itself was unable to handle pgbouncer's connection pooling and failed to start properly.

I opened an issue on GitHub, and fortunately, the Onyx team had already resolved the problem.

We now have two options to manage PostgreSQL connections:

  1. Use Onyx's connection pooling feature: We opted for this approach. You can configure the connection pool and overflow buffer size using the POSTGRES_API_SERVER_POOL_SIZE and POSTGRES_API_SERVER_POOL_OVERFLOW environment variables.
  2. Disable connection pooling and use pgbouncer: To disable Onyx's connection pooling feature, set the POSTGRES_USE_NULL_POOL environment variable to true.

Adjusting Onyx's internal connection pool settings resolved the issue for us. By choosing one of the two available options, you can effectively manage PostgreSQL connections and avoid potential deployment issues.