Skip to content

feat: http version check#3912

Merged
mcollina merged 14 commits intomainfrom
http-version-check
May 21, 2022
Merged

feat: http version check#3912
mcollina merged 14 commits intomainfrom
http-version-check

Conversation

@climba03003
Copy link
Copy Markdown
Member

@climba03003 climba03003 commented May 19, 2022

Fixes #3893

Checklist

@climba03003 climba03003 added the benchmark Label to run benchmark against PR and main branch label May 19, 2022
@github-actions
Copy link
Copy Markdown

Node: 14
PR: [1] 1488k requests in 30.06s, 280 MB read
MAIN: [1] 1478k requests in 30.06s, 278 MB read


Node: 16
PR: [1] 1595k requests in 30.06s, 300 MB read
MAIN: [1] 1605k requests in 30.07s, 302 MB read


Node: 18
PR: [1] 1723k requests in 30.04s, 324 MB read
MAIN: [1] 1785k requests in 30.04s, 335 MB read

@github-actions github-actions Bot removed the benchmark Label to run benchmark against PR and main branch label May 19, 2022
@climba03003
Copy link
Copy Markdown
Member Author

I think the impact is minimal.

Pull Request

$ npx concurrently -k -s first "node ./examples/benchmark/simple.js" "npx autocannon -c 100 -d 30 -p 10 localhost:3000/"
[1] Running 30s test @ http://localhost:3000/
[1] 100 connections with 10 pipelining factor
[1]
[1] 
[1] ┌─────────┬───────┬───────┬───────┬───────┬──────────┬─────────┬────────┐
[1] │ Stat    │ 2.5%  │ 50%   │ 97.5% │ 99%   │ Avg      │ Stdev   │ Max    │
[1] ├─────────┼───────┼───────┼───────┼───────┼──────────┼─────────┼────────┤
[1] │ Latency │ 20 ms │ 23 ms │ 35 ms │ 46 ms │ 24.43 ms │ 4.86 ms │ 138 ms │
[1] └─────────┴───────┴───────┴───────┴───────┴──────────┴─────────┴────────┘
[1] ┌───────────┬─────────┬─────────┬────────┬─────────┬──────────┬─────────┬─────────┐
[1] │ Stat      │ 1%      │ 2.5%    │ 50%    │ 97.5%   │ Avg      │ Stdev   │ Min     │
[1] ├───────────┼─────────┼─────────┼────────┼─────────┼──────────┼─────────┼─────────┤
[1] │ Req/Sec   │ 32095   │ 32095   │ 40415  │ 41791   │ 40134.67 │ 1724.15 │ 32093   │
[1] ├───────────┼─────────┼─────────┼────────┼─────────┼──────────┼─────────┼─────────┤
[1] │ Bytes/Sec │ 6.04 MB │ 6.04 MB │ 7.6 MB │ 7.86 MB │ 7.55 MB  │ 323 kB  │ 6.03 MB │
[1] └───────────┴─────────┴─────────┴────────┴─────────┴──────────┴─────────┴─────────┘
[1]
[1] Req/Bytes counts sampled once per second.
[1] # of samples: 30
[1]
[1] 1205k requests in 30.05s, 226 MB read
[1] npx autocannon -c 100 -d 30 -p 10 localhost:3000/ exited with code 0
--> Sending SIGTERM to other processes..
[0] node ./examples/benchmark/simple.js exited with code SIGTERM
Done in 33.95s.

Main Branch

$ npx concurrently -k -s first "node ./examples/benchmark/simple.js" "npx autocannon -c 100 -d 30 -p 10 localhost:3000/"
[1] Running 30s test @ http://localhost:3000/
[1] 100 connections with 10 pipelining factor
[1]
[1] 
[1] ┌─────────┬───────┬───────┬───────┬───────┬──────────┬─────────┬────────┐    
[1] │ Stat    │ 2.5%  │ 50%   │ 97.5% │ 99%   │ Avg      │ Stdev   │ Max    │    
[1] ├─────────┼───────┼───────┼───────┼───────┼──────────┼─────────┼────────┤    
[1] │ Latency │ 20 ms │ 23 ms │ 37 ms │ 46 ms │ 24.18 ms │ 5.28 ms │ 146 ms │    
[1] └─────────┴───────┴───────┴───────┴───────┴──────────┴─────────┴────────┘    
[1] ┌───────────┬────────┬────────┬────────┬───────┬─────────┬─────────┬────────┐
[1] │ Stat      │ 1%     │ 2.5%   │ 50%    │ 97.5% │ Avg     │ Stdev   │ Min    │
[1] ├───────────┼────────┼────────┼────────┼───────┼─────────┼─────────┼────────┤
[1] │ Req/Sec   │ 31407  │ 31407  │ 40991  │ 42527 │ 40535.2 │ 1913.72 │ 31395  │
[1] ├───────────┼────────┼────────┼────────┼───────┼─────────┼─────────┼────────┤
[1] │ Bytes/Sec │ 5.9 MB │ 5.9 MB │ 7.7 MB │ 8 MB  │ 7.62 MB │ 360 kB  │ 5.9 MB │
[1] └───────────┴────────┴────────┴────────┴───────┴─────────┴─────────┴────────┘
[1]
[1] Req/Bytes counts sampled once per second.
[1] # of samples: 30
[1]
[1] 1217k requests in 30.05s, 229 MB read
[1] npx autocannon -c 100 -d 30 -p 10 localhost:3000/ exited with code 0
--> Sending SIGTERM to other processes..
[0] node ./examples/benchmark/simple.js exited with code SIGTERM
Done in 33.96s.

@Fdawgs
Copy link
Copy Markdown
Member

Fdawgs commented May 19, 2022

Would nodejs/node#43115, as mentioned in the other PR, not tackle this?

@climba03003
Copy link
Copy Markdown
Member Author

climba03003 commented May 19, 2022

Would nodejs/node#43115, as mentioned in the other PR, not tackle this?

It can handle it, but the that issue seems no activity.
At least, I don't think it will land in a near future.

If the impact is small enough (fall between the variation), I think we can land it first.
Then, remove it after the core update.

Comment thread lib/server.js Outdated
@jsumners
Copy link
Copy Markdown
Member

What issue does this solve?

@climba03003
Copy link
Copy Markdown
Member Author

What issue does this solve?

#3893

Comment thread lib/route.js
Copy link
Copy Markdown
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment thread lib/server.js
@climba03003 climba03003 requested a review from mcollina May 20, 2022 02:51
Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread docs/Reference/Routes.md Outdated
Comment thread lib/server.js Outdated
return function validateHTTPVersion (httpVersion) {
// `bypass` skip the check when custom server factory provided
// `httpVersion in obj` check for the valid http version we should support
return bypass || httpVersion in obj
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would the difference be in using an actual Map and then a .has check?

Suggested change
return bypass || httpVersion in obj
return bypass || obj.has(httpVersion)

Copy link
Copy Markdown
Member Author

@climba03003 climba03003 May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Map is definitely slower in this case.
I also tested Set, it is about the same as Array.includes.

I re-run the benchmark. Map actually about the same as in operator.

using Map.has x 1,295,809,605 ops/sec ±0.09% (98 runs sampled)
using Map.has (first item) x 1,293,557,094 ops/sec ±0.12% (96 runs sampled)
using Set.has x 145,554,007 ops/sec ±0.65% (91 runs sampled)
using Set.has (first item) x 147,771,297 ops/sec ±0.31% (96 runs sampled)
using in obj x 1,294,797,802 ops/sec ±0.19% (94 runs sampled)
using in obj (first item) x 1,295,422,306 ops/sec ±0.05% (100 runs sampled)
using Array.includes x 127,497,843 ops/sec ±0.51% (95 runs sampled)
using Array.includes (first item) x 148,103,651 ops/sec ±0.26% (95 runs sampled)
Using raw comparisson x 512,871,599 ops/sec ±35.76% (39 runs sampled)
Using raw comparisson (first item) x 145,327,537 ops/sec ±4.66% (79 runs sampled)

Comment thread lib/server.js Outdated
@climba03003 climba03003 requested a review from jsumners May 20, 2022 13:58
Comment thread lib/server.js Outdated
@climba03003 climba03003 requested a review from Fdawgs May 20, 2022 14:35
Comment thread docs/Reference/Routes.md Outdated
Comment thread lib/server.js Outdated
Co-authored-by: Frazer Smith <[email protected]>
Copy link
Copy Markdown
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@mcollina
Copy link
Copy Markdown
Member

Can you resolve the conflicts?

@mcollina mcollina merged commit ad0d31a into main May 21, 2022
@mcollina mcollina deleted the http-version-check branch May 21, 2022 18:09
@github-actions
Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http2 request to a http1 fastify server hits "default handler for 404 did not catch this, this is likely a fastify bug"

6 participants