#recommendations for a simple & scalable notification system?

3 messages · Page 1 of 1 (latest)

silver schooner
#

i'm working on a blog/forum site & about to start on a simple notification system that sends out notifications to followers when an author publishes a post

i was thinking of just creating a little temporary store in my database, creating a notification document with a unique in it, & then appending the id of that document into a follower's notifications list

in code i guess it would look something like

app.post("/", (req, res) => {
  let post = new Post;
  // ...
  await post.save();

  let notification = new Notification;
  // ...
  await notification.save();

  // a queue is definitely more scalable, but just sticking this here to get the point across
  await Users.updateMany(
    { "_id": { "$in": req.user.followers } }, 
    { "$push": { "notifications": notification._id } }
  ).exec();

  return res.send("ok");
});

as stated in the comment above updateMany, i've been thinking about writing a queue to schedule these notifications in batches so that my endpoint doesn't bottleneck & kill the server

but as i think about it, if the amount of users dramatically scales up, would the only other option be to use a dedicated server/service for notifications?

there are just a lot of questions floating around in my head when it comes to scaling the system for potentially hundreds of thousands of users

if you guys have any recommendations or experience, please let me know asap 🙏

low kayak
#

hey arson

#

yes for large scale applications, there is a service that checks the queue