storing 1-3 mb html snapshots, d1 rows or r2 objects with the metadata in d1
crawler on a worker saves the rendered html for each page it visits, roughly 40k snapshots a month, and each one is 1 to 3 mb of text. i need to query by url and date and occasionally diff two versions. putting the blob straight in a d1 column is one less moving part, so before i build the two-store version i'd like to know whether anyone regrets doing it either way.
@leaky_bucket_ed · 2mo ago · 3 replies
Numbers for the R2 side so you can sanity check the bill. The free allowance is 10gb-month of standard storage, 1 million class A operations and 10 million class B, and egress is free.
Your writes are class A, so 40k a month is nowhere near the million. Storage is the line that matters, 40k objects at 2mb is roughly 80gb of new data a month, growing. Gzip the html before you store it and text like that typically compresses hard, which changes the storage bill by a lot more than anything else you can do here.
Also store the content hash in D1. Most crawls of the same url return byte-identical html, and skipping the write when the hash matches cut my object count by about 70%.
Reply
Report
@r2_bucketeer · 2mo ago
the content hash idea alone probably halves this. most of the pages i'm crawling change once a week at best and i've been storing an identical copy every single run.
Reply
Report
@airgap_amir · 2mo ago
Store the hash on the metadata row and you also get change detection for free, which sounds like the diffing feature you were planning to build separately.
Reply
Report