I will describe the data and case.
record {
customerId: "id", <---- indexed
binaryData: "data" <---- not indexed
}
Expectations:
- customerId is random 10 digit number
- Average size of binary record data - 1-2 kilobytes
- There may be up to 100 records per one customerId
- Overall number of records - 500M
- Write pattern #1: insert one record at a time
- Write pattern #2: batch, maybe in parallel, with speed of at least 20M record per hour
- Search pattern #1: find all records by customerId
- Search pattern #2: find of all records by customerId group, in parallel, at a rate of at least 10M customerId per hour
- Data is not too important, we can trade some aspects of reliability for speed
- We suppose to work in AWS / GCP - it's best we key-value store is administered by the cloud
- We want to spend no more that 1K USD per month on cloud costs for this solution
What we have tried:
We have this approach implemented in relational database, in AWS RDS MariaDB. Server is 32GB RAM, 2TB GP2 SSD, 8 CPU. I found that IOPS usage was high and insert speed was not satisfactory. After investigation I concluded that due to random nature of customerId there is high rate of different writes to index. After this I did the following:
- input data is sorted by customerId ASC
- Additional trade was made to reduce index size with little degradation of single record read speed. For this I did some sort of buckets where records 1111111185 and 1111111186 go to same "bucket" 11111111. This way bucket can't contain more than 100 customerIds so read speed will be ok, and write speed improves.
Even like this, I could not make more than 1-3M record writes per hour. Different write concurrencies were tested, current value is 4 concurrent writers. After all modifications it's not clear what else we can improve:
- IOPS is not at the top use (~4K per second),
- CPU use is not high,
- Network is not fully utilized,
- Write and read throughputs are not capped.
Apparently, ACID principles are holding us back. I am in look for flatly scalable key-value store and will be glad to hear any ideas and roughly estimations.