Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Usage with pg-bouncer #410

Closed
timsuchanek opened this issue Jan 15, 2020 · 8 comments
Closed

Usage with pg-bouncer #410

timsuchanek opened this issue Jan 15, 2020 · 8 comments
Assignees
Labels
kind/docs A documentation change is required.
Milestone

Comments

@timsuchanek
Copy link
Contributor

We should research how to set up Prisma Client together with pg-bouncer.

@timsuchanek timsuchanek added kind/docs A documentation change is required. process/candidate Candidate for next Milestone. labels Jan 15, 2020
@janpio janpio added this to the Preview 21 milestone Jan 17, 2020
@divyenduz
Copy link

Related issue: prisma/prisma#556

@pimeys
Copy link
Contributor

pimeys commented Jan 21, 2020

I'll write a document about pgbouncer today.

@pimeys
Copy link
Contributor

pimeys commented Jan 21, 2020

Summary: yes we can.
Longer summary: https://www.notion.so/prismaio/Pgbouncer-Evaluation-71076db4699e4ba48bf13df879d485a7

The work so far in two branches:

@janpio janpio removed the process/candidate Candidate for next Milestone. label Jan 21, 2020
@pimeys
Copy link
Contributor

pimeys commented Jan 22, 2020

Merged to master now, instructions how to enable the transaction mode in query engine can be found here:

prisma/prisma-engines#403

@pimeys pimeys assigned timsuchanek and unassigned pimeys Jan 22, 2020
@pimeys
Copy link
Contributor

pimeys commented Jan 22, 2020

Threw this back to @timsuchanek now. You should make a decision how and when to enable the flag in query engine, if wanting to support pgbouncer transaction mode in the client.

@timsuchanek
Copy link
Contributor Author

timsuchanek commented Jan 22, 2020

Awesome @pimeys! We need to make a product decision, how we expose this in Prisma Client. cc @sorenbs

@pimeys
Copy link
Contributor

pimeys commented Jan 22, 2020

We now run all the tests against pgbouncer in transaction mode btw.

@pimeys
Copy link
Contributor

pimeys commented Jan 24, 2020

I did an initial test how Heroku's Pgbouncer offering could work together with Prisma. Summarizing what needs to be done for Pgbouncer:

If in session mode, everything works just normally. Just point Prisma to the Pgbouncer URL and call it a day. (This will not help you consume less connections)

If in transaction mode, certain settings need to be modified in Pgbouncer config:

pool_mode = transaction
server_reset_query = DEALLOCATE ALL
server_reset_query_always = 1

And of course the Prisma Client needs to start the server in the right mode, e.g. this spec should be implemented.

Heroku allows changing Pgbouncer's settings using environment variables. For now only two of the three settings can be changed:

> heroku config:add PGBOUNCER_POOL_MODE=transaction
> heroku config:add PGBOUNCER_SERVER_RESET_QUERY="DEALLOCATE ALL"

The third setting should be available when the needed pull request lands.

For other important providers, as discussed with @divyenduz, he will make sure the settings are available. When all is set, these need to be communicated with our users through the documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/docs A documentation change is required.
Projects
None yet
Development

No branches or pull requests

5 participants