Database rows vs object storage for images

A database row that holds image bytes makes every read use database CPU and network. Object storage behind edge caches serves the bytes without the database. At 200 images/s of 1 MB, rows give p99 over 10 s and 29 percent errors. Object storage gives p99 81 ms for 5,864 USD/mo.

Play the level

A disk that fillsArrow keys change the write rate. Tap to ship the logs.

5 MB/s · logs kept on the host · disk full in 33 minutes

Images through one cardArrow keys change the images per second. Tap to swap the card.

100 images/s · 1,600 of 1,000 Mbps · it does not fit

Case 1

200 images/s of 1 MB each. The images need no joins, and their metadata stays in the app database. p99 must stay below 300 ms and cost below 10,000 USD/mo.

Case 1
Measure Goal Image bytes in database rows Object storage behind a CDN
p99 latency under 300 ms 10.1 s Fail 81 ms Pass
Monthly cost 16 USD/mo 5,864 USD/mo
Error rate 29.3% 0%
SQLUsersPostgres2 vCPU · 4 GB
SQLUsersPostgres2 vCPU · 4 GB
Image bytes in database rows: misses a goal
HTTP/2S3UsersCDN1 vCPU · 1 GBObject stor…2 vCPU · 2 GB
HTTP/2S3UsersCDN1 vCPU · 1 GBObject stor…2 vCPU · 2 GB
Object storage behind a CDN: meets the goals