We are building a notification service whose work is to send push notification to end user. There are two types of notifications
Group notification where we send same text notification to all user's in a group. This is easily achievable as everyone subscribe to a group and we send a notification to a group.
Personalised notification where we send specific text notification to each user.
My question is (for Personalised notification) how best should we architect our notification service.
Approach 1: Do we keep logic of selecting users based on app logic on application service where we create message for each user and then send batches of users with message to notification service to send them?
Select Users based on application logic (on app server) -> Loop over each user and make their custom message (on app server) -> Make batches of 1K users with message and send to notification service (on app server) -> Send notification (Notification service)
- Adds load on application server
Approach 2: we let notification service directly access app database and fetch users, create their message and send them?
Select users -> Loop over to make message -> Send to each user (All on notification service)
- In this approach, notification service need to access app DB and lot of app logic go here, seems not right. As it will make notification service contains lot of app logic.
- Take load off app server as everything needs to be done by notification service.
What do you guys suggest? Is there any other approach we can consider. Considering we might need to send personalised notification to million users.