Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gin): support both http/2 and http/3 using quic-go/quic-go #3973

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xN4P4LM
Copy link

@xN4P4LM xN4P4LM commented May 19, 2024

53c1160

Update quick-go and add support for both TLS/TCP and QUIC connections in parallel using RunTLSAndQUIC

- Bump github.com/quic-go/quic-go from v0.43.1 to v0.44.0 and dependencies
- Created new func RunTLSAndQUIC to run both TLS/TCP and QUIC in parallel

e67f1e9

Updated intgration tests to support HTTP/3

- Added new test for RunTLSAndQUIC
- Added support for HTTP/3 with future tests

Latency Testing using RunTLSAndQUIC (this is not perfect or real world):

2024/05/20 09:44:32 Average time for HTTP/3: 2.278181ms
2024/05/20 09:44:32 Average time for HTTP/2: 2.012242ms
2024/05/20 09:44:32 Average time for HTTP/1.1: 1.589074ms

Using RunTLSAndQUIC:

  • Client:
2024/05/20 09:46:31 HTTP/3:
2024/05/20 09:46:31 GET https://localhost:8080
2024/05/20 09:46:31 Got response for https://localhost:8080: "HTTP/3.0"
2024/05/20 09:46:31 Response Body:
{"links":[{"name":"Home","url":"/"},{"name":"Resume","url":"/resume/"},{"name":"Resources","url":"/resources/"},{"name":"Projects","url":"/projects/"},{"name":"Blog","url":"/blog/"},{"name":"About","url":"/about/"}]}
2024/05/20 09:46:31 HTTP/2:
2024/05/20 09:46:31 GET https://localhost:8080
2024/05/20 09:46:31 Got response for https://localhost:8080: "HTTP/2.0"
2024/05/20 09:46:31 Response Body:
{"links":[{"name":"Home","url":"/"},{"name":"Resume","url":"/resume/"},{"name":"Resources","url":"/resources/"},{"name":"Projects","url":"/projects/"},{"name":"Blog","url":"/blog/"},{"name":"About","url":"/about/"}]}
2024/05/20 09:46:31 HTTP/1.1:
2024/05/20 09:46:31 GET https://localhost:8080
2024/05/20 09:46:31 Got response for https://localhost:8080: "HTTP/1.1"
2024/05/20 09:46:31 Response Body:
{"links":[{"name":"Home","url":"/"},{"name":"Resume","url":"/resume/"},{"name":"Resources","url":"/resources/"},{"name":"Projects","url":"/projects/"},{"name":"Blog","url":"/blog/"},{"name":"About","url":"/about/"}]}
  • Server:
[GIN] 2024/05/20 - 09:46:31 | 200 |      27.844µs |       127.0.0.1 | GET      "/"
[GIN] 2024/05/20 - 09:46:31 | 200 |      16.351µs |       127.0.0.1 | GET      "/"
[GIN] 2024/05/20 - 09:46:31 | 200 |       5.029µs |       127.0.0.1 | GET      "/"

Using RunQUIC:

  • Client:
2024/05/20 09:48:42 HTTP/3:
2024/05/20 09:48:42 GET https://localhost:8080
2024/05/20 09:48:42 Got response for https://localhost:8080: "HTTP/3.0"
2024/05/20 09:48:42 Response Body:
{"links":[{"name":"Home","url":"/"},{"name":"Resume","url":"/resume/"},{"name":"Resources","url":"/resources/"},{"name":"Projects","url":"/projects/"},{"name":"Blog","url":"/blog/"},{"name":"About","url":"/about/"}]}
2024/05/20 09:48:42 HTTP/2:
2024/05/20 09:48:42 GET https://localhost:8080
2024/05/20 09:48:42 Get "https://localhost:8080": dial tcp [::1]:8080: connect: connection refused
2024/05/20 09:48:42 HTTP/1.1:
2024/05/20 09:48:42 GET https://localhost:8080
2024/05/20 09:48:42 Get "https://localhost:8080": dial tcp [::1]:8080: connect: connection refused
  • Server:
[GIN] 2024/05/20 - 09:48:42 | 200 |      52.529µs |       127.0.0.1 | GET      "/"

  • With pull requests:
    • Open your pull request against master
    • Your pull request should have no more than two commits, if not you should squash them.
    • It should pass all tests in the available continuous integration systems such as GitHub Actions.
    • You should add/modify tests to cover your proposed code changes.
    • If your pull request contains a new feature, please document it on the README.

Signed-off-by: Diana Moore dmoore@xn4p4lm.com

…ections in parallel using RunTLSAndQUIC

- Bump github.com/quic-go/quic-go from v0.43.1 to v0.44.0 and dependencies
- Created new func RunTLSAndQUIC to run both TLS/TCP and QUIC in parallel

Signed-off-by: Diana Moore <dmoore@xn4p4lm.com>
- Added new test for RunTLSAndQUIC
- Added support for HTTP/3 with future tests

Signed-off-by: Diana Moore <dmoore@xn4p4lm.com>
Copy link

codecov bot commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.05%. Comparing base (3dc1cd6) to head (e67f1e9).
Report is 67 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3973      +/-   ##
==========================================
- Coverage   99.21%   99.05%   -0.16%     
==========================================
  Files          42       44       +2     
  Lines        3182     2759     -423     
==========================================
- Hits         3157     2733     -424     
+ Misses         17       15       -2     
- Partials        8       11       +3     
Flag Coverage Δ
?
-tags "sonic avx" 99.05% <100.00%> (?)
-tags go_json 99.05% <100.00%> (?)
-tags nomsgpack 99.04% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 99.05% <100.00%> (-0.16%) ⬇️
go-1.22 99.05% <100.00%> (?)
macos-latest 99.05% <100.00%> (-0.16%) ⬇️
ubuntu-latest 99.05% <100.00%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xN4P4LM xN4P4LM changed the title feat(gin): support both http2 and http3 using quic-go/quic-go feat(gin): support both http/2 and http/3 using quic-go/quic-go May 20, 2024
// both TLS/TCP and QUIC connections in parallel requests.
// It is a shortcut for http3.ListenAndServe(addr, certFile, keyFile, router)
// Note: this method will block the calling goroutine indefinitely unless an error happens.
func (engine *Engine) RunTLSAndQUIC(addr, certFile, keyFile string) (err error) {
Copy link
Member

Choose a reason for hiding this comment

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

maybe we should keep RunQUIC func and replace http3.ListenAndServeQUIC with http3.ListenAndServeTLS

Copy link
Author

@xN4P4LM xN4P4LM May 21, 2024

Choose a reason for hiding this comment

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

That might be a good alternative, but could there be any situations where you would only want to provide just QUIC?

I could see a potential for for mobile first applications with high retry and latency requirements.

@bound2
Copy link

bound2 commented May 23, 2024

cc @marten-seemann for visibility

Copy link

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

Using http3.ListenAndServerTLS is fine, if you don't need a lot of control over the HTTP(/3) server spawned.

Most importantly:

If you want more control, you can initialize a http3.Server, which exposes a bunch of configuration options, and a Close method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants