I copied the example for exposing an R2 bucket to the internet here: Using R2 in a Worker · Cloudflare R2 docs
When I try to retrieve assets using this worker, often the response times are around the 0.5s-1s mark (sometimes more).
For example, this is a gif that is stored in my R2 bucket and retrieved using that worker: https://bacon-cdn.andrewdjessop.workers.dev/shakes-fists.gif
I’ve just fetched this 10 times and it seems the average is around 700ms - 800ms. I was expecting something more around 100ms (preferably less).
Is this a fundamental limitation of R2, or is it just because it’s in beta and is not rolled out to all data centres, or something else to do with the code?
Cheers.
Edit: here’s one of the logs:
outcome": "ok",
"scriptName": null,
"exceptions": [],
"logs": [
{
"message": [
"GET object shakes-fists.gif: https://bacon-cdn.andrewdjessop.workers.dev/shakes-fists.gif"
],
"level": "log",
"timestamp": 1653553449825
}
],
"eventTimestamp": 1653553449825,
"event": {
"request": {
"url": "https://bacon-cdn.andrewdjessop.workers.dev/shakes-fists.gif",
"method": "GET",
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-encoding": "gzip",
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"cf-connecting-ip": "8.20.126.63",
"cf-ipcountry": "DE",
"cf-ray": "71151ce55a7b994b",
"cf-visitor": "{\"scheme\":\"https\"}",
"connection": "Keep-Alive",
"host": "bacon-cdn.andrewdjessop.workers.dev",
"pragma": "no-cache",
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"100\", \"Google Chrome\";v=\"100\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
"x-forwarded-proto": "https",
"x-real-ip": "8.20.126.63"
},
"cf": {
"longitude": "8.68430",
"latitude": "50.11880",
"tlsCipher": "AEAD-AES128-GCM-SHA256",
"continent": "EU",
"asn": 13335,
"clientAcceptEncoding": "gzip, deflate, br",
"country": "DE",
"isEUCountry": "1",
"tlsClientAuth": {
"certIssuerDNLegacy": "",
"certIssuerSKI": "",
"certSubjectDNRFC2253": "",
"certSubjectDNLegacy": "",
"certFingerprintSHA256": "",
"certNotBefore": "",
"certSKI": "",
"certSerial": "",
"certIssuerDN": "",
"certVerified": "NONE",
"certNotAfter": "",
"certSubjectDN": "",
"certPresented": "0",
"certRevoked": "0",
"certIssuerSerial": "",
"certIssuerDNRFC2253": "",
"certFingerprintSHA1": ""
},
"tlsExportedAuthenticator": {
"clientFinished": "b1e20a5740a343fcfb6467be09be00535855a9941070aa87dd4415f8b4ce4813",
"clientHandshake": "fb3a0192daba988d584c9e608f7ee16806e3d8039bc0a7756062f179c8f5996f",
"serverHandshake": "341a06efb07e5c69e892a125b2c9f398a7d9635e045aea84ed4fb1e83df12dd3",
"serverFinished": "ab86bdcd773353e83d726a1e7e50a7bf38163fb5edaea1081ba6a895215bf0fb"
},
"tlsVersion": "TLSv1.3",
"colo": "FRA",
"timezone": "Europe/Berlin",
"city": "Frankfurt am Main",
"edgeRequestKeepAliveStatus": 1,
"requestPriority": "",
"httpProtocol": "HTTP/3",
"region": "Hesse",
"regionCode": "HE",
"asOrganization": "Cloudflare Warp",
"postalCode": "60313"
}
},
"response": {
"status": 200
}
},
"id": 12
So it seems that it’s coming from a data centre not too far from me (I’m in France, data centre is Germany).