Resource icon

Deferred Alerts for XF1 [Paid] 1.0.0

No permission to buy ($30.00)

Xon

Well-known member
Xon submitted a new resource:

Deferred Alerts for XF1 - Send alerts/emails later (by seconds)

Designed for when large volumes of alerts and emails are send out on content updates.

It uses the XF deferred system to push alert & email notifications into a new request. This can dramatically reduce memory usage and ensures the large volume of alerts & emails being sent to not impact the original poster.

Note; this has been a private add-on for ~6 months and had worked well on https://forums.spacebattles.com

Supported content types
  • Watched Threads replies.
  • Watched Forums, new threads/replies.
  • XenForo Resource Manager
    • ...

Read more about this resource...
 
Last edited:
Why this was implemented:
unknown.webp
(Thread Starter Post + Thread Starter Alerts + 1k watchers on a thread = lots of notifications)
 
Last edited:
How can I test and verify it works as expected?

I have user1 with an existing thread1.
I created user2 and replied to thread1 as testing.

Right after I posted as user2, I reload the page for user1 then I instantly receive an alert.
I did it multiple times and it works that way always.
Alerts are sent instantly.

Deferred means it must be late to alert user1 right?
 
Deferred means it must be late to alert user1 right?
No, it means they'll be processed in the background. It's more aimed for threads that have a significant number of watchers to be alerted.

Without this add-on, replies on threads like that would cost a fair bit of memory and the user replying would see a delay until all alerts are processed. This add-on mitigates that by pushing alert tasks to the background.
 
  • Like
Reactions: rdn
Right after I posted as user2, I reload the page for user1 then I instantly receive an alert.
I did it multiple times and it works that way always.
Alerts are sent instantly.
If you open up your browser debugger tools, you'll see a deferred.php call occur right after you post. This kicks off the notifications.

You can look at the tables; xf_thread_watch_pending and xf_forum_watch_pending to see estimated maximum possible recipients and people number of users actually sent to.

For example;
SQL:
select xf_thread_watch_pending.post_id, thread_id, sent, estimated_count, from_unixtime(start_time) as start_time, (end_time- start_time) as duration
from xf_thread_watch_pending
where from_unixtime(start_time) > '2017-08-01'
order by sent desc
limit 4;

select xf_thread_watch_pending.post_id, thread_id, sent, estimated_count, from_unixtime(start_time) as start_time, (end_time- start_time) as duration
from xf_thread_watch_pending
where from_unixtime(start_time) > '2017-08-01'
order by duration desc
limit 4;

In the last ~25 days;

# post_id, thread_id, sent, estimated_count, start_time, duration
'38156997', '512524', '4224', '4356', '2017-08-13 01:14:11', '35'
'38068269', '512524', '4206', '4310', '2017-08-10 16:11:30', '36'
'38377777', '517894', '4006', '4047', '2017-08-19 12:20:57', '80'
'38219838', '517894', '3999', '4044', '2017-08-14 20:44:55', '31'

# post_id, thread_id, sent, estimated_count, start_time, duration
'38215068', '395276', '6', '141', '2017-08-14 18:18:46', '94'
'38377777', '517894', '4006', '4047', '2017-08-19 12:20:57', '80'
'37994409', '420746', '24', '153', '2017-08-08 13:00:43', '68'
'38494306', '517894', '3767', '4057', '2017-08-22 22:13:17', '67'

And yes, that really is several threads with over 4000 watchers that take between 30 seconds to over a minute to notify

The important thing is the duration column; sure it is spread over multiple deferred.php requests, but you need roughly the same order of magnitude when someone posts a reply which triggers huge numbers of notifications.

No, it means they'll be processed in the background. It's more aimed for threads that have a significant number of watchers to be alerted.
And when you have Persistent Alerts and Thread Starter Alerts setup and have thousands of people being alerted at once.
 
  • Like
Reactions: rdn
For a 327 pages thread reply.
1503604202265.webp


399 pages thread reply.
1503604282424.webp

I guess it works as expected.

Thanks a lot for the explanation.


Edit: On test site I got without this addon I still see the deferred.php call right after I post reply.
 
Last edited:
You can look at the tables; xf_thread_watch_pending and xf_forum_watch_pending to see estimated maximum possible recipients and people number of users actually sent to.
I got this:
1503605060101.webp

1503605121763.webp

Max so far was 487 subscribers and 16 seconds.
 
Part of the issue is the push notifications hold the worker around until it finishes. Really XF needs a background task runner rather than relying on job.php

Try these add-ons;

For large jobs it is more aggressive about pushing stuff into the deferred jobs system, and then run the jobs via the CLI system. This may help spread the load out.
 
  • Like
Reactions: rdn
Back
Top Bottom