I suddenly received a $9 Cloudflare bill. It wasn’t very high, but for a moment I couldn’t figure out which billing item it was.
I checked the bill details and found it came from R2 storage.
| Description | Qty | Unit | price | Amount |
|---|---|---|---|---|
| R2 Storage Class A Operations (First 1M included) May 9 – Jun 8, 2025 | 1,121,440 | $4.50 per 1,000,000 | 1,121,440 | $9.00 |
In other words, the billable Class A Operations for R2 storage reached 1,121,440—over a million calls in a month, and that’s not even counting the free one million.
My first reaction was that it was caused by the batch of problem data I uploaded earlier, but I figured that more than a thousand problems producing over ten thousand files shouldn’t generate a million write operations. So I looked through the implementation logic and didn’t feel there were any clues.
After searching around, I found that the DidaOJ website’s CDN repository was being called too many times; the judge data repository, on the other hand, wasn’t called much. Then I remembered a status update logic I had implemented before.
To save server resources earlier, I wrote the server status report data to R2 storage. Each node reported its own status once every 3 seconds, so in a month I filled the quota directly…
When I was choosing an object storage service earlier, I kept focusing on traffic fees, so I chose R2 storage because egress traffic is free. But looking at it today, R2 storage charges $4.50 per million Class A Operations (1 million free per month), while Alibaba Cloud charges CNY 1 per million (5 million free per month)… I can only say there’s real design behind pricing strategies.
This was a lesson learned: when evaluating a solution, I still need to consider it carefully and comprehensively, and look closely at every aspect.
As for site status, I’ll just honestly store and retrieve it using the database. Since hardware resources are currently limited, Redis and MongoDB are on the same machine, mainly to cache some compute-intensive data. If Redis resources can be freed up later, storing this kind of status in Redis would be more reasonable.