Worker request time increased drastically after deployment
Hey there, before my deployment i had a quite low request time, usually below a second, only a few hundred milliseconds. But all of a sudden after a few deployments my worker request times went up to 4 or 5 seconds.
My worker really doesnt do much besides a few DB requests and console logs, but no extreme loops or anything, and is written in js. The only thing i changed was adding a lookup table for country codes to get the country the request was made from, so
but that was actually it. I cant explain to myself how or why the request times went up by so much, but maybe that isnt even the issue and something else.. Any ideas?
Also for the metrics, median CPU time is 7 ms, wall time is 3000ms and execution duration is 37.8 GB-sec.
8 Replies
So if your median CPU Time is decent it wouldn't be related to the country lookup, and instead should be in a subrequest or d1 query/binding call you're doing. I would time them all with
performance.now()
and see how long each one takes.
The D1 Console page may also show something interesting for your database under Metrics -> Query Latencymy query latency is 0ms apparently
for D1
as its all just primary key queries
how are subrequests defined in my worker? I dont do any requests to any websites or anything, just D1 and KV
these are my KV latencies
Subrequest is any request to another cf service (kv/d1) or an actual url via fetch
in my js i just use awaits but only for DB requests or KVs if that might be related
yea i dont use any fetch
okay so magically all requests are now back to their usual times, but all metrics are the same....
If your request time is high, and it's not in your cpu time, your metrics show high wall time, so it should be in one of the kv/d1 calls if that's all you're doing. Maybe an excessive amount that adds up quickly or something? Eitherway I'd just wrap in
const start = performance.now(); //external subrequest (kv, d1, etc) const end = performance.now(); const timing = end - start;then log that timing + your op name, so you can what's being slow
alright, from now on i will use that, thank you!