Skip to content

Implementing Websockets without exhausting database connection pool? #502

Answered by gi0baro
kamakazikamikaze asked this question in Q&A
Discussion options

You must be logged in to vote

@kamakazikamikaze correct, by default the database Pipe opens a connection in the open step of the pipeline, and release it on the close step. This is true both for requests and websockets mainly for 2 reasons:

  • historical reasons
  • giving the same DX regardless of requests/websockets: if your code interact with the database having the database pipe in the pipeline it is always ensured you have a database connection opened.
    I agree with you that this is far from ideal in websockets scenarios, but at the same time there's no way for Emmett to understand when to acquire/release database connections based on your route code.

So yes, if you want to use database connections only when you need t…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@kamakazikamikaze
Comment options

@gi0baro
Comment options

@gi0baro
Comment options

@gi0baro
Comment options

@kamakazikamikaze
Comment options

Answer selected by kamakazikamikaze
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants