Scrivio Interview library
ScenarioIntermediate7 min read · updated 13 November 2026

A messaging product stores 6 billion small attachments and previews, averaging 20 KB, in standard object storage. A lifecycle rule to move objects older than 30 days to an archive class was enabled, and the next bill went up instead of down.

Explain why, and design a tiering approach that actually saves money for this data.

The bill rose because lifecycle transitions are charged per object, so billions of 20 KB objects produced a huge one-time transition charge, and archive classes add per-object overhead (index and metadata space billed per object) that is larger than the data itself at 20 KB; some classes also bill a minimum size and duration. A tiering approach that saves money packs small objects into large archive files, for example one per conversation per month with an index of offsets, tiers only those packed files, uses size filters so tiny objects never transition, and models the break-even per object before any rule is enabled.

Why this question is asked

This is the storage version of a classic performance trap: an optimisation that looks right by the gigabyte and is wrong by the object. Six billion attachments of 20 KB sound like a lot of data, but they are only 120 TB, and the per-object charges of colder tiers overwhelm the per-GB savings. Interviewers ask this to see whether we can do the arithmetic and redesign the data layout, not just tweak a rule. In this answer, we will rebuild the bill to see where the money went, look at minimum size and duration charges, design packing and size-filtered rules, model the break-even, and explain how users read a packed attachment.

1Rebuilding the Bill

Let us do the arithmetic with illustrative list prices; the exact numbers vary by provider and region, so a real analysis uses the current price list. Six billion objects of 20 KB is 120 TB. In standard storage at about $0.023 per GB-month, that costs about $2,760 per month.

Text
objects = 6,000,000,000 x 20 KB = 120 TB
standard storage = 120,000 GB x $0.023 = about $2,760 / month
transition fee = 6,000,000 x $0.05 per 1,000 = about $300,000 once
after moving to deep archive:
data = 120,000 GB x $0.00099 = about $119 / month
overhead 32 KB/object at archive price (192 TB) = about $190 / month
overhead 8 KB/object at standard price (48 TB) = about $1,104 / month
total = about $1,413 / month
monthly saving = 2,760 - 1,413 = about $1,350
payback = 300,000 / 1,350 = about 220 months (18 years)

Notice where the money goes. The transition is billed per object, and six billion objects turn a tiny per-request price into a six-figure bill, which is exactly the jump the next invoice showed. Then the per-object overhead: archive classes keep about 40 KB of index and metadata per object, part of it charged at the standard rate, which is twice the size of the average attachment. Even after the one-time charge, the monthly saving is half of what the per-GB price suggested, and it would take about 18 years to pay back. And since new objects keep turning 30 days old, the rule keeps charging transitions every month.

2Minimum Size and Minimum Duration Make It Worse

If the rule had targeted an infrequent-access class instead, another charge would bite. Some of those classes bill each object as at least 128 KB. A 20 KB preview is billed as 128 KB at a lower rate: about 128 KB x $0.0125 versus 20 KB x $0.023, which is roughly three and a half times more expensive than leaving it in standard storage.

Minimum storage durations add a second trap. Many messages and previews are deleted by users or by retention within weeks. An object moved to a class with a 90 or 180-day minimum and deleted after 20 days is still billed for the full minimum, so short-lived small objects are charged as if they were larger and older than they are.

3Packing Small Objects Into Large Archive Files

The fix is to change the unit we tier. Instead of moving six billion small objects, we move a few million large files. A packing job takes all attachments of a conversation for a month, writes them one after another into a single file, and records each attachment's offset and length in an index.

SQL
-- index in a small database (PostgreSQL)
CREATE TABLE packed_attachment (
attachment_id bigint PRIMARY KEY,
pack_key text NOT NULL, -- s3://media-archive/2026/09/conv-81442.pack
byte_offset bigint NOT NULL, -- 1048576
byte_length int NOT NULL, -- 20480
sha256 bytea NOT NULL);
-- 6,000,000,000 objects / about 200 per pack = about 30,000,000 packs
-- transition fee: 30,000 x $0.05 per 1,000 = about $1,500 instead of $300,000
-- overhead: 40 KB on a 4 MB pack = 1 percent instead of 200 percent
Step throughPacking then tiering
  1. Select attachments older than 30 daysgrouped by conversation and month
  2. Write them into one pack filerecord offset, length and checksum per attachment
  3. Verify the packread back and compare checksums
  4. Delete the original small objectsonly after verification
  5. Lifecycle moves packs to a colder classfew, large objects: cheap transitions

5 steps in order. Play them, or step through them one at a time.

The job verifies each pack by reading it back and comparing checksums before deleting the original small objects, and it is resumable per conversation and month. Packs from conversations that are very small can be combined further, so packs are at least a few megabytes. The packed files, now large, are exactly what tiering was designed for.

4Size-Filtered Lifecycle Rules

Lifecycle rules can filter by object size. We set a minimum size, for example 1 MB, so only packs and genuinely large files transition, and tiny objects never do. Some providers now skip objects smaller than 128 KB by default, but we state the filter explicitly rather than rely on a default (check yours). Tiny objects that remain unpacked stay in standard storage, or move to a cheaper non-archive class without a minimum size, and are deleted when retention says so. Often the cheapest answer for previews is deletion: a preview can be regenerated from the original attachment, so it does not need to be archived at all.

5Modelling the Break-Even Before Enabling a Rule

Every rule gets a short model per object before it is turned on. The cost side is the transition fee plus any added overhead and any minimum-duration charge. The saving side is the monthly price difference times the object's size, over its expected remaining life.

Java
saving_per_month = size_gb x (price_hot - price_cold) - overhead_cost_per_month
payback_months = transition_fee_per_object / saving_per_month
enable the rule only if payback_months < expected_remaining_life_months
and expected_remaining_life_months >= minimum_duration_months
-- 20 KB object: payback about 220 months -> no
-- 4 MB pack: payback under 1 month -> yes

Writing the model down also forces us to answer the read question: how often are these objects read after 30 days, and what do retrievals cost? A class with retrieval fees is wrong for data that is opened often, however cheap it is to store.

6Follow-up questions

How would users read an attachment that now sits inside a packed archive file?

The API looks up the attachment in the index to find its pack, offset and length, then reads only those bytes with an HTTP range request, so a 20 KB attachment costs one small read, not a 4 MB download. It checks the checksum and can cache the result. For this to feel normal to users, packs should live in a class with millisecond access, such as an instant-retrieval archive class. If packs go to a class that needs a restore, the product must show the attachment as being retrieved and notify the user later, which is acceptable only for very old content.

How do we delete one attachment that is inside a pack?

We mark it deleted in the index so it is never served, and a periodic compaction job rewrites packs that contain deleted items, which also meets privacy deadlines. Rewriting a pack in an archive class may incur minimum-duration charges, so compaction runs on a schedule that balances deadlines and cost.

Why not just delete old previews?

Often that is the best answer. Previews can be regenerated from the original attachment on demand, so storing them for years in any tier is waste. Keeping only originals and regenerating previews when an old conversation is opened usually saves more than any tiering rule.

7Conclusion

In this answer, we saw that the bill went up because transitions are charged per object and archive classes add per-object overhead larger than a 20 KB object, with minimum sizes and durations making small, short-lived objects even more expensive. The fix is to tier large objects: pack small attachments into files per conversation per month with an index of offsets, filter lifecycle rules by size, delete what can be regenerated, and model the per-object break-even before enabling any rule.

What to say in the interviewAbout 90 seconds aloud

Open with

The bill went up because tiering is priced per object, and we have six billion small ones. Lifecycle transitions are billed per object, so moving six billion objects costs a large one-time sum, in the hundreds of thousands of dollars at typical list prices, which is the jump we saw.

Then, if they want more

On top of that, archive classes keep about 40 KB of index and metadata per object, partly charged at the standard rate, which is bigger than the 20 KB attachment itself, so the monthly saving is much smaller than the price per GB suggests.

Some classes also bill a minimum object size, like 128 KB, and a minimum duration, so small and short-lived objects pay as if they were bigger and older.

My design is to pack small objects into large files, for example one file per conversation per month, a few megabytes each, with an index of offsets and checksums in a small database. Then only the packs are tiered, so we transition thirty million objects instead of six billion.

Lifecycle rules get a minimum size filter so tiny objects never transition, and previews that can be regenerated are simply deleted. Reads use the index and an HTTP range request into the pack. And before enabling any rule, I model the break-even per object: transition fee and overhead versus the monthly saving over its remaining life.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain why, and design a tiering approach that actually saves money for this data.": https://scrivio-interview-library.netlify.app/architecture/storage-and-pipelines/9039d10199/