Object storage for blobs
Object storage addresses bytes by a key and prices storage, requests and transfer apart. At 200 images/s of 1 MB, transfer is about 518 TB/month: 31,104 USD from the origin, or 5,184 USD from edge caches.
See it on the board
The same traffic runs on two boards. The simulator measured both when this page was built.
| Measure | Goal | Image bytes in the database | Object store 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% |
Key numbers
| Number | Value |
|---|---|
| Object storage price | 0.015 USD/GB-mo |
| Origin egress price | 0.06 USD/GB |
| CDN egress price | 0.01 USD/GB |
5 MB/s · logs kept on the host · disk full in 33 minutes
How it works
A database is built for rows that you query, join and update. A photo is not a row. It has no fields to join, and it never changes in place. Storing the bytes in a database makes the database store them, cache them and send them to every client.
Object storage is built for files. You put bytes under a key and you get them back by that key. It scales to huge sizes, and it is cheap for each GB: 0.015 USD per GB-month here. The metadata of the image, such as its owner and its name, stays in the application database next to the key.
In the mini board users load 200 images/s of 1 MB each. That is 200 MB/s, or about 518 TB of transfer each month. The database holds the images in the naive design, and each read goes through it. Its p99 passes 300 ms.
The price of transfer matters most. At 0.06 USD per GB from the origin, the transfer costs 31,104 USD each month. A CDN in front serves repeated reads from its edge caches at 0.01 USD per GB. The same traffic then costs about 5,184 USD. The object store sends each image once to the CDN.
So split the system by what each part does best. The database keeps the metadata, the object store keeps the bytes, and the CDN delivers them.
In the levels you move the image bytes out of the database and check p99 and cost.