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.
- User A posts some content, for the sake of argument a blog.
- User B comes along, reads the blog and 'follow's it.
- User A needs to be notified that the blog has been followed.
- 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,
- User A posts some content.
- Users B through X all 'like' that content.
- 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.