Open technophile-04 opened 2 months ago
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 |
@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.
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 usingnode-postgress
only in local development but usingPool
instead ofClient
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