-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(engineio/ws): add read_buffer_size option and set default to 4KiB (…
…#450) * fix(engineio/ws): add read_buffer_size option and set default to 4KiB * fix(socketio/client): make sure that the ns packet slice is not kept at ns connection * fix(parser/common): copy buffer for partial bin packets * test(e2e/heaptrack) set max client to 10K
- Loading branch information
Showing
13 changed files
with
282 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
*.gz | ||
client/node_modules | ||
memory_usage.svg | ||
node_modules | ||
memory_usage.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { io } from "socket.io-client"; | ||
|
||
const URL = process.env.URL || "http://localhost:3000"; | ||
const MAX_CLIENTS = 5000; | ||
const POLLING_PERCENTAGE = 0.05; | ||
const CLIENT_CREATION_INTERVAL_IN_MS = 1; | ||
const EMIT_INTERVAL_IN_MS = 1000; | ||
|
||
let clientCount = 0; | ||
let lastReport = new Date().getTime(); | ||
let packetsSinceLastReport = 0; | ||
|
||
const createClient = () => { | ||
// for demonstration purposes, some clients stay stuck in HTTP long-polling | ||
const transports = | ||
Math.random() < POLLING_PERCENTAGE ? ["polling"] : ["polling", "websocket"]; | ||
|
||
const socket = io(URL, { | ||
transports, | ||
}); | ||
|
||
setInterval(() => { | ||
socket.emit("ping"); | ||
}, EMIT_INTERVAL_IN_MS); | ||
|
||
socket.on("pong", () => { | ||
packetsSinceLastReport++; | ||
}); | ||
|
||
socket.on("disconnect", (reason) => { | ||
console.log(`disconnect due to ${reason}`); | ||
}); | ||
|
||
if (++clientCount < MAX_CLIENTS) { | ||
setTimeout(createClient, CLIENT_CREATION_INTERVAL_IN_MS); | ||
} | ||
}; | ||
|
||
createClient(); | ||
|
||
const printReport = () => { | ||
const now = new Date().getTime(); | ||
const durationSinceLastReport = (now - lastReport) / 1000; | ||
const packetsPerSeconds = ( | ||
packetsSinceLastReport / durationSinceLastReport | ||
).toFixed(2); | ||
|
||
console.log( | ||
`client count: ${clientCount} ; average packets received per second: ${packetsPerSeconds}`, | ||
); | ||
|
||
packetsSinceLastReport = 0; | ||
lastReport = now; | ||
}; | ||
|
||
setInterval(printReport, 5000); |
Oops, something went wrong.