design patterns - How many rows to insert per notification in a notification system? -
following on this question looking @ building similar notification system , have question (which has obvious answer think i'd prefer have other opinions):
if particular post generated million likes, , adds comment post, need notify million people liked post comment added. way achieve write million rows notificationread
table has notificationid
, 'send' them various users?
i can't visualise other approach let me keep track of read notifications , potentially inserting million rows per post per notification sounds daunting , expensive.
is there other way it? using sql server 2014 , application server coldfusion 2016
first off, if need push notifications, there's no escaping fact need somehow notify each of million users. don't need store notifications on server.
one make reasonable assumptions:
- most activity occur on recent posts (say, posts less week old)
- most users not respond notification immediately
with this, can skip storing notifications recent posts: when user logs in, can poll user's recent posts see if there new activity. you're doing work when user logs in spread on time.
for older posts, still fall storing individual notifications each user, shouldn't happen often. here again, instead of inserting new row each notification, choose keep list of last n notifications per user. way, if user doesn't log in long time, you're not piling old notifications (that user doesn't care anyway).
Comments
Post a Comment