ARSON
ARSON
Explore posts from servers
TTCTheo's Typesafe Cult
Created by ARSON on 2/17/2023 in #questions
recommendations for writing a simple & scalable notification system?
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");
});
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 🙏
1 replies
TTCTheo's Typesafe Cult
Created by ARSON on 2/14/2023 in #questions
chrome -internal-autofill-selected
1 replies
TTCTheo's Typesafe Cult
Created by ARSON on 2/1/2023 in #questions
tips on getting file sizes down in a nextjs 13 project?
1 replies
TTCTheo's Typesafe Cult
Created by ARSON on 1/6/2023 in #questions
chrome rendering fuzzy bold fonts
4 replies