Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use appropriate driver based on env #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

technophile-04
Copy link
Member

Description:

Please feel free to close this PR since might an not required optimisation and also I can't seem to prove practically why this would be helpful but in theory :

Using vercel postgres on production and preview mode instead of node-postgres.

The reason for above is:

Vercel-postgress is nicely optimized to work in serverless envionemnt and it also manages the db connections itself nicely without us needing to anything.

Since in serverless environment functions are ephemeral like they spin up to handle a request and then shut down. So if we use node-postgres with Client then it will again and again start / stop db connections probably also increasing the latency or might create multiple unecessary connections.

With vercel-postgress I think they handle above case nicely and also some other optimization.

ANother change which I did was switching from node-postgres Client => Pool. This change was not required at all since now we are using node-postgress only in local development but using Pool instead of Client is lot closer vercel-postgress in how they manage connections / multiple concurrent request. But again this changes was indeed not required at all.

But yeah please feel free to close this PR!! and this changes is not that much required at all considering our users / requests to the application lol we might be only saving $0.0000.......1 with this changes or maybe no change at all

Copy link

vercel bot commented Aug 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
extensions-hackathon ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 22, 2024 9:21am

@damianmarti
Copy link
Member

@technophile-04 excellent optimization!! Although it will not make any difference in this project, it's the right way to manage the DB connections in a serverless environment. The complexity added is not too much, so I think it's a good idea to use it, so when we use this code on another site, we take advantage of it, and maybe in this other project it make a big performance improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants