cmorten / opine

Minimalist web framework for Deno ported from ExpressJS.
https://github.com/cmorten/opine/blob/main/.github/API/api.md
MIT License
854 stars 43 forks source link

[#154] Implement WebSocket support. #155

Closed xyzshantaram closed 2 years ago

xyzshantaram commented 2 years ago

Implement WebSocket upgradation for HTTP connections

Fixes #154.

Details

This PR implements the ability to upgrade an HTTP connection into a WebSocket one by implementing an upgrade() method on the OpineRequest object. (See discussion in linked issue.)

Checklist

github-actions[bot] commented 2 years ago

Benchmark results

PR to merge main 28971958940a5804fecdc2d27b942e19d4674fea -> main ```console opine: 1 middleware ================================ 1 middleware Running 3s test @ http://localhost:3333/?foo[bar]=baz 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 2.84ms 1.04ms 19.47ms 88.70% Req/Sec 1.78k 265.50 2.11k 75.00% Latency Distribution 50% 2.64ms 75% 3.09ms 90% 3.65ms 99% 7.16ms 10650 requests in 3.02s, 1.92MB read Requests/sec: 3530.78 Transfer/sec: 651.68KB opine: 10 middleware ================================ 10 middleware Running 3s test @ http://localhost:3333/?foo[bar]=baz 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 2.84ms 0.88ms 18.71ms 82.94% Req/Sec 1.77k 257.57 2.12k 78.33% Latency Distribution 50% 2.68ms 75% 3.12ms 90% 3.73ms 99% 5.72ms 10565 requests in 3.01s, 1.90MB read Requests/sec: 3513.07 Transfer/sec: 648.41KB opine: 50 middleware ================================ 50 middleware Running 3s test @ http://localhost:3333/?foo[bar]=baz 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 2.79ms 0.86ms 22.32ms 85.40% Req/Sec 1.80k 284.97 2.19k 63.33% Latency Distribution 50% 2.64ms 75% 3.09ms 90% 3.62ms 99% 5.32ms 10757 requests in 3.01s, 1.94MB read Requests/sec: 3578.60 Transfer/sec: 660.50KB std/http benchmark ================================ Server listening on localhost:3333 Running 3s test @ http://localhost:3333/?foo[bar]=baz 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 794.73us 264.29us 6.48ms 89.57% Req/Sec 6.19k 461.40 6.82k 78.12% Latency Distribution 50% 760.00us 75% 0.87ms 90% 1.00ms 99% 1.55ms 39417 requests in 3.20s, 3.27MB read Requests/sec: 12311.81 Transfer/sec: 1.02MB deno_http_native benchmark ================================ Server listening on localhost:3333 Running 3s test @ http://localhost:3333/?foo[bar]=baz 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 783.90us 229.35us 5.88ms 86.55% Req/Sec 6.25k 439.71 6.67k 87.10% Latency Distribution 50% 754.00us 75% 0.86ms 90% 0.98ms 99% 1.46ms 38528 requests in 3.10s, 3.20MB read Requests/sec: 12426.18 Transfer/sec: 1.03MB ```