Skip to content

Sending messages via WebSocketOutputStream is slow #4000

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

Open
michbin opened this issue Apr 4, 2025 · 1 comment
Open

Sending messages via WebSocketOutputStream is slow #4000

michbin opened this issue Apr 4, 2025 · 1 comment

Comments

@michbin
Copy link

michbin commented Apr 4, 2025

Describe the bug
Sending messages through the WebSocketStreamHandler.WebSocketOutputStream is quite slow. This behavior is mainly caused by the flush() method. We often observed that flush() only returned after 100 ms which reduced the throughput significantly.

The root cause is the long wait time (100 ms!) in following code snippet:

      while (WebSocketStreamHandler.this.socket.queueSize() > 0) {
        try {
          Thread.sleep(100);
          ...

Client Version
19.0.1

Kubernetes Version
1.29

Java Version
Java 17

To Reproduce
Invoke Exec.exec(...) to create an ExecProcess.
Use the output stream returned by Process.getOutputStream().
Send data using write(...) calls and flush the stream afterwards.

Expected behavior
A wait time of 1 ms should be sufficient.

Server (please complete the following information):

  • OS: Linux and Windows
  • Environment: container and IDE
@brendandburns
Copy link
Contributor

Happy to take PRs to improve this (for example making the wait configurable) or alternate mechanisms for ensuring the queue is flushed.

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

No branches or pull requests

2 participants