-
Notifications
You must be signed in to change notification settings - Fork 196
Description
I encountered two (most likely independent) performance problems with suave websockets.
A setup which demonstrates the problem can be achieved as such:
- create websocket connections (in javascript) which occasionally sends a message to suave (which replies immediately), in code they are called
lurkers - create another websocket connection which repeateadely as fast as possible sends messages to suave, again answered immediately (so this connection is stressed compared to
lurkers).
In this setup here the WebSocket example has been modified in order to show the problem in a consice manner.
For demostration, use the test repo, start the modified websocket example and open Blub.html available in the Websocket directory in a web browser.
In your chrome you will see:
Problem 1:
As you will see, typically the ping pong takes 0.21ms, however suddenly the application starts printing long iteration warning - showing more than 500ms roundtrip time.
In the output log you will see stuff as such:
The thread 0x25f0 has exited with code 0 (0x0).
The thread 0x47c8 has exited with code 0 (0x0).
The thread 0x4e3c has exited with code 0 (0x0).
The thread 0x41e8 has exited with code 0 (0x0).
The thread 0xeb4 has exited with code 0 (0x0).
The thread 0x4fac has exited with code 0 (0x0).
The thread 0x868 has exited with code 0 (0x0).
The thread 0x4af8 has exited with code 0 (0x0).
On a machine with more cpus or setting higher MinThreads in the threadpool this problem goes away. We will shortly submit an issue to coreclr @krauthaufen
The problem is simply the way async operations work on sockets in combination with varying workloads as simulated by the two kinds of sockets.
Problem 2:
Using many WebSocket connections, beginning from approx 10 take forever.
You can see the connection time for 32 clients (as you will see in Blub.html) in the screenshot which is about 5seconds-20secons.
22305.31 available workers: 32766, io's: 1000
[18:24:20 DBG] 127.0.0.1 connected. Now has 23 connected
[18:24:20 VRB] Reserving buffer at 172032, with 77 segments from call from Suave.Tcp.job
[18:24:20 VRB] Processing request... -> processor
[18:24:20 VRB] reading first line of request
[18:24:20 VRB] Reserving buffer at 180224, with 76 segments from call from Suave.Web.readMoreData
[18:24:20 VRB] reading headers
[18:24:20 VRB] Freeing buffer at 180224 from Suave.Web.split. Free segments 77.
[18:24:20 VRB] parsing post data
[18:24:20 VRB] Processed request. <- processor
22356.27 available workers: 32765, io's: 1000
22407.22 available workers: 32766, io's: 100
This is most likely due to problems in concurrent buffer management.
