Notifications - Is This Too Much

Posted on 2012-09-04
Last Modified: 2012-09-22
Hi, i am in the process of building a custom site in php. I am designing the user's notification settings and i am trying to decide on what options the user can check and uncheck in their settings. (please do not suggest open source software as this site needs to be custom for many reasons ;)

i have added the following setting, and i am trying to decide whether to leave it their or not:

[ ] email me when another member comments on the same post

I am aware that some posts will have 500+ individual comments so that means that if all of the users have the above option selected, the system will need to send out 500+ emails to all of the users, everytime someone adds a new comment.

Would this slow down my system or is PHP well able to cope with these type of functions these days... thanks in advance for your help...
Question by:oo7ml
    LVL 12

    Assisted Solution

    One of the forums I visit emails me the first time somebody responds to a thread, and there is a notice in the email stating that subsequent responses won't generate another email alert until after I have visited the thread again.  Once I visit the tread again, then I will get another alert the first time there is another comment again.

    This way you would know there is at least one new comment to go look at, but you wouldn't get inundated in notification emails for 500 comments.

    Author Comment

    Yeah, i think most forums operate that way... not sure what to do here...
    LVL 34

    Accepted Solution

    1. Most forum posts are not going to be followed by 500 people. Even popular forums for commercial video games don't get that kind of thread subscription traffic for most of their forum posts. By the time you do get the kind of traffic that generates explicit opt-ins from 500 people on the same thread, you'll probably be faced with bigger hardware and performance problems and will be considering the best load-balancing option.

    2. Don't try to process notifications on the submission of a new thread reply. Break it up into three parts:
    A. When a user creates a new reply / post, have a "processed" flag in the database record set to false.
    B. Have a separate cron job running every minute that looks for "unprocessed" records and determines who needs to be notified about them, and then updates those records to be "processed" so they don't get looked at again by the next run. Have that job simply populate a queue in the database "notifications_to_send" . That way, this job can run in under a minute and keep up with new posts.

    3. Have another job that runs every minute or two that simply pulls the next 100-500 (or however many emails your server can handle in 60 seconds), remove them from the queue (to prevent race conditions), and then mail them all out.

    Using this approach, you'll be able to scale much better. Even if you start to become too busy to process everything right away, the queue system will let you fall behind and catch up when the traffic goes back down. You'll also be able to visualize when you need new hardware or need to add load-balancing.

    It's also easy to add additional code to do parallel processing of the queue by adding mailing jobs (e.g. create a new job, lock the table, pull the records, update them to "claim" them for that mailing job, then unlock the table so the next parallel job can grab the next batch). You might be surprised at how many notifications you can blast out using this approach.

    Author Comment

    Wow, cool, will need to read this again later, thanks for the detailed approach...
    LVL 107

    Assisted Solution

    by:Ray Paseur
    You might consider the timeliness of the comments.  During the first day after a post, sending a notification summary every hour for new comments might make sense, then during the first week a notification a day might make sense, etc.

    Hello, Joe.  Here is your summary of comments.  27 comments have been added recently. Follow this link to see the comments...

    Just a thought, ~Ray

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Creating and Managing Databases with phpMyAdmin in cPanel.
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now