Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-12630 Adding debounce to prevent client breaking for very high rate channels. #2041

Merged
merged 1 commit into from
Nov 20, 2018

Conversation

crspeller
Copy link
Member

Adds a queued denounce function to websocket event handling for new posts. This is an attempt to prevent very high rate channels from breaking the client by overloading it with posts.

@crspeller crspeller added Setup Old Test Server Triggers the creation of a test server 3: QA Review Requires review by a QA tester labels Nov 14, 2018
@mattermod
Copy link
Contributor

Setup Test Server label detected. Spinmint test server created if build succeeds (checks pass and no conflicts with base branch).

@mattermod
Copy link
Contributor

Spinmint test server created at: https://i-0f957e01030fc6a87.test.spinmint.com

Test Admin Account: Username: sysadmin | Password: sysadmin

Test User Account: Username: user-1 | Password: user-1

Instance ID: i-0f957e01030fc6a87

@crspeller
Copy link
Member Author

@lindy65 Can you take a look at this? Should be able to test this with /test posts like we discussed before.

@lindy65
Copy link
Contributor

lindy65 commented Nov 14, 2018

@crspeller - yep, will test this today using /test posts :)

@lindy65
Copy link
Contributor

lindy65 commented Nov 14, 2018

Hey @crspeller

Tested by enabling Developer Test Commands in System Console and using /test posts 100 ten times in a row. The channel broke.

image

Then tested /test posts 75 ten times in a row and the channel still broke.

image

Adding ten times /test posts 50 in a row didn't break the channel but I continued to 13 times and it broke on the twelfth post of /test posts 50

image

I am posting these test post commands very quickly one after the other with no pause inbetween so am not sure if this is a true simulation of user experience?

The channel does not break for over 30 continuous /test posts 5, /test posts 10, /test posts 15, test posts 20 posts at high speed.

It starts to break again at around 25 continuous /test posts 30 posts at high speed.

Let me know if you need me to test in a different way or whether these results are sufficient?

@lindy65 lindy65 added Tests/Not Needed Does not require new release tests and removed 3: QA Review Requires review by a QA tester labels Nov 14, 2018
@crspeller
Copy link
Member Author

@lindy65 That message is fine. The "break" is only for very high frequency channels. The important thing to test is if the client is still usable while the posts are incoming.

You can compare the behavior to the behavior on master and you should see the difference.

@lindy65
Copy link
Contributor

lindy65 commented Nov 14, 2018

Thanks @crspeller

Just compared the behavior on master and absolutely can see a huge difference! Performance on the spinmint is way, way better.

@crspeller crspeller added the 2: Dev Review Requires review by a core commiter label Nov 14, 2018
actions/websocket_actions.jsx Outdated Show resolved Hide resolved
actions/websocket_actions.jsx Outdated Show resolved Hide resolved
actions/websocket_actions.jsx Show resolved Hide resolved
return null;
});
dispatch({
type: PostTypes.RECEIVED_POSTS,
Copy link
Member

Choose a reason for hiding this comment

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

One other thing here, do we know how much of a difference this will have dispatching once vs dispatching repeatedly? I've changed the RECEIVED_POSTS action from the original code into a new action (something like RECEIVED_NEW_POST although that name is already taken) that only takes a single post with some of my scrolling-related changes, and I'm wondering if I'll need to add a new RECEIVED_NEW_POSTS action as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Batching was required to get the performance increases when this code actually fires. Otherwise you get lots of redux updates.

// If the timeout is going this is the second or further event so queue them up.
if (queue.push(args) > 200) {
// Don't run us out of memory, give up if the queue gets insane
queue = [];
Copy link
Member

Choose a reason for hiding this comment

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

Could we do this without dumping the entire queue of posts when it becomes overloaded? It might be nice to only ignore any ones over the limit in that case

Copy link
Member Author

Choose a reason for hiding this comment

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

This only happens when there are over 200 posts within 100ms of the previous post. Not really worried about not breaking the channel in that case.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah breaking the channel in this case is fine. The goal of this is to not break the entire app when one channel goes nuts.

actions/websocket_actions.jsx Outdated Show resolved Hide resolved
actions/websocket_actions.jsx Outdated Show resolved Hide resolved
@crspeller
Copy link
Member Author

@hmhealey Ready for re-review.

Copy link
Member

@hmhealey hmhealey left a comment

Choose a reason for hiding this comment

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

The only thing I'm still a bit unsure about is how the batching will affect the changes to the post reducer will affect this, but I can deal with that when the time comes

@hmhealey hmhealey added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Nov 19, 2018
Copy link
Member

@jwilander jwilander left a comment

Choose a reason for hiding this comment

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

LGTM

@crspeller crspeller merged commit 59ed7ce into master Nov 20, 2018
@mattermod
Copy link
Contributor

Spinmint test server destroyed

@crspeller crspeller deleted the mm-12630 branch November 20, 2018 15:57
@lindy65 lindy65 removed 4: Reviews Complete All reviewers have approved the pull request Setup Old Test Server Triggers the creation of a test server labels Nov 20, 2018
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Nov 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation Tests/Not Needed Does not require new release tests
Projects
None yet
6 participants