Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable19] Allow to group push notifications via an event #651

Merged

Conversation

nickvergessen
Copy link
Member

For notify() this doesn't make any difference for now,
but for markProcessed() it reduces the number of connections drastically.

@nickvergessen
Copy link
Member Author

I think it's worth extending the public api to have this available outside,
because for talk we delete multiple notification types and then send the new call notifications on the start. and that could all be done in one attempt instead of 3 per user like atm.

@nickvergessen
Copy link
Member Author

nickvergessen commented Jun 4, 2020

Before (total notification time 18.362028121948 sec)

{"call":"markProcessed","duration":14.11000394821167,"user":"","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.01212000846862793,"user":"arthur","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.16085410118103027,"user":"barthelemy","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.13795113563537598,"user":"camila","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.23497605323791504,"user":"christoph","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.3176860809326172,"user":"georg","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.15791106224060059,"user":"icewind","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.22125697135925293,"user":"ivan","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.13574504852294922,"user":"jan","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.2843620777130127,"user":"jos","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.17973995208740234,"user":"julius","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.6714599132537842,"user":"marinofaggiana","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.011767864227294922,"user":"mario","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.16736102104187012,"user":"maxence","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.2198801040649414,"user":"morris","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.12984919548034668,"user":"roeland","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.14777588844299316,"user":"tobias","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.1602768898010254,"user":"bjoern","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.16556096076965332,"user":"greta","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.14077210426330566,"user":"marinela","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.00967097282409668,"user":"daniel","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.22638797760009766,"user":"michael","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.1615757942199707,"user":"marco","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.013900041580200195,"user":"Nextcloud","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.15236496925354004,"user":"marija","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.03081798553466797,"user":"kevin","app":"spreed","type":"call","id":"yq2vkcrd"}

After (total notification time 11.468997001648 sec)

{"call":"markProcessed","duration":6.879827976226807,"user":"","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.016108989715576172,"user":"arthur","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.1615159511566162,"user":"barthelemy","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.1563420295715332,"user":"camila","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.16210389137268066,"user":"christoph","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.3264729976654053,"user":"georg","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.17954683303833008,"user":"icewind","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.2435929775238037,"user":"ivan","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.14418292045593262,"user":"jan","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.2585749626159668,"user":"jos","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.1683950424194336,"user":"julius","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.627108097076416,"user":"marinofaggiana","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.03292703628540039,"user":"mario","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.1646571159362793,"user":"maxence","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.26062989234924316,"user":"morris","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.18233299255371094,"user":"roeland","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.1449120044708252,"user":"tobias","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.2237529754638672,"user":"bjoern","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.15462207794189453,"user":"greta","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.15375304222106934,"user":"marinela","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.029803037643432617,"user":"daniel","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.29815006256103516,"user":"michael","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.3036839962005615,"user":"marco","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.015551090240478516,"user":"Nextcloud","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.16412091255187988,"user":"marija","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.016328096389770508,"user":"kevin","app":"spreed","type":"call","id":"yq2vkcrd"}

With talk hack for "start call" (total notification time 8.3450264930725 sec)

{"call":"markProcessed","duration":0.00045299530029296875,"user":"","app":"spreed","type":"room","id":"yq2vkcrd"}
{"call":"markProcessed","duration":0.4759969711303711,"user":"","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.012813091278076172,"user":"arthur","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.016541004180908203,"user":"barthelemy","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.016688108444213867,"user":"camila","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.04747295379638672,"user":"christoph","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.022778987884521484,"user":"georg","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.019840002059936523,"user":"icewind","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.0189821720123291,"user":"ivan","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.0436251163482666,"user":"jan","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.018208026885986328,"user":"jos","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.013883113861083984,"user":"julius","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.011530876159667969,"user":"mario","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.01524806022644043,"user":"maxence","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.014024972915649414,"user":"morris","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.019247055053710938,"user":"roeland","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.017735958099365234,"user":"tobias","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.014232873916625977,"user":"bjoern","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.017943859100341797,"user":"greta","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.024059057235717773,"user":"marinela","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.013537168502807617,"user":"daniel","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.016693115234375,"user":"michael","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.018706083297729492,"user":"marco","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.008783817291259766,"user":"Nextcloud","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.0187070369720459,"user":"marija","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"notify","duration":0.010982036590576172,"user":"kevin","app":"spreed","type":"call","id":"yq2vkcrd"}
{"call":"flush","duration":7.416311979293823}

Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 good stuff! Scaling ftw.

@nickvergessen
Copy link
Member Author

/backport to stable19

@nickvergessen
Copy link
Member Author

/backport to stable18

Copy link
Member

@danxuliu danxuliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested (with a dummy push proxy, not a real one, but it should not make any difference) and works 👍

I was wondering, would it be possible to defer all the notifications and then listen to an event dispatched before the controller is about to send the response to flush the notifications? That way the apps would not even need to explicitly defer and flush them, and all the notifications would be automatically grouped.

In addition to that, even if deferring and flushing is clearly an improvement any request that triggers a notification will "hang" until all the notifications are sent to the push proxies. Would it be possible to send the response and, then, send the notifications to the push proxies? Maybe again with an event that is sent after the response is sent but before the request is ended.

Finally, instead of sending the notifications while the request that created them is running, would it be possible to "detach" the sending and doing it separately? For example, by queueing a background job that starts in the next X seconds. That way the requests would be faster and notifications from different events could be grouped too.

I have no idea if any of the above is possible or the drawbacks that they could have but I am not seeing, but I mention it just in case :-)

@nickvergessen
Copy link
Member Author

Yeah ultimatly that is the goal, unluckily until the response is closed the frontend won't start processing. The answer anyway.

We would need something that processes stuff in parallel afterwards, but we only have 5mins async background jobs which is way too slow. So until that is solved 🤷‍♂️

@nickvergessen
Copy link
Member Author

Since we are going with the deferrable apps in master, this shall be rebased onto 19

For notify() this doesn't make any difference for now,
but for markProcessed() it reduces the number of connections drastically.

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Talk app, good guys, they know what they are doing. Trust me.

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the feature/noid/allow-to-group-push-sending-for-a-while branch from 57fef09 to d54d5db Compare July 8, 2020 13:00
@nickvergessen nickvergessen changed the base branch from master to stable19 July 8, 2020 13:00
@nickvergessen nickvergessen changed the title Group pushing the notifications [stable19] Allow to group push notifications via an event Jul 8, 2020
@nickvergessen
Copy link
Member Author

Rebased on stable19, ready for merge

Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same code we already run right?
So good to go from my point of view!

@nickvergessen
Copy link
Member Author

This is the same code we already run right?
So good to go from my point of view!

Yeah

@nickvergessen nickvergessen merged commit ddba5ec into stable19 Jul 9, 2020
@nickvergessen nickvergessen deleted the feature/noid/allow-to-group-push-sending-for-a-while branch July 9, 2020 09:33
@backportbot-nextcloud
Copy link

The backport to stable19 failed. Please do this backport manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants