?
Solved

Notifications - Is This Too Much

Posted on 2012-09-04
5
Medium Priority
?
476 Views
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...
0
Comment
Question by:oo7ml
5 Comments
 
LVL 12

Assisted Solution

by:Seaton007
Seaton007 earned 600 total points
ID: 38365441
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.
0
 

Author Comment

by:oo7ml
ID: 38365454
Yeah, i think most forums operate that way... not sure what to do here...
0
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 800 total points
ID: 38365546
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.
0
 

Author Comment

by:oo7ml
ID: 38367781
Wow, cool, will need to read this again later, thanks for the detailed approach...
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 600 total points
ID: 38372386
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
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
The viewer will learn how to dynamically set the form action using jQuery.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

839 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