I’ve a system wherein some knowledge is inserted into database. At any time when that knowledge is inserted subscribers needs to be notified about that (it does not must occur simply after inserting, however there’s a time restrict so I can wait like 10 s after which notify about X variety of knowledge inserted).
Downside is that every subscriber might have a filter. So shall we say that new document was inserted to database and it’s a product of kind: sneakers. I’ve 1 ok of subscribers who’re involved in that so they need to obtain electronic mail with that info however a few of them have filter in order that solely whether it is measurement 10.
What could be one of the best design for that to make it scallable?
Proper now I’ve a course of that retains on searching for new information in database and for every one it iterates via all subscribers looking for out if this consumer needs to be notified and if sure I ship message to the queue with document and subscriber ID in order that one other element will obtain it and ship to that consumer.
This fashion I can have X variety of elements searching for new knowledge and Y variety of elements receiving occasions from queue and sending notifications to customers so it may be scalled out however nonetheless I feel that it’s not the optimum manner for doing that.
Thanks for assist