# How Aerospike write data into disk

**URL:** <https://discuss.aerospike.com/t/how-aerospike-write-data-into-disk/844>\
**Category:** General Discussion\
**Created:** [January 16, 2015, 12:54pm UTC](https://discuss.aerospike.com/t/how-aerospike-write-data-into-disk/844 "2015-01-16T12:54:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Job](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@Job](https://discuss.aerospike.com/u/Job)\
**Post date:** [January 16, 2015, 12:54pm UTC](https://discuss.aerospike.com/t/how-aerospike-write-data-into-disk/844/1 "2015-01-16T12:54:58Z")

</div>

Hi All,

When did Aerospike flushed data written into memory of all replica nodes into disk. If the write process to disk is eventual, how did aerospike tolerate during cluster failure, since there is no log mechanism as like Cassandra does

---

<div class="post-metadata">

**Author:** ![lucien](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/lucien/32/2065_2.png) [@lucien](https://discuss.aerospike.com/u/lucien)\
**Post date:** [January 20, 2015, 1:56am UTC](https://discuss.aerospike.com/t/how-aerospike-write-data-into-disk/844/2 "2015-01-20T01:56:47Z")

</div>

Please see this post that covered the subject:

> [@The interval to flush changed data from memory into disk?](https://discuss.aerospike.com/t/the-interval-to-flush-changed-data-from-memory-into-disk/163):
>
> by Hanson » Thu Jul 24, 2014 8:02 pm I’m using Aerospike 3.3.8 In-Memory with disk Persistence. I tried to insert a new record, and checked the persistence data file, but found the timestamp of it has not been changed after I have inserted that record for a long time. Seems Aerospike will not flush changed data from memory into disk if the buffer is not full. Shouldn’t also flush changed data from memory into disk per time interval? e.g.: either buffer is full or interval \> 1 second since la…

---

<div class="post-metadata">

**Author:** ![raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@raj](https://discuss.aerospike.com/u/raj)\
**Post date:** [January 20, 2015, 4:22am UTC](https://discuss.aerospike.com/t/how-aerospike-write-data-into-disk/844/3 "2015-01-20T04:22:19Z")

</div>

Two new config parameters to control this are

**flush-max-ms:** This is number of millisecond server waits before it flushes unfilled buffers. default is 1000ms this can set using command

> asinfo -v ‘set-config:context=namespace;id=test;flush-max-ms=1’

**fsync-max-sec:** In case of raw device open is called with O\_SYNC so every write is flushed to the storage given we deal with our own page size. In case of using filesystem this governs the rate at which file gets synced. Default is 0 i.e never sync. It can be set using command

> asinfo -v ‘set-config:context=namespace;id=test;fsync-max-sec=1’

Changing this may increase your io bandwidth requirements.

Aerospike has

1. Is log structure on storage
2. Does sync replication

It means last committed copy is always safe and the writes make to the write buffer on master and all the replica nodes before write is acknowledged to the user.

There is still a window where data can be lost e.g in case of entire cluster failure, ofcourse there are ways around it by doing Rack Aware replication or doing Cross DC replication. Only way to close this window would be to perform sync data or log flush to the storage (this is assuming storage is reliable enough) but this would be highly detrimental to performance.

Most of NoSQL data bases _DOES_ _NOT_ perform sync log or data flush including Cassandra which does aysnc commit log flush and has `commitlog_sync_period_in_ms` set to 10 seconds by default.

HTH – R
