svelte-adapter-uws 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +48 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -53,6 +53,7 @@ I've been loving Svelte and SvelteKit for a long time. I always wanted to expand
53
53
  **Deployment & scaling**
54
54
  - [Deploying with Docker](#deploying-with-docker)
55
55
  - [Clustering](#clustering)
56
+ - [OS tuning for production](#os-tuning-for-production)
56
57
  - [Performance](#performance)
57
58
 
58
59
  **Examples**
@@ -2205,6 +2206,53 @@ With `network_mode: host`, containers share the host network stack directly -- n
2205
2206
 
2206
2207
  ---
2207
2208
 
2209
+ ## OS tuning for production
2210
+
2211
+ uWebSockets.js can handle hundreds of thousands of connections per process, but Linux defaults are conservative. For any deployment expecting more than a few hundred concurrent WebSocket connections, apply these settings on the host machine.
2212
+
2213
+ ### Kernel parameters
2214
+
2215
+ Add to `/etc/sysctl.conf` and run `sysctl -p`:
2216
+
2217
+ ```
2218
+ net.ipv4.tcp_max_syn_backlog = 4096 # pending TCP connection queue
2219
+ net.ipv4.tcp_tw_reuse = 1 # reuse TIME_WAIT sockets faster
2220
+ net.core.somaxconn = 4096 # listen() backlog limit
2221
+ fs.file-max = 1024000 # system-wide file descriptor limit
2222
+ ```
2223
+
2224
+ ### File descriptor limits
2225
+
2226
+ Add to `/etc/security/limits.conf` (takes effect on next login):
2227
+
2228
+ ```
2229
+ * soft nofile 1024000
2230
+ * hard nofile 1024000
2231
+ root soft nofile 1024000
2232
+ root hard nofile 1024000
2233
+ ```
2234
+
2235
+ The wildcard `*` does not apply to the root user on most Linux distributions. If the app runs as root (common in Docker), the explicit `root` lines are required.
2236
+
2237
+ ### Docker
2238
+
2239
+ If running in Docker, the container also needs raised limits. Add to your `docker-compose.yml`:
2240
+
2241
+ ```yaml
2242
+ services:
2243
+ app:
2244
+ ulimits:
2245
+ nofile:
2246
+ soft: 65536
2247
+ hard: 65536
2248
+ ```
2249
+
2250
+ Without these changes, each process is limited to 1024 file descriptors (the default). Each WebSocket connection uses one file descriptor, so the default caps you at roughly 1000 concurrent connections per process. The server CPU can be well under 50% and you will still hit this ceiling -- the bottleneck is the OS, not uWS or your application code.
2251
+
2252
+ For a deeper walkthrough, see [Millions of active WebSockets with Node.js](https://unetworkingab.medium.com/millions-of-active-websockets-with-node-js-7dc575746a01) from the uWebSockets.js authors.
2253
+
2254
+ ---
2255
+
2208
2256
  ## Performance
2209
2257
 
2210
2258
  ### Why uWebSockets.js?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-adapter-uws",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "description": "SvelteKit adapter for uWebSockets.js - high-performance C++ HTTP server with built-in WebSocket support",
5
5
  "author": "Kevin Radziszewski",
6
6
  "license": "MIT",