Estimate Cloudflare Data Platform Costs Before Migrating
In this article
Migrating to Cloudflare's data platform (D1, R2, Workers, Queues, etc.) can cut costs, but only if you estimate accurately first. This guide walks you through a practical, step-by-step method to forecast your monthly bill based on your current usage patterns, so you avoid surprise charges and can compare apples-to-apples with your existing setup.
What You'll Need
- Current database or storage usage metrics (rows, read/write operations, storage size)
- Traffic analytics (requests per day, peak vs. average)
- Existing cloud bill or usage dashboard (to extract operation counts)
- A spreadsheet or a simple text file for calculations
Step-by-Step
- List your current workloads. Break down your application into components: database reads/writes, file storage, API requests, background jobs, and real-time features. For each, note the approximate monthly volume.
- Map each workload to a Cloudflare service. Typical mappings: relational data → D1, object storage → R2, serverless functions → Workers, message queues → Queues, and key-value store → KV. Don't force a fit—if you have a heavy analytics workload, D1 might not be right.
- Estimate D1 database costs. D1 charges by storage (GB per month) and operations (reads and writes per day). Check Cloudflare's pricing page for current rates. Multiply your average daily reads and writes by 30 to get monthly figures. Remember that D1 has a free tier (5 GB storage, 5 million reads/day, 100k writes/day) – subtract that before calculating cost.
- Estimate R2 storage costs. R2 charges for storage (GB/month) and operations (Class A: writes, Class B: reads). There's no egress fee. Take your current object storage size and monthly operation counts. Apply the free tier (10 GB storage, 1 million Class A ops, 10 million Class B ops) then multiply by rates.
- Estimate Workers costs. Workers charges per request (after 100k free requests/day) and per CPU millisecond (after 10 million free ms/day). Estimate your total monthly requests and average CPU time per request. Multiply and add. Don't forget Workers KV reads/writes if you use it – those have separate charges.
- Add Queues and other services. If you use Queues, estimate operations per month. For any other Cloudflare services (like Images, Stream), add them separately. Keep a line item for each service.
- Sum it up and compare. Total the monthly estimated cost. Compare it with your current bill for the same workloads. Include any egress savings (Cloudflare charges no egress) – this often tips the balance.
- Validate with a small pilot. Before full migration, run a one-week pilot with a subset of traffic. Measure actual usage against your estimates and adjust the forecast.
Common Mistakes
- Ignoring the free tiers. Cloudflare's free tiers are generous. If you're small, you may pay nothing. Always subtract free allowances before calculating.
- Using peak instead of average. Pricing is based on total monthly usage, not peak. Use averages, but note that spikes can push you over thresholds—plan for some headroom.
- Forgetting write-heavy workloads. D1 charges per write operation, and writes are more expensive than reads. If your app logs frequently, that adds up fast.
- Assuming egress is free everywhere. It's free on Cloudflare, but if you're comparing to a provider that charges egress, include that in your current cost.
- Overlooking Workers CPU time. Requests are only half the cost; CPU time can dominate if you do heavy computation. Estimate that carefully.
Tips
- Use Cloudflare's official pricing pages – they update rates, so always check the latest.
- Build a spreadsheet with formulas so you can tweak inputs easily.
- Start with a conservative estimate (round up) to avoid budget overruns.
- Consider using D1's built-in metrics after migration to refine your forecast.
- Remember that Cloudflare's free tier is per account, not per database – so if you have multiple apps, they share the free allowance.
Troubleshooting
If your estimate seems wildly off, check these:
- Did you use the right units? Cloudflare charges per million operations, not per operation. Convert your counts correctly.
- Is your traffic pattern bursty? If you have daily spikes, your average might be fine, but the peak could push you into a higher tier. Look at your 95th percentile.
- Are you double-counting? Workers that call D1 or R2 count as both a Worker request and a database operation. Make sure you account for both, but don't multiply them together.
- Did you include the free tier correctly? The free tier is applied per day, not per month. For example, D1 gives 5 million reads per day, so that's 150 million per month free. Recalculate with daily limits.
- Still stuck? Reach out to Cloudflare's sales team – they can provide a custom estimate based on your usage patterns.
Frequently Asked Questions
Is Cloudflare's data platform really cheaper than AWS or GCP?
Often yes, especially when you factor in zero egress fees. But it depends on your workload. For heavy analytics or complex queries, a traditional database might be more cost-effective.
Can I use D1 for a production database?
Yes, D1 is production-ready, but it has limitations like a 10 GB database size limit. For larger datasets, consider using it with Workers or alongside another database.
What's the difference between D1 and Workers KV?
D1 is a SQL database for relational data with joins and transactions. KV is a global key-value store for simple lookups. Use KV for high-read, low-write scenarios; D1 for structured data.
How do I estimate Workers CPU time?
Run a simple benchmark in a test Worker that logs CPU time per request. Multiply average CPU time by your expected monthly requests. Cloudflare's dashboard also shows CPU time after you deploy.
Does Cloudflare charge for data transfer between services?
No, internal traffic between Workers, D1, R2, and Queues is free. You only pay for egress to the public internet, which is free up to a limit (and then very cheap).
Can I get a refund if I overpay?
Cloudflare doesn't offer refunds for usage, but you can set budget alerts in the dashboard to monitor spending and avoid overages.