I have a riak cluster set up with 3 servers. I can look at the bitcask to establish how much disk space this cluster is currently using but I’d also like to find out how many items are currently being stored in the cluster.
The cluster is being used to store images, meaning that binary data is being stored against a key in a set of buckets. I have tried to use map reduce functions against the HTTP interface in order to return the number of items in the bucket however they have timed out.
What is the most time optimised way to get the count of the number of keys from a specific bucket?
Counting the number of keys in a bucket on the Riak cluster is not very efficient, even with the use of the MapReduce functions.
The most efficient way I have found to count the number of items is to do it on the client through the streaming API. The following example uses node-js to do this.
First install the riak-js client
Then run the following on the command line to give you your count.