summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-06-04 04:53:09 +0700
committerShulhan <ms@kilabit.info>2023-06-04 04:53:38 +0700
commit25d09e2625ffe7a3a254f5bdb3351f405bfb0246 (patch)
treeec62f88cf0aaf40e130191c33f96933b6a8673b7
parentd67947e3fea16423cb42e6fa550450d6f22f4756 (diff)
downloadpakakeh.go-25d09e2625ffe7a3a254f5bdb3351f405bfb0246.tar.xz
lib/websocket: increase the max buffer and queue for better throughput
The maxBuffer increased from 1024 to 4096 bytes. The reason that we use 1024 previously is related to MTU size and maximum payload in TCP (although its higher, 1460 bytes). The maxQueue increase from 128 to 4096.
-rw-r--r--lib/websocket/funcs.go4
-rw-r--r--lib/websocket/server.go3
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/websocket/funcs.go b/lib/websocket/funcs.go
index 6a8a427e..aec7118b 100644
--- a/lib/websocket/funcs.go
+++ b/lib/websocket/funcs.go
@@ -14,7 +14,9 @@ import (
"golang.org/x/sys/unix"
)
-const maxBuffer = 1024
+// maxBuffer define maximum payload that we read/write from socket at one
+// time.
+const maxBuffer = 4096
// Recv read all content from file descriptor into slice of bytes.
//
diff --git a/lib/websocket/server.go b/lib/websocket/server.go
index 42d8faec..11c7b383 100644
--- a/lib/websocket/server.go
+++ b/lib/websocket/server.go
@@ -23,7 +23,8 @@ import (
)
const (
- _maxQueue = 128
+ // _maxQueue define maximum connection waiting to be upgraded.
+ _maxQueue = 4096
_resUpgradeOK = "HTTP/1.1 101 Switching Protocols\r\n" +
"Upgrade: websocket\r\n" +