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

websocket: fix write back-pressure #618

Merged
merged 1 commit into from
May 4, 2021

Conversation

katreniak
Copy link
Contributor

@katreniak katreniak commented Apr 30, 2021

Websocket transport is eagerly writing to underlaying websocket
without respecting back-pressure.
When an event is emitted to multiple clients, socket.io adapter
sends the same packet object to all socket clients.
These packet objects are shared for all clients inside room.

Once the packet is sent to transport,
transport prepares buffer with transport headers and packet data
and the sharing among clients is lost.

This change significantly reduces memory usage when
many packets are emitted to many clients in a burst.

This change causes that buffered data is sent to clients
more evenly packet by packet.

This change slightly (up to 10%) improved write throughput in the tests where
many packets are emitted to many clients in a burst.

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behaviour

Websocket transport does not respect back pressure from underlaying websocket

New behaviour

Websocket transport respects back pressure from underlaying websocket

Other information (e.g. related issues)

@katreniak katreniak force-pushed the master branch 2 times, most recently from 00067b5 to 1b32011 Compare April 30, 2021 13:31
Websocket transport is eagerly writing to underlaying websocket
without respecting back-pressure.
When an event is emitted to multiple clients, socket.io adapter
sends the same packet object to all socket clients.
These packet objects are shared for all clients inside room.

Once the packet is sent to transport,
transport prepares buffer with transport headers and packet data
and the sharing among clients is lost.

This change significantly reduces memory usage when
many packets are emitted to many clients in a burst.

    This change causes that buffered data is sent to clients
    more evenly packet by packet.
@katreniak
Copy link
Contributor Author

Thank you!

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

Successfully merging this pull request may close these issues.

None yet

2 participants