Skip to content

Latest commit

 

History

History
250 lines (186 loc) · 6.61 KB

File metadata and controls

250 lines (186 loc) · 6.61 KB

WebSocket Server Performance Report

Date: January 2025
Server: LikuBuddy WebSocket Server (dist/websocket/cli.js)
Node.js: v20.x
Test Machine: Windows Development Environment

Executive Summary

The WebSocket server demonstrates excellent performance across all tested loads:

  • 1000 concurrent connections handled smoothly
  • Sub-5ms connection latency at all scales
  • ~10KB memory per connection (efficient)
  • ~500 msg/s throughput at peak load
  • 100% connection success rate across all tests

Verdict: ✅ Production Ready for Chess AI tournaments and multiplayer scenarios.


Load Test Results

Test Configuration

Parameter Value
Server Port 3847
Health Port 3848
Test Duration 20 seconds (after ramp-up)
Messages per client 1 msg/second
Ramp rate 25-100 conn/second

Test 1: 100 Connections (Baseline)

🔗 CONNECTION STATISTICS
  Target Connections:    100
  Successful:            100 (100.0%)
  Failed:                0
  Peak Active:           100

⚡ LATENCY (Connection Time)
  Min:                   1ms
  Max:                   5ms
  Average:               2ms
  P50:                   2ms
  P95:                   3ms
  P99:                   5ms

📨 MESSAGE STATISTICS
  Messages Sent:         1400
  Messages Received:     1500
  Throughput (sent):     45.6 msg/s
  Throughput (recv):     48.8 msg/s

💾 MEMORY USAGE (Client Process)
  Heap Used (min):       6.43 MB
  Heap Used (max):       7.69 MB
  RSS (min):             47.17 MB
  RSS (max):             49.99 MB
  Est. per connection:   12.9 KB

📋 ASSESSMENT: ✅ EXCELLENT

Test 2: 500 Connections (Medium Load)

🔗 CONNECTION STATISTICS
  Target Connections:    500
  Successful:            500 (100.0%)
  Failed:                0
  Peak Active:           500

⚡ LATENCY (Connection Time)
  Min:                   1ms
  Max:                   5ms
  Average:               2ms
  P50:                   2ms
  P95:                   3ms
  P99:                   3ms

📨 MESSAGE STATISTICS
  Messages Sent:         9500
  Messages Received:     10000
  Throughput (sent):     253.3 msg/s
  Throughput (recv):     266.6 msg/s

💾 MEMORY USAGE (Client Process)
  Heap Used (min):       6.27 MB
  Heap Used (max):       11.16 MB
  RSS (min):             46.17 MB
  RSS (max):             54.08 MB
  Est. per connection:   10.0 KB

📋 ASSESSMENT: ✅ EXCELLENT

Test 3: 1000 Connections (High Load)

🔗 CONNECTION STATISTICS
  Target Connections:    1000
  Successful:            1000 (100.0%)
  Failed:                0
  Peak Active:           1000

⚡ LATENCY (Connection Time)
  Min:                   1ms
  Max:                   5ms
  Average:               2ms
  P50:                   2ms
  P95:                   3ms
  P99:                   4ms

📨 MESSAGE STATISTICS
  Messages Sent:         19000
  Messages Received:     20000
  Throughput (sent):     459.6 msg/s
  Throughput (recv):     483.8 msg/s

💾 MEMORY USAGE (Client Process)
  Heap Used (min):       6.29 MB
  Heap Used (max):       14.85 MB
  RSS (min):             46.51 MB
  RSS (max):             62.40 MB
  Est. per connection:   8.8 KB

📋 ASSESSMENT: ✅ EXCELLENT

Performance Analysis

Memory Efficiency

Connections Heap (MB) RSS (MB) Per Connection
100 7.69 49.99 ~12.9 KB
500 11.16 54.08 ~10.0 KB
1000 14.85 62.40 ~8.8 KB

Key Insight: Memory usage per connection decreases at scale due to better sharing of resources. The server demonstrates excellent memory efficiency.

Latency Profile

Load P50 P95 P99
100 2ms 3ms 5ms
500 2ms 3ms 3ms
1000 2ms 3ms 4ms

Key Insight: Connection latency remains consistently low (1-5ms) regardless of load. No degradation observed at 1000 connections.

Throughput Scaling

Connections Sent/sec Recv/sec Scale Factor
100 45.6 48.8 1.0x
500 253.3 266.6 5.5x
1000 459.6 483.8 10.1x

Key Insight: Throughput scales nearly linearly with connection count. This indicates no bottlenecks in the message handling pipeline.


Recommendations

Current Server Configuration

  • Default max-clients: 100 (conservative for development)
  • Recommended for production: 500-1000 based on expected load
  • Memory headroom: Allocate ~100MB RSS for 1000 concurrent users

Starting Server with Higher Limits

# Development (default)
npm run websocket

# Production with 500 clients
node dist/websocket/cli.js --max-clients 500

# High-load scenario (1000 clients)
node dist/websocket/cli.js --max-clients 1000

Chess Tournament Capacity

Based on test results, the server can comfortably handle:

Scenario Connections Assessment
2-player game 2 ✅ Trivial
Small tournament (8 players) 16+ ✅ Excellent
Medium tournament (32 players) 64+ ✅ Excellent
Large tournament (100 players) 200+ ✅ Excellent
AI Battle (10 concurrent games) 20+ ✅ Excellent

Running Load Tests

Prerequisites

npm run build
npm run websocket  # Start server first

Load Test Commands

# Quick baseline test
node scripts/load-test.js --connections=100 --duration=15

# Full profile with memory tracking
node scripts/load-test.js --connections=500 --duration=20 --profile

# Stress test
node scripts/load-test.js --connections=1000 --duration=30 --ramp=100 --profile

Available Options

Flag Description Default
--url WebSocket server URL ws://localhost:3847
--connections Number of connections 100
--duration Test duration (seconds) 30
--messages Messages per client per second 1
--ramp Connections per second during ramp-up 10
--profile Enable memory profiling false

Conclusion

The LikuBuddy WebSocket server is fully capable of handling:

  • Real-time multiplayer games
  • AI vs AI tournaments with multiple concurrent games
  • Spectator connections
  • Chat and state synchronization

No additional optimization is required for the planned Chess implementation. The current architecture provides excellent headroom for future growth.


Report generated from load tests performed in January 2025