25/35
Part 3 of 3 · Serving and driftLearn and do
Cache by tier, and count the cache in the feature's age
A cache cuts the fetch time, and it makes each value older.
| Feature | Changes | Cache | Extra age it adds |
|---|---|---|---|
| Title features | when the catalog snapshot refreshes | in process, refreshed every 5 minutes | up to 5 minutes |
| Member batch features | once a day | per session, TTL 30 minutes | up to 30 minutes, on a value already 4 to 28 hours old |
| Member streaming features | every few seconds | none, or a TTL well under the freshness target | a 10-minute TTL makes a 1-minute feature a 10-minute feature |
Set each TTL from how often the value changes.
The session cache pays off. Say one homepage session makes 6 ranking calls (assume: the first rows plus pagination). Reading member batch features once per session instead of once per call removes 5 reads in 6, about 83%.
In the editor, write worst_age_s(pipeline_lag_s, cache_ttl_s) and reads_saved(calls_per_session). The last line checks the 10-second stream behind a 15-minute cache, and the 6-call session.