I have a node js site on local system where user is notified for trending articles or post by email. My code works like :-
app.get('/:articlename', (req, res)=>{
conn.query(`SELECT views,isAlreadySent FROM article_table WHERE article_name='${req.params.articlename}'`, (err, results, fields)=>{
// if views greater then 5000 views and isAlreadySent is false then send email to subscribed user from database
})
});
The above code is long I am showing you guys shorter version. Everything works fine. My code is that when any user views any article it triggers email sending method and if that article have views more than 5000 then it's email will be sent to all subscribed users but the subscribed user can be thousands so how can I send email to all subscribed user without lagging the current viewer
I want to make user notified like pinterest, medium notifies millions users by mailing
I mean when any user request the article page a block of code will check the views and if views greater then something then an email will be send to multiple users. Number of users can be large and if I sent email at the time when user request the article then it can be unusual delay for that user. I want that if views are greater then something then it should post any bool value to another program and that program should email to all behind the scenes without disturbing the user or it can be done by any other trick please tell