1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-21 23:04:45 -05:00
denoland-deno/ext/http
Nathan Whitaker e92a05b551
feat(serve): Opt-in parallelism for deno serve (#24920)
Adds a `parallel` flag to `deno serve`. When present, we spawn multiple
workers to parallelize serving requests.


```bash
deno serve --parallel main.ts
```

Currently on linux we use `SO_REUSEPORT` and rely on the fact that the
kernel will distribute connections in a round-robin manner.

On mac and windows, we sort of emulate this by cloning the underlying
file descriptor and passing a handle to each worker. The connections
will not be guaranteed to be fairly distributed (and in practice almost
certainly won't be), but the distribution is still spread enough to
provide a significant performance increase.

---
(Run on an Macbook Pro with an M3 Max, serving `deno.com`

baseline::
```
❯ wrk -d 30s -c 125 --latency http://127.0.0.1:8000
Running 30s test @ http://127.0.0.1:8000
  2 threads and 125 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   239.78ms   13.56ms 330.54ms   79.12%
    Req/Sec   258.58     35.56   360.00     70.64%
  Latency Distribution
     50%  236.72ms
     75%  248.46ms
     90%  256.84ms
     99%  268.23ms
  15458 requests in 30.02s, 2.47GB read
Requests/sec:    514.89
Transfer/sec:     84.33MB
```

this PR (`with --parallel` flag)
```
❯ wrk -d 30s -c 125 --latency http://127.0.0.1:8000
Running 30s test @ http://127.0.0.1:8000
  2 threads and 125 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   117.40ms  142.84ms 590.45ms   79.07%
    Req/Sec     1.33k   175.19     1.77k    69.00%
  Latency Distribution
     50%   22.34ms
     75%  223.67ms
     90%  357.32ms
     99%  460.50ms
  79636 requests in 30.07s, 12.74GB read
Requests/sec:   2647.96
Transfer/sec:    433.71MB
```
2024-08-14 22:26:21 +00:00
..
benches chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
00_serve.ts feat(serve): Opt-in parallelism for deno serve (#24920) 2024-08-14 22:26:21 +00:00
01_http.js perf(ext/http): recover memory for serve and optimize AbortController (#23559) 2024-04-25 14:52:24 -04:00
02_websocket.ts fix(ext/websocket): change default idleTimeout to 30s (#23985) 2024-05-26 10:46:05 +05:30
Cargo.toml chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
compressible.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
fly_accept_encoding.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
http_next.rs feat(ext/http): Implement request.signal for Deno.serve (#23425) 2024-04-24 14:03:37 -04:00
lib.rs feat(ext/http): Implement request.signal for Deno.serve (#23425) 2024-04-24 14:03:37 -04:00
network_buffered_stream.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
reader_stream.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
README.md chore: add README to ext/http/ (#11958) 2021-09-08 20:48:28 +02:00
request_body.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
request_properties.rs feat(ext/net): Refactor TCP socket listeners for future clustering mode (#23037) 2024-04-08 16:18:14 -06:00
response_body.rs perf(ext/http): Reduce size of ResponseBytesInner (#24840) 2024-08-02 00:30:26 +00:00
service.rs perf(ext/http): Reduce size of ResponseBytesInner (#24840) 2024-08-02 00:30:26 +00:00
websocket_upgrade.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00

deno_http

This crate implements server-side HTTP based on primitives from the Fetch API.