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

[#115] Migrate to native server #149

Closed cmorten closed 2 years ago

cmorten commented 2 years ago

Issue

Fixes #115.

Details

Swaps out std legacy server for new std server utilising the Deno native server impl. This may see an increase in Opine server performance... but haven't tuned particularly, so could be sloppy in places.

Is a change of internal implementation, so no deliberate public interface changes. Expect there may be some subtle differences due to moving from custom responses to Response instances (e.g. Content-Length for 204, or 304 responses no longer present) sufficient to warrant a major version bump anyway, if only to play safe.

CheckList

github-actions[bot] commented 2 years ago

Benchmark results

PR to merge feat/migrate-to-native-server c225b7aa20f88913f048e82bc9cedeeed6fa07ca -> 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.27ms 647.80us 17.05ms 89.20% Req/Sec 2.22k 315.94 2.53k 85.48% Latency Distribution 50% 2.06ms 75% 2.39ms 90% 2.86ms 99% 4.69ms 13715 requests in 3.11s, 2.47MB read Requests/sec: 4413.59 Transfer/sec: 814.62KB 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.59ms 755.01us 18.48ms 83.82% Req/Sec 1.93k 250.42 2.36k 75.81% Latency Distribution 50% 2.42ms 75% 2.82ms 90% 3.40ms 99% 5.11ms 11961 requests in 3.11s, 2.16MB read Requests/sec: 3841.45 Transfer/sec: 709.02KB 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.32ms 631.09us 19.45ms 91.38% Req/Sec 2.17k 280.09 2.39k 85.94% Latency Distribution 50% 2.17ms 75% 2.37ms 90% 2.79ms 99% 4.35ms 13818 requests in 3.20s, 2.49MB read Requests/sec: 4311.41 Transfer/sec: 795.76KB 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 646.70us 127.94us 4.00ms 79.87% Req/Sec 7.55k 264.25 8.10k 80.00% Latency Distribution 50% 623.00us 75% 695.00us 90% 791.00us 99% 1.07ms 45066 requests in 3.00s, 3.74MB read Requests/sec: 15019.85 Transfer/sec: 1.25MB 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 642.49us 155.40us 4.20ms 86.64% Req/Sec 7.63k 831.37 13.15k 95.08% Latency Distribution 50% 623.00us 75% 684.00us 90% 770.00us 99% 1.10ms 46331 requests in 3.10s, 3.84MB read Requests/sec: 14948.25 Transfer/sec: 1.24MB ```