cloudflare workers or a $7 vps for an api at 45 req/s and p95 under 300ms Benchmarks
Read-heavy JSON API. Steady 45 req/s with peaks around 120, so roughly 3.9M requests a day. Contract says p95 under 300ms measured at the client. Data lives in Postgres, single region, and about 70% of responses are cacheable for 60 seconds.
I can put this on Workers or on a $7/month VPS with 2 vCPU and 4GB. I am one person and I do not want to be woken up by a full disk.
What actually decides this - cost, latency, or the fact that nobody is on call?
@cast_iron_carl · 7mo ago · 3 replies
Do the arithmetic before the architecture. 3.9M/day is about 117M requests a month.
On the paid Workers plan that is roughly $5 base with 10M requests included, then 107M extra at $0.30 per million, so about $32, plus CPU time on top - at 5ms of CPU per request you are looking at another ten dollars or so. Call it $45-50/month. Check the current numbers yourself, but the shape does not move.
The VPS is $7 and 45 req/s of cached JSON is nothing for 2 vCPU. So the money says VPS by a factor of six.
The money is not the interesting part though. Your 70% cacheable is - stick a CDN in front of either option and 70% of your traffic never reaches your origin at all, which takes 45 req/s down to 14. At 14 req/s a $7 box is bored and the p95 question becomes entirely about the distance to Postgres, which is the same for both options because the database has not moved.
One person, no on-call: I would take the VPS, put a CDN in front, and spend the difference on a managed database and backups I do not run myself.
Reply
Report
@crimp_not_solder · 7mo ago
The CDN point reframes it. I had been treating cacheability as a nice-to-have rather than as the thing that decides the capacity question.
Reply
Report
@cast_iron_carl · 7mo ago
It usually is the thing. Most "do I need edge compute" arguments are actually cache-hit-rate arguments wearing a costume.
Reply
Report