Sample Header Ad - 728x90

Implementating user notifications list using Aerospike

3 votes
2 answers
367 views
I need to choose the right DB for a notifications system that needs to handle billions of notifications. The record structure is as follows: [user_id, item_type, item_id, created_at, other_data] The inserts are going to be in bulks up to hundreds of thousands at spikes. And it needs to support thousands of selects per minute of this kind: select * from user_notifications where user_id=12345 order by created_at limit 10 select * from user_notifications where user_id=12345 and item_type='comment' order by created_at limit 10 --- and for the pagination next page: select * from user_notifications where user_id=12345 and item_type='comment' and created_at>'2020-11-01 10:50' order by created_at limit 10 It should also allow quick updates and deletes and ideally have TTL on each record. Right now it's implemented using MySQL, we only have 400M rows and it's already slow as hell. And bulk cleanup is just impossible. Initially, I thought ScyllaDB/Cassandra is ideal for that. If I set the primary key to be [user_id, item_type, item_id] (user_id being the partition key) for inserts/updates/deletes and [user_id, item_type, created_at] as secondary index. CQL seems straightforward in this case and it should work fast (correct me if I'm wrong). The problem is that we are Ruby-On-Rails based and there's no good ruby client library for that. The one listed in the ScyllaDB clients' list (https://github.com/datastax/ruby-driver) is in maintenance mode and I'm not sure it will be updated with new Ruby versions, etc. Recently, I heard about Aerospike and their benchmarks look really cool, but I couldn't figure out how to implement the above requirement using Aerospike's architecture. Especially as their secondary index seems to be always in memory which makes it impossible to index billions of rows. This notifications schema seems to me like something very common, but still, I couldn't find a good article describing all the ideal ways to implement it. Any suggestions are welcome. Thanks
Asked by Kaplan Ilya (173 rep)
Dec 2, 2020, 10:15 PM
Last activity: Dec 3, 2020, 06:44 PM