Hey all! Today we released the final step in a fairly large rearchitecture of Hyperdrive. We'll be getting into the details in a full length blog post a little down the road, but for now here are the takeaways.
All newly created Hyperdrives will perform substantially more efficiently. This goes double for users with the origin database in APAC.
This should primarily manifest as lower latencies and fewer disconnects.
This will affect all Hyperdrives with or without caching.
We will be backfilling this solution to existing Hyperdrives progressively, over the course of the next couple weeks, starting next Monday. If you want yours handled sooner, please feel free to message me or respond in a thread here.
This one took the whole team quite a bit of work, it's been fun to ship. I'm excited to finally have it going out the door.
I've done some search on this channel and it seems like cache busting/purging is still WIP? I ran into a bug today that took me awhile to figure out it was being caused by hyperdrive - user creates a comment, the query client then invalidates the comments query, it refetches the stale data causing my optimistic comment to disappear. This makes sense given hyperdrive caching. I'm just curious as to what my workaround should be given that cache purging isn't a thing (yet).
It'd be a little contrived for me to add some volatile function to the query given that it'd have to originate from the client and then drill through the api router and modify queries in a weird way
The alternative is likely just a second hyperdrive config with caching disabled, and direct your queries to whichever is appropriate at the application level.
Totally depends on what you're doing. If you are sorting by a date column, but are returning the date column anyway, you can sort it in JavaScript after.
I just turned off caching for now, I'll wait until cache purging is shipped, I don't love modifying the application layer in weird ways to get expected query behavior
I think the two hyperdrive configs is a pretty good solution, since in my case it's really there's a set of resources that frequently are mutated and should never be cached, and sets of resources that can be cached
Part of the reason that this is taking so long is that a bunch of folks went ahead and tried to allowlist based on the shared/untrusted ip pool. We don't want to just break them (though at some point they'll get broken anyway when the pool shifts enough to clip them, but at least it won't be because we did it). So the migration over is kind of a process.
@AJR oh, another reason why exposing Hyperdrive as a regular PostgreSQL pooler would be great: we could do stacked Hyperdrive configs! e.g. one "main" Hyperdrive with no caching connected to the real backend directly, and then have another Hyperdrive config with caching enabled that connects to the main Hyperdrive's pooler.
Oh yeah. Measure how long it takes to create a connection to a pooler/origin further away than a couple hundred miles and you'll have a clear picture of why only ~half of our configs even having caching enabled.
I'm pretty sure the answer to this is "heck no", but would it possible to have a unique outgoing port for each Hyperdrive config? (And I don't think it would be too insane, since it's only 25 ports per paid Workers account that would need to be "reserved".) Or even 1 unique port per account would be nice.
That would be really nice to firewall based off of.
I would be curious if using Hyperdrive reduces bandwidth pricing (and by how much) for Google Cloud customers, since Cloudflare has a reduced bandwidth price iirc.
The goal is that it should, yes. Still needs some work to get all the way there, I believe. I don't work with that project a ton and there is some nuance IIRC.
It gets complicated. It goes GCP->Workers->Hyperdrive for ingress, so I believe that's already reduced. Egress from ??->Workers->Hyperdrive->GCS is the one I'm not certain about.
You should be able to automatically tell who did the allowlist by trying to connect from a new IP. Then whoever fails, email them giving them a warning that they need to use the new proper official list of IP ranges.
Of the shared address pool? Not publicly, but folks are clever. Hazard of making tools for other devs, I guess. In some regions things are stable enough that folks noticed that all Hyperdrive connections were coming in from a small number of addresses, and eventually just coded that into their firewall rules.
Hey thanks for reply on this. Yes when I try to setup hyperdrive + a managed DO database in cf dashboard it errors
I have setup connections with supabase in the past successfully and I searched this channel for issues with DO leading me to believe it’s with DO ip range?
Interesting. I searched and you're right, TCP connect from workers to DO seems to have some issues.
I'm not sure if it's due to the shared address range or not, though.
I'll check Monday with my teammate who's working on the migration to the CF IP ranges and see if we have a way to test if DO cooperates with those. I'd be curious to know, honestly