How to get record size in Aeropsike

For one of our requirement, we need to get the record size (size taken by record on SSD ). Is there any API in Java client or is possible by Lua UDF to get actual size of record in Aerospike.

The reason we need is that Aerospike has limitation of record size of 1 mb of SSD storage. So we need to find how much space record is currently occupying so that we can split the record in 2 records if size is near to 1 MB.

Please note we do not want to use Large Data Types for this problem as the number of occurrence where record may cross over 1 MB size is not more than 1-2% of total records and we don’t want LDT overhead for 99% records.

On the Value class in the Java API is a method estimateSize(). This can be used to give the approximate size for the value in on bin, and then it’s a simple matter to sum the sizes of all the values in your record.

Note that this method is only approximate – there will be record level overhead (64 bytes for the primary index, overhead for set name, etc. See Capacity Planning for more details.

I’m assuming that if you have such variable data this is stored primarily in lists or maps, and hence the estimateSize() method should do the job for you.

I agree with your approach – do not use LDTs for this use case.

Hope this helps,


Thanks Tim. This was of great help and good to know approach is correct.

We are facing the same problem. But in our case percentage is much larger ~30-40%. We can’t use LList as we are using XDR as well. Should we go with Gagan approach as well i.e splitting records at application level or there is some other way.

@Gagan_Agrawal : How do you manage 2 records with same key and what about version while updating records?

We just append an identifier as a suffix. E.g key_1 and key_2 to split key into 2 keys. Version management is done at split key level.