首页   快速返回

aerospike中的过期驱逐和停止写入机制
文章分类 aerospike
发布时间 2018-12-29 修改时间 2018-12-29
根据原文翻译整理

FAQ What are Expiration, Eviction and Stop-Writes
https://discuss.aerospike.com/t/faq-what-are-expiration-eviction-and-stop-writes/2311



expiration eviction  stop-writes
过期 逐出 停止写入


Expiration
Expiration is a normal process within Aerospike when TTL has been set to a positive integer 
(records with no TTL or TTL of 0 or -1 are not included in expiration or eviction). 
Unless a client sends an override, the TTL used for a write will be the default TTL for the namespace. 
When a record is written the server takes the TTL (either the default or that specified by the client)
and adds it to the current time to get the expiration time. 
When a record hits its expiration time the Namespace Supervisor will expire it, meaning it is removed from the cluster.
An update or a touch from a client will reset the expiration time as if it were a new write. 
Reads will not affect expiration time. 
The namespace supervisor (NSUP) thread manages both evictions and expirations.
NSUP does not run all the time, instead it runs periodically. The time interval at which NSUP wakes up is the nsup-period

TTL 为0或-1的记录不会过期或逐出
TTL 客户端主动设置,否则使用namespace的默认TTL配置
update和touch操作会更新TTL
NSUP (namespace supervisor) 线程 负责 过期 和 逐出操作。
NSUP线程周期运行, 时间间隔通过  nsup-period 参数设置

It is possible to throttle NSUP by altering the time interval for which it sleeps between generating delete transactions. 
The parameter used to do this is nsup-delete-sleep. In configurations with multiple namespaces and with large number of records, 
it is actually not uncommon for nsup to take longer then the nsup period to complete a cycle, 
especially if expirations, evictions or set-deletes are active.

可以通过更改NSUP在生成delete事务之间休眠的时间间隔来限制NSUP。用于此操作的参数是nsup-delete-sleep。
在具有多个名称空间和大量记录的配置中,nsup实际上比nsup周期更长的时间来完成一个周期并不少见,特别是在过期、回收或删除处于活动状态时。

NSUP线程清理数据生成delete 事务, nsup-delete-sleep 可以配置删除操作时间间隔

It may be useful to throttle NSUP so that transaction queues are not overloaded with deletes generated by NSUP.
对NSUP进行节流可能很有用,这样事务队列就不会因为NSUP生成的删除而超载。

A touch operation will typically update / reset the TTL of the record. 
touch 操作用于更新或重置TTL

Let’s assume the default-ttl in the server config is set to 30D for the namespace.
Client writes a record with a 10D TTL.
5 days later, the client does a touch operation without setting a TTL.
The record will now have a TTL of 30D which is the default-ttl on the server side will expire 30 days from this point.

假设服务端设置默认TTL为30天
客户端写入数据并设置TTL 10天
五天之后 ,客户端执行不带TTL的touch操作
这条记录的TTL变为30天

Eviction
Eviction is when records are removed before their expiration time. 
Only records where TTL is set to a positive integer will be affected by evictions. 
Eviction starts when a High Water Mark (either disk or memory) is breached. 
It is particularly important to understand the role of bucket width in eviction as this explain which data will be evicted first.

逐出发生在记录过期之前,只有TTL大于0的记录才会被逐出
逐出在 内存或磁盘空间到达高位水时触发
尤其重要的是要理解桶宽在回收中的作用,因为这将解释首先回收哪些数据。

Stop-Writes
A database hits stop-writes=true when either of the following conditions are met:
停止写入在以下任意情况满足时触发

Stop-write-pct is exceeded. This refers to RAM and stops the system running out of memory. 
Stop-write-pct超过。这是指RAM,它可以阻止系统耗尽内存。

This parameter is active even when SSDs are used as Aerospike always uses RAM for indexes.
索引永远放在内存中
http://www.aerospike.com/docs/reference/configuration/#stop-writes-pct 

min-avail-pct relates to the minimum available amount of space on SSDs 
min-avail-pct 与ssd上的最小可用空间有关
and refers to the minimum free blocks available for writing across all SSDs associated with a given namespace. 
This should never be lowered to less than 5%.
http://www.aerospike.com/docs/reference/configuration/#min-avail-pct

As the name suggests stop-writes=true indicates that the database will be in a read only mode until both of the conditions listed above are false.
 
 Though the database will not accept writes, deletes will still be processed. 
 Replica writes as well as migrations related writes will also be processed.
 
 写入不会被处理,删除任然可以被处理,副本和迁移相关的写入仍然可以被处理
 
 

It follows from the above that if disk HWM is set sufficiently high then a database could hit stop-writes without evictions being triggered. 
This may be appropriate for a given use case however the interaction of when eviction and stop-writes are triggered should be considered carefully. 
Both of the parameters listed above can be changed dynamically.

从上面可以看出,如果磁盘HWM设置得足够高,那么数据库就可以在不触发逐出的情况下进行停止写操作。
这可能适合于给定的使用场景,但是应该仔细考虑何时触发驱逐和停止写的交互。
上述两个参数都可以动态更改。




Key Points:
Expirations are a normal part of Aerospike operation.
过期是正常操作的一部分
Evictions are a way of managing database behaviour when nearing maximum capacity.
逐出是在接近容量时管理数据库的一种方法
Stop-writes are another tool for managing behaviour near maximum capacity.
停止写入是管理接近最大容量的行为的另一个工具。
Only records where TTL is set to a positive integer can be evicted.
只有将TTL设置为大于0的记录才能被删除。
It is possible for a database to be at stop-writes=true without evictions being triggered.
数据库有可能在stop-write =true时不触发驱逐。
When databases start evicting and going into stop-writes can be controlled and should be implied from the user use case.
逐出和停止写入的时间可以控制,根据实际使用场景来确定。

上一篇     下一篇
Aerospike3.8之前版本的TTL和驱逐机制

人工智能AI真香!!!

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

aerospike数据逐出与停止写入相关参数

2018年度最让人尴尬的新闻

史上最牛逼的幸福公式