wse-client 1.4.0 → 1.4.1

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.
package/README.md CHANGED
@@ -20,7 +20,7 @@ Building real-time features between React and Python is painful. You need WebSoc
20
20
 
21
21
  Install `wse-server` on your backend, `wse-client` on your frontend (React or Python). Everything works immediately: auto-reconnection, message encryption, sequence ordering, offline queues, health monitoring. No configuration required for the defaults. Override what you need.
22
22
 
23
- The engine is Rust-accelerated via PyO3. Up to **14M msg/s** JSON, **30M msg/s** compressed benchmarked on AMD EPYC 7502P (32 cores) with the Rust stress-test client ([results](docs/BENCHMARKS_RUST_CLIENT.md)). Sub-millisecond connection latency (0.38ms median) with Rust JWT authentication.
23
+ The engine is Rust-accelerated via PyO3. **14M msg/s** JSON, **30M msg/s** binary, **2.1M deliveries/s** fan-out, **500K concurrent connections** with zero message loss -- benchmarked on AMD EPYC 7502P. Multi-instance horizontal scaling via Redis pub/sub. Sub-millisecond latency (0.38 ms) with Rust JWT authentication.
24
24
 
25
25
  ---
26
26
 
@@ -141,7 +141,7 @@ Connection quality scoring (excellent / good / fair / poor), latency tracking, j
141
141
 
142
142
  ### Scaling
143
143
 
144
- Redis pub/sub for multi-process fan-out. Run multiple server workers behind a load balancer. Clients get messages from any worker. Fire-and-forget delivery with sub-millisecond latency.
144
+ Redis pub/sub for multi-instance fan-out. Run N server instances behind a load balancer -- publish on any instance, all subscribers receive the message regardless of which instance they're connected to. Pipelined PUBLISH (up to 64 per round-trip), circuit breaker, exponential backoff with jitter, dead letter queue for failed messages. Capacity scales linearly with instances: tested up to 1.04M deliveries/s per instance.
145
145
 
146
146
  ### Rust Performance
147
147
 
@@ -169,7 +169,8 @@ Compression, sequencing, filtering, rate limiting, and the WebSocket server itse
169
169
  | **Snapshot Provider** | Protocol for initial state delivery. Implement `get_snapshot(user_id, topics)` and clients receive current state immediately on subscribe -- no waiting for the next publish cycle. |
170
170
  | **Circuit Breaker** | Three-state machine (CLOSED / OPEN / HALF_OPEN). Sliding-window failure tracking. Automatic recovery probes. Prevents cascade failures when downstream services are unhealthy. |
171
171
  | **Message Categories** | `S` (snapshot), `U` (update), `WSE` (system). Category prefixing for client-side routing and filtering. |
172
- | **PubSub Bus** | Redis pub/sub with PSUBSCRIBE pattern matching. orjson fast-path serialization. Custom JSON encoder for UUID, datetime, Decimal. Non-blocking handler invocation. |
172
+ | **Multi-Instance Orchestration** | Horizontal scaling via Redis pub/sub. Publish on any instance, all subscribers receive the message. Pipelined PUBLISH (64 commands/batch, 3 retries), circuit breaker (10-fail threshold, 60s reset), exponential backoff with jitter, dead letter queue (1000-entry ring buffer). 1.04M deliveries/s per instance, linear scaling with N instances. |
173
+ | **PubSub Bus** | Redis pub/sub with PSUBSCRIBE pattern matching. Glob wildcard topic routing (`user:*:events`). orjson fast-path serialization. Non-blocking handler invocation. |
173
174
  | **Pluggable Security** | `EncryptionProvider` and `TokenProvider` protocols. Built-in: AES-GCM-256 with ECDH P-256 key exchange, HMAC-SHA256 signing, selective message signing. Rust-accelerated crypto (SHA-256, HMAC, AES-GCM, ECDH). |
174
175
  | **Rust JWT Authentication** | HS256 JWT validation in Rust during the WebSocket handshake. Zero GIL acquisition on the connection critical path. 0.01ms decode (85x faster than Python). Cookie extraction and `server_ready` sent from Rust before Python runs. |
175
176
  | **Lock-Free Server Queries** | `get_connection_count()` uses `AtomicUsize` — zero GIL, zero blocking, safe to call from async Python handlers. No channel round-trip to the tokio runtime. |
@@ -210,31 +211,69 @@ Compression, sequencing, filtering, rate limiting, and the WebSocket server itse
210
211
 
211
212
  ## Performance
212
213
 
213
- Rust-accelerated engine via PyO3. Benchmarked on localhost.
214
-
215
- ### Apple M2 (8 cores)
216
-
217
- | Metric | Single Client | 10 Workers |
218
- |--------|--------------|------------|
219
- | **Sustained throughput (JSON)** | 113,000 msg/s | **356,000 msg/s** |
220
- | **Sustained throughput (MsgPack)** | 116,000 msg/s | **345,000 msg/s** |
221
- | **Burst throughput (JSON)** | 106,000 msg/s | **488,000 msg/s** |
222
- | **Connection latency** | **0.53 ms** median | 2.20 ms median |
223
- | **Ping RTT** | **0.09 ms** median | 0.18 ms median |
224
- | **64KB messages** | 43K msg/s (2.7 GB/s) | **164K msg/s (10.2 GB/s)** |
225
-
226
- ### AMD EPYC 7502P (64 cores, 128 GB)
227
-
228
- | Metric | 64 Workers | 128 Workers |
229
- |--------|-----------|-------------|
230
- | **Sustained throughput (JSON)** | **2,045,000 msg/s** | 2,013,000 msg/s |
231
- | **Sustained throughput (MsgPack)** | **2,072,000 msg/s** | 2,041,000 msg/s |
232
- | **Burst throughput (JSON)** | 1,557,000 msg/s | **1,836,000 msg/s** |
233
- | **Connection latency** | 2.60 ms median | 2.96 ms median |
234
- | **Ping RTT** | 0.26 ms median | 0.41 ms median |
235
- | **64KB messages** | **256K msg/s (16.0 GB/s)** | 238K msg/s (14.9 GB/s) |
236
-
237
- See [BENCHMARKS.md](docs/BENCHMARKS.md) for full results and methodology.
214
+ Rust-accelerated engine via PyO3. AMD EPYC 7502P (32 cores, 128 GB), Ubuntu 24.04, localhost.
215
+
216
+ ### Highlights
217
+
218
+ | Metric | Value | Details |
219
+ |--------|-------|---------|
220
+ | **Peak throughput** | **14.2M msg/s** | JSON, Rust client, 500 connections |
221
+ | **Peak binary** | **30M msg/s** | MsgPack/compressed, Rust client |
222
+ | **Fan-out broadcast** | **2.1M deliveries/s** | Single-instance, zero message loss |
223
+ | **Max connections** | **500,000** | Zero errors, zero gaps at every tier |
224
+ | **Connection latency** | **0.38 ms** median | Rust JWT auth in handshake |
225
+ | **Accept rate** | **15,020 conn/s** | Sustained connection establishment |
226
+ | **Memory per conn** | **4.4 KB** | Rust core static overhead |
227
+
228
+ ### Point-to-Point (Rust Native Client)
229
+
230
+ | Payload | Throughput | Bandwidth |
231
+ |---------|-----------|-----------|
232
+ | 64 bytes | **19.4M msg/s** | 1.2 GB/s |
233
+ | 256 bytes | **12.5M msg/s** | 3.1 GB/s |
234
+ | 1 KB | **10.3M msg/s** | 10.0 GB/s |
235
+ | 16 KB | **1.2M msg/s** | **19.9 GB/s** |
236
+ | 64 KB | **284K msg/s** | **18.2 GB/s** |
237
+
238
+ ### Point-to-Point (Python Multi-Process, 64 Workers)
239
+
240
+ | Metric | JSON | MsgPack |
241
+ |--------|------|---------|
242
+ | **Sustained** | **2,045,000 msg/s** | **2,072,000 msg/s** |
243
+ | **Burst** | 1,557,000 msg/s | 1,836,000 msg/s |
244
+ | **64KB messages** | 256K msg/s (16.0 GB/s) | -- |
245
+ | **Ping RTT** | 0.26 ms median | -- |
246
+
247
+ ### Point-to-Point (TypeScript/Node.js, 64 Processes)
248
+
249
+ | Format | Throughput | Scaling |
250
+ |--------|-----------|---------|
251
+ | JSON | **7.0M msg/s** | 97% linear |
252
+ | MsgPack | **7.9M msg/s** | +13% over JSON |
253
+
254
+ ### Fan-out Broadcast (Single-Instance)
255
+
256
+ Server broadcasts to N subscribers. **Zero message loss at every tier.**
257
+
258
+ | Subscribers | Deliveries/s | Bandwidth | p50 Latency |
259
+ |-------------|-------------|-----------|-------------|
260
+ | 10 | **2.1M** | 295 MB/s | 0.005 ms |
261
+ | 1,000 | 1.4M | 185 MB/s | -- |
262
+ | 10,000 | 1.2M | 163 MB/s | -- |
263
+ | 100,000 | 1.7M | 234 MB/s | -- |
264
+ | **500,000** | **1.4M** | 128 MB/s | -- |
265
+
266
+ ### Rust Acceleration vs Python
267
+
268
+ | Component | Speedup | Rust | Python |
269
+ |-----------|---------|------|--------|
270
+ | JWT decode (HS256) | **85x** | 10 us | 850 us |
271
+ | Msgpack parsing | **~50x** | -- | -- |
272
+ | Rate limiter | **40x** | -- | -- |
273
+ | HMAC-SHA256 | **22x** | -- | -- |
274
+ | Compression (zlib) | **6.7x** | -- | -- |
275
+
276
+ See benchmark docs for full results: [Overview](docs/BENCHMARKS.md) | [Rust Client](docs/BENCHMARKS_RUST_CLIENT.md) | [TypeScript Client](docs/BENCHMARKS_TS_CLIENT.md) | [Python Client](docs/BENCHMARKS_PYTHON_CLIENT.md) | [Fan-out](docs/BENCHMARKS_FANOUT.md)
238
277
 
239
278
  ---
240
279
 
@@ -1,5 +1,5 @@
1
1
  export declare const WS_PROTOCOL_VERSION = 1;
2
- export declare const WS_CLIENT_VERSION = "1.3.9";
2
+ export declare const WS_CLIENT_VERSION = "1.4.1";
3
3
  export declare const HEARTBEAT_INTERVAL = 15000;
4
4
  export declare const IDLE_TIMEOUT = 40000;
5
5
  export declare const CONNECTION_TIMEOUT = 10000;
package/dist/constants.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // Protocol Constants
6
6
  // ---------------------------------------------------------------------------
7
7
  export const WS_PROTOCOL_VERSION = 1;
8
- export const WS_CLIENT_VERSION = '1.3.9';
8
+ export const WS_CLIENT_VERSION = '1.4.1';
9
9
  // ---------------------------------------------------------------------------
10
10
  // Connection Constants
11
11
  // ---------------------------------------------------------------------------
package/dist/index.d.ts CHANGED
@@ -21,5 +21,5 @@ export type { OfflineQueueConfig } from './services/OfflineQueue';
21
21
  export { EventHandlers } from './handlers/EventHandlers';
22
22
  export { registerAllHandlers } from './handlers/index';
23
23
  export * from './constants';
24
- export declare const WSE_VERSION = "1.3.9";
24
+ export declare const WSE_VERSION = "1.4.1";
25
25
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -44,5 +44,5 @@ export * from './constants';
44
44
  // ---------------------------------------------------------------------------
45
45
  // Version Info
46
46
  // ---------------------------------------------------------------------------
47
- export const WSE_VERSION = '1.3.9';
47
+ export const WSE_VERSION = '1.4.1';
48
48
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wse-client",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "WSE (WebSocket Engine) React client. Type-safe hooks, auto-reconnect, offline queue, E2E encryption.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",