How to implement Instant Notifications to ‘follow’ or ‘like’ nodes?

My employer has a social intranet site with 1000s of users, groups, communities and blogs. Users are free to ‘follow’ or ‘like’ nodes, blogs and other users, subscribe to communities, join groups etc.

What I’m trying to achieve is the following.

  1. User A posts some content, for the sake of argument a blog.
  2. User B comes along, reads the blog and ‘follow’s it.
  3. User A needs to be notified that the blog has been followed.
  4. User B needs to be notified in the future that the blog has changed, been added to, modified or even simply ‘like’d by another user.

This is all good with small numbers of people involved. However, as mentioned earlier, there are 1000s of people on this site. When a lot of users follow a blog or ‘like’ something, they all need to be informed of the update and it is here that I’m having the problem. The regular nodeJS module for Drupal seems to blanket broadcast to every active session on the site at that moment, and let Drupal figure out who needs to be told but the load on the server is massive as most of the notifications are unnecessary.

I’ve had a look at the Actions NodeJS module as well which at first glance seemed to be absolutely ideal as I know I can tell it to just get a list of the users who are followers, loop through each one and tell them that something has happened. The problem with this lies in that the initial event, ‘like’ing something for example, does not complete until everyone has been notified so the system hangs until exit.

For example,

  1. User A posts some content.
  2. Users B through X all ‘like’ that content.
  3. User Y comes along and ‘like’s it as well.

Users A through X all get told that User Y has liked it but the ‘like’ operation from User Y’s point of view does not complete until the last person has been notified. Again, this is not so much of a problem with a handful of users, but with possibly 1000s this becomes an issue to be dealt with now. If it’s just an implementation issue and you know how to solve this, shout up.

Some ‘back of a crisp packet’ calculations say that the slow part of the process is the looping through of all the relevant users. Accessing the database to get the list of relevant UIDs is pretty quick as is the sending of the actual message.

Am I looking at writing some custom code to handle this? Am I going to be better off handing the work to a separate thread to process the notifications? Is this even possible? Does a module exist already that can perform this task efficiently? This is greenfield by the way. Anything will be considered for this task as performance on the site with the current implementation is 100% toilet. It may be that the current implementation is flawed and the existing modules are perfectly capable of accomplishing this, this is a real possibility. However, from what I’ve read, I don’t think that this is the case.

I don’t want to blanket broadcast to the site and let Drupal sort out who needs to see the notification as that means many unnecessary hits on the server but if that’s how things are supposed to work, please let me know. I’d much rather just target a list of users and hit them, that seems to me to be the better way forward. All hints, tips, ideas and suggestions are welcome. The NodeJS module allows a system-wide broadcast which is pretty much instant across all open sessions. What I’d love is to be able to harness that performance but with a targeted list of UIDs.

Other info you may need to know.

  • I have a dedicated Node JS server at my disposal
  • The main Drupal site has 3 web heads but only using 1 at the moment for testing. Usual behaviour is ’round robin’ned across the 3 servers.
  • The site is hosted on a private network
  • No anonymous users allowed; everyone has to log in to use the site so everyone has a UID.
  • PHP v5.3.3
  • Drupal v7
  • NodeJS v0.10.36

Upgrading the software isn’t really an option but if it absolutely 100% can not be accomplished any other way, then it becomes an issue for discussion for those on a higher pay grade to me. I’ve already said that I think things should be upgraded, particularly NodeJS, but there is definite resistance to this, don’t ask me why.

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

How to implement Instant Notifications to ‘follow’ or ‘like’ nodes?

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.