# If I only use memory to store all data, need I keep each record less than write-block-size?

**URL:** <https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169>\
**Category:** How Aerospike Works\
**Created:** [May 17, 2017, 8:33am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169 "2017-05-17T08:33:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![RockyTu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rockytu/32/785_2.png) [@RockyTu](https://discuss.aerospike.com/u/RockyTu)\
**Post date:** [May 17, 2017, 8:33am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/1 "2017-05-17T08:33:15Z")

</div>

If I don’t persist data to SSD or HDD, only in memory, can I make record larger than wirte-block-size? If so, what about the index and secondary index, still need 64 bytes for primary index?

---

<div class="post-metadata">

**Author:** ![Albot](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/albot/32/2076_2.png) [@Albot](https://discuss.aerospike.com/u/Albot)\
**Post date:** [May 18, 2017, 1:59am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/2 "2017-05-18T01:59:48Z")

</div>

You don’t have a write-block-size if you’re all in memory. That setting goes under the storage-device section. If you have no storage device, then you have no size limitation… Yes, you still have the overhead of 64bytes per record. Additional sizing information/overhead per record and secondary index sizing is all outlined here, and applies the same to in-memory db. [http://www.aerospike.com/docs/operations/plan/capacity](http://www.aerospike.com/docs/operations/plan/capacity)

---

<div class="post-metadata">

**Author:** ![RockyTu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rockytu/32/785_2.png) [@RockyTu](https://discuss.aerospike.com/u/RockyTu)\
**Post date:** [May 18, 2017, 5:28am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/3 "2017-05-18T05:28:27Z")

</div>

if so, I cannot persist them into disk. But they can store in memory all the time until cold start, right?

---

<div class="post-metadata">

**Author:** ![pgupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pgupta/32/2351_2.png) [@pgupta](https://discuss.aerospike.com/u/pgupta)\
**Post date:** [May 18, 2017, 5:56am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/4 "2017-05-18T05:56:23Z")

</div>

Data in memory is stored in process RAM in both Community and Enterprise Edition. If the process is stopped, you will lose the data on that node. If you have a replica in the remaining cluster, it will replicate and you will again and have a master and replica in the remaining cluster - assuming you have enough RAM in the remaining cluster. When the node joins back in, data will be replicated back into it from the cluster per the new partition map, partition by partition.

However, if you have a namespace that specifies single-bin records stored as data in memory, plus if the bin type is integer or float, then you can additionally specify data-in-index in the namespace configuration. The bytes in Primary Index that are used to point to the data location in memory are then used to store the data itself. _That means, in Enterprise Edition, where PI is stored in linux shared RAM, if the process is stopped and restarted, you don’t lose the data in case of single-bin, data-in-memory, data-in-index, data type integer or float._

---

<div class="post-metadata">

**Author:** ![RockyTu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rockytu/32/785_2.png) [@RockyTu](https://discuss.aerospike.com/u/RockyTu)\
**Post date:** [May 18, 2017, 9:23am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/5 "2017-05-18T09:23:47Z")

</div>

My requirement is to store larger than 1MB record into RAM, and everyday remove all data, the next day, store new data again, so the RAM is enough and the way is like memory-cached. The data structure is normal, for example one record with multiple bin, one set has many records. I know the write block size is not applied to memory store. But is there any shortcoming or key point for this solution ?

---

<div class="post-metadata">

**Author:** ![pgupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pgupta/32/2351_2.png) [@pgupta](https://discuss.aerospike.com/u/pgupta)\
**Post date:** [May 18, 2017, 2:54pm UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/6 "2017-05-18T14:54:27Z")

</div>

Are you planning to do scans and secondary index queries?

---

<div class="post-metadata">

**Author:** ![RockyTu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rockytu/32/785_2.png) [@RockyTu](https://discuss.aerospike.com/u/RockyTu)\
**Post date:** [May 24, 2017, 1:30am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/7 "2017-05-24T01:30:50Z")

</div>

Yes, I want to store all data in RAM, but use it like normal, multiple bins, sets, and secondary indexes, I want to jump out 1 MB limitation, I would like to know if this solution has any cons ?

---

<div class="post-metadata">

**Author:** ![Albot](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/albot/32/2076_2.png) [@Albot](https://discuss.aerospike.com/u/Albot)\
**Post date:** [May 24, 2017, 1:45am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/8 "2017-05-24T01:45:02Z")

</div>

I think the only con is that you are dealing with larger chunks of data, and of course the cost of memory…

---

<div class="post-metadata">

**Author:** ![pgupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pgupta/32/2351_2.png) [@pgupta](https://discuss.aerospike.com/u/pgupta)\
**Post date:** [May 24, 2017, 4:58am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/9 "2017-05-24T04:58:04Z")

</div>

I believe Secondary Index queries and scans results send data in 1 MB buffers. Hence I asked if you would be running those. I would explore that aspect further. May be the server allocates larger buffer on the heap instead of using pre-allocated buffers in case record size is greater than 1MB in RAM.

---

<div class="post-metadata">

**Author:** ![RockyTu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rockytu/32/785_2.png) [@RockyTu](https://discuss.aerospike.com/u/RockyTu)\
**Post date:** [May 24, 2017, 6:53am UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/10 "2017-05-24T06:53:07Z")

</div>

yes, I see you concern now, thanks.

---

<div class="post-metadata">

**Author:** ![pgupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pgupta/32/2351_2.png) [@pgupta](https://discuss.aerospike.com/u/pgupta)\
**Post date:** [May 24, 2017, 6:25pm UTC](https://discuss.aerospike.com/t/if-i-only-use-memory-to-store-all-data-need-i-keep-each-record-less-than-write-block-size/4169/11 "2017-05-24T18:25:56Z")

</div>

And if you start moving larger chunks of data, network transfer may become a latency bottleneck. It may be self defeating.
