In a Feeds architecture(like Facebook news or Twitter), how to make the feeds counts consistent with the feeds lists' length? -
i designing feeds system, 1 can post news, , others can see each other's news, twitter.
now i'm saving news in hbase, , cache them in redis. approach has o(1) insert, update , remove, "count" hard achieve:
if save separate count in redis, , increasing/decreasing upon insertion/removal, value can not consistent real list length in hbase: 1 single failure on network or other exception can make value wronged.
if count hbase, it's time consuming.
what design choice should make?
hbase provides support atomic counters: instead of maintaining count in redis , relying on multiple system can use hbase (in real-time).
just insert post, , if went ok, increment counter. can have multiple counters track total posts + posts per day, week, month, year... it's powerful feature.
for more info hbase book has few pages dedicated counters, also, can check increment example.