In my environment, Hyperdrive is 10x

In my environment, Hyperdrive is 10x slower than direct connection, while latencies that are displayed Cloudflare web dashboard are not such bad(~100ms). The database region is Tokyo(Japan) and I accessed my Workers from Tokyo too. Does anyone experience a similar problem?
24 Replies
AJR
AJR4mo ago
Sounds like this is relevant to you. https://discord.com/channels/595317990191398933/1150557986239021106/1263092112875061259 Please DM me with your Hyperdrive ID, we have a fix we're working on we can test with you, if you're interested.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
That's going to depend a lot on where your users are and where your database is. It should not be substantially slower than a direct connection, though. Those are the cases we are concerned with at the moment.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
While I hate to do the typical engineer thing, it depends™️ . If your users and your DB were in the same datacenter then we'd add quite a lot of latency. For a normal Workers use case we generally have less latency than a direct connection. There's enough variation with your provider, your app, your actual user placement, peering arrangements, etc ad nauseum, that us publishing the figures we see would not be useful for what you would see. As always, I recommend you measure to see what the actual difference is.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
https://hyperdrive-demo.pages.dev/ This demo hits a setup on neon from a worker elsewhere I believe. Again, in the normal use case hyperdrive is actually faster than a direct connection from workers. Ah, details of the setup are described at the bottom of the page
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
No, that first query is uncached, 126 ms is correct for a new query
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
I don't know what you're asking about. I've given you the numbers we have. Those line up with what I see in my tests as well.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
I don't know what 200-300ms you're referring to. Hyperdrive is for hitting a database from a Worker. If your users are all in the same datacenter as your database, and you're sending traffic out to the Cloudflare network and back, the latency you'll see has very little to do with Hyperdrive. In general, "just give me some numbers" isn't really a meaningful question.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
If you're seeing those, that's a problem and we want to hear about it.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
Ah. I see
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
So, we observe the actual runtime overhead of hyperdrive (that is the processing of the connection and the actual postgres message), to be incredibly small. On the order of <5ms (conservatively). The comparison to make here would be hitting a database from a worker via Hyperdrive vs via the same Worker with a direct connection. In those scenarios you will almost never see that 5ms as our optimizations willl substantially overwhelm it and you'll see the difference shown in that demo.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
Now, if you're connecting via psql from a single point and comparing that to numbers from a worker (either with or without Hyperdrive), any difference you're seeing is basically measuring the difference in traversing via cloudflare vs via the public Internet. In most cases Workers will win, for a variety of reasons. However if your hyperdrive is placed in a way that isn't ideal, or if for some reason our connectivity to your database is worse than the public Internet, you start to see much less good numbers
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
AJR
AJR4mo ago
No problem. Hope that helps.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server