[SERVER-5592] Requesting document-level LRU Created: 13/Apr/12  Updated: 29/Jun/12  Resolved: 13/Apr/12

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: P Eger Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to DOCS-251 Pattern: Expire Least Recently Used D... Closed
Participants:

 Description   

Requesting MongoDB to officially support "LRU Capped Collections", basically capped collections but with LRU instead of FIFO ordering. IOW I would like to be able to set a max collection size, and have MongoDB automatically delete least recently used (read or write) documents when full. The LRU need not be perfect, but a decent approximation would likely be good enough for most needs.

This is a fundamental requirement for us using MongoDB as a cache, presently we will need to implement one of the following less desireable hacks:
1) Maintain the LRU in app server memory (sucks in a clustered environment)
2) Maintain a "last access" timestamp with every doc (sucks in that it turns every read into a write)

Either way, we have to write a background job that continually monitors the db size and deletes when we hit a threshold (or do this on every write which is expensive). Which also sucks because it has ugly failure modes.

Ideally, the LRU would be persisted. I can think of a few ways this can be done relatively cheaply, as long as the LRU is not expected to be exact. A simple in-memory lru would be sufficient for our needs though.

A couple of things I don't need, though others might
1) Support for sharded collections. I feel that a per-shard LRU is plenty good, no need to maintain perfect LRU behaviour across all servers.
2) LRU across collections, which would add complex inter-collection behaviour

Thanks and open to alternatives. I tried seeing how this could be simulated with capped collections but could not find a reasonable solution.



 Comments   
Comment by P Eger [ 13/Apr/12 ]

Yeah I saw that ticket but could not convince myself that it would provide LRU/capped behaviour. A simple TTL would need to be configured and sized to the data insertion rate, which is definitely not desired and similar to the problems with trying to use capped collections. Do you have a pointer to a more complete description/documentation of the feature?

Comment by Eliot Horowitz (Inactive) [ 13/Apr/12 ]

I believe this is fully covered by SERVER-211.

Well, not fully covered, but could be easily implemented on top of.

Comment by P Eger [ 13/Apr/12 ]

Some related tickets:

https://jira.mongodb.org/browse/SERVER-5170
https://jira.mongodb.org/browse/SERVER-211

Generated at Thu Feb 08 03:09:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.