I am implementing a similar feature like the StackExchange Inbox and I have many considerations about the resource usage.
My system has inbox messages, system health notifications and Achievements. On each page request I am querying the DB if there are any notifications from all these three resources (2 tables and one complex query).
To save some resources I am using Redis Cache to cache the notifications response
IEnumerable<NotificationModel> for 10 minutes. That way I don't have to query the DB too often but I might have to wait 10 minutes to get the latest Notification.
While this works and I suppose won't hurt my Server I feel that it must be a better solution because:
- Redis doesn't work well with large objects and my notification list contain all the information that might got large enough.
- StackExchange does this better with instant notifications (maybe using SignalR)
- Querying three tables, even every 10 mins, is a waste of resources.
- I don't have the viewed state that hides the bubble notification, the one it shows about the new messages that haven't been read.
I suppose I should create a new table that will store all the notifications and I should query only that.
Maybe add a column that let me know if some of the messages are new and the rest are already read.
Store at the Redis Cache only the number of the new notifications and not the actual messages, use Ajax to show the notification only when the user request it(click on the notification icon).
What do you think about this? Have you implemented anything similar?