Does Smart Placement support Hyperdrive? I'm using Next.js with Postgres
I successfuly deployed a page using Next.js with next-on-pages connected to a Postgres database using Drizzle/Postgres.js and Hyperdrive. Everything works, except that the latency is still very high. I have enabled Smart Placement but it still takes >700ms to respond on a route with just one simple database query. My current deployment on Kubernetes takes ~150ms to do the same. (I'm measuring round trip to my pc). The "cf-placement" header shows that Smart Placement didn't trigger. Does it work with Hyperdrive? Is there anything I can do to improve this latency?
3 Replies
how did you get postgres.js to work with hyperdrive did you bundle the node dependencies?
I couldn't get pages to work with postgres in the short amount of time I tried it
1. Add this to nextconfig:
2. build with
next-on-pages
3. run sed -i '1s/^/import * as cloudflare_sockets from \"cloudflare:sockets\"\\nglobalThis.__edge_sockets = cloudflare_sockets;\\n/' .vercel/output/static/_worker.js/index.js
4. deploy with wrangler
there are a few more tricks to get it working on dev mode as well. Either way, I can't go to production with this without Smart Placement working@lbguilherme Thank you!