首页  

Aerospike3.8之前版本的TTL和驱逐机制     所属分类 aerospike 浏览量 1569
根据原文翻译整理
Records TTL and Evictions - For Aerospike server version prior to 3.8
https://discuss.aerospike.com/t/records-ttl-and-evictions-for-aerospike-server-version-prior-to-3-8/737



If records TTL is set to zero (never expire) for all data in a namespace and Memory or disk HWM is reached then system will go to stop-writes.
如果namespace中的记录TTL设置为零(永不过期),达内存或磁盘 占用打到 设置的HWM阈值 ,那么系统将停止写入。

HWM 高水位标记 HighWaterMark

If records TTL is greater than zero then Eviction algorithm will use a 100 bucket histogram algorithm to determine what to expire.

如果记录TTL大于0,驱逐算法将使用100桶 分布图算法来确定哪些记录过期。

The bucket width or histogram base unit can be determine by dividing the MAX TTL by a hundred.
桶宽或直方图基本单位可以通过最大TTL除以100来确定。

Bucket_Width = MAX_TTL/100

Note that if within a namespace records have different TTLs set and TTLs fall in different histogram buckets , Aerospike will start evicting data from the lower TTL buckets first.

如果namespace中设置了不同的TTL,并且TTL位于不同的bucket中,将首先从较小的TTL bucket中回收数据。


If all records fall within the same bucket then eviction become random.
如果所有记录都落在同一个桶中,则会随机驱逐。


Info on TTL bucket can be gathered from asinfo.

asinfo -h 127.0.0.1 -p 3000 -v "hist-dump:ns=data-ns;hist=ttl"
requested value  hist-dump:ns=data-ns;hist=ttl
value is  data-ns:ttl=100,41600222,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5100;
Histogram format: NAMESPACE:HISTOGRAM=NUM_BUCKETS,BUCKET_WIDTH,BUCKET_0,BUCKET_1,…

Where:

HISTOGRAM is ttl
NUM_BUCKETS is 100
BUCKET_WIDTH varies based on data the current max Void Time in seconds. Note: Records with indefinite TTLs (TTL = 0) are not represented in ttl or evict histograms.
BUCKET_0 are records between 0 * BUCKET_WIDTH and 1 * BUCKET_WIDTH.
BUCKET_1 are records between 1 * BUCKET_WIDTH and 2 * BUCKET_WIDTH.
…
BUCKET_99 are records between 2 * BUCKET_WIDTH and 100 * BUCKET_WIDTH.
In above example

BUCKET_WIDTH = 4160022 secs


HISTOGRAM is ttl (相当于类型)    分桶算法 各种分布图
桶数
桶宽度


200 records are in bucket 2 and will expire in 4160022 × 3 = 12480066 secs While 5100 records are in the last bucket and will in 4160022 × 100 Algorithm will evict bucket 2 prior to bucket 99. But randomly expire records within bucket 99.
最后一个桶的 5100条记录随机过期

Please see our data retention doc:

http://www.aerospike.com/docs/operations/configure/namespace/retention/ 

and on asinfo at:

http://www.aerospike.com/docs/tools/asinfo/ 

Evictions Algorithm:
Verify that evictions are happening based on these eviction algorithms:

if (default-ttl == 0) || (eviction-period == 0) do not run eviction; otherwise, execute one of the following steps depending of the type of namespace

Namespace with storage engine memory:
If (memory_hwm >= data_sz + index_sz) do not run eviction algorithm; otherwise, run eviction algorithm

Namespace with storage engine ssd (data-in-memory is set to false):
if (memory_hwm >= index_sz) && (ssd_hwm >= data_sz) do not run eviction algorithm; otherwise, run eviction algorithm

Namespace with storage engine ssd (data-in-memory is set to true):
if (memory_hwm >= data_sz + index_sz) && (ssd_hwm >= data_sz) do not run eviction algorithm; otherwise, run eviction algorithm

这里的 && 感觉应该是 || ,达到任何一个条件都会开始逐出 ?

If total size reaches HWM, data may be evicted. Exceptions are:

Records with no TTL specified (in a namespace that has no default TTL) will neither be expired nor evicted. They are excluded from the TTL histograms. We sometimes refer to such records as “zero-void-time” records.
Record with TTL=0 in configuration file (set to never expire) will also be excluded from eviction
Records with TTL set to -1 through AS clients. (Also means record never expires)
All other records will be subject to eviction algorithms

数据大小达到HWM时会触发驱逐,除了以下情况

没有设置 TTL 或者 TTL=0 或 TTL=-1 的记录不会被驱逐

上一篇     下一篇
金融危机十项注意

乌合之众大众心理学中最经典的20句话

2018年简单总结

人工智能AI真香!!!

aerospike3.8及以上版本的数据淘汰机制

aerospike中的过期驱逐和停止写入机制