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

NIOAsyncChannel based HTTP server #269

Merged
merged 33 commits into from
Nov 18, 2023
Merged

NIOAsyncChannel based HTTP server #269

merged 33 commits into from
Nov 18, 2023

Conversation

adam-fowler
Copy link
Member

@adam-fowler adam-fowler commented Nov 7, 2023

HTTP server using NIOAsyncChannel. This requires a bunch a changes. I'll update this PR as they are done

  • NIOAsyncChannel HTTP server
  • TLS
  • Transport services
  • Hummingbird integration
  • HTTP2

@adam-fowler adam-fowler marked this pull request as draft November 7, 2023 09:55
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Attention: 48 lines in your changes are missing coverage. Please review.

Comparison is base (d2403d1) 83.87% compared to head (1d5c5f9) 85.12%.
Report is 1 commits behind head on 2.x.x.

Files Patch % Lines
Sources/HummingbirdCore/Server/Server.swift 84.69% 30 Missing ⚠️
...mmingbirdCore/Server/HTTP/HTTPChannelHandler.swift 92.00% 6 Missing ⚠️
Sources/HummingbirdCore/Request/RequestBody.swift 88.00% 3 Missing ⚠️
.../HummingbirdCore/Server/HTTPUserEventHandler.swift 95.38% 3 Missing ⚠️
...ources/Hummingbird/Middleware/CORSMiddleware.swift 66.66% 1 Missing ⚠️
Sources/Hummingbird/Router/ResponseGenerator.swift 80.00% 1 Missing ⚠️
...ources/HummingbirdCore/Response/HTTPResponse.swift 85.71% 1 Missing ⚠️
...ces/HummingbirdCore/Server/HTTP/HTTP1Channel.swift 96.15% 1 Missing ⚠️
Sources/HummingbirdTLS/TLSChannelSetup.swift 96.66% 1 Missing ⚠️
Sources/HummingbirdXCT/HBXCTRouter.swift 97.36% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            2.x.x     #269      +/-   ##
==========================================
+ Coverage   83.87%   85.12%   +1.25%     
==========================================
  Files          83       78       -5     
  Lines        5301     4565     -736     
==========================================
- Hits         4446     3886     -560     
+ Misses        855      679     -176     

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

@adam-fowler adam-fowler marked this pull request as ready for review November 8, 2023 08:49
@adam-fowler
Copy link
Member Author

There's something wrong with the core server. Its performance is really poor on Linux

.github/workflows/ci.yml Show resolved Hide resolved
Sources/Hummingbird/Middleware/CORSMiddleware.swift Outdated Show resolved Hide resolved
Sources/Hummingbird/Server/Application+HTTPResponder.swift Outdated Show resolved Hide resolved
Sources/Hummingbird/Server/RequestContext.swift Outdated Show resolved Hide resolved
Sources/HummingbirdCore/Server/HTTPUserEventHandler.swift Outdated Show resolved Hide resolved
Sources/HummingbirdCore/Server/HTTPUserEventHandler.swift Outdated Show resolved Hide resolved
* Use new NIOAsyncChannel.executeThenClose api

* fix tabbing
Copy link
Member

@Joannis Joannis left a comment

Choose a reason for hiding this comment

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

One small comment I just noticed

@@ -21,7 +21,7 @@ let hostname = HBEnvironment.shared.get("SERVER_HOSTNAME") ?? "127.0.0.1"
let port = HBEnvironment.shared.get("SERVER_PORT", as: Int.self) ?? 8080

// create app
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 2)
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 8)
Copy link
Member

Choose a reason for hiding this comment

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

Can we use System.coreCount here instead?

Copy link
Member

Choose a reason for hiding this comment

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

Or NIOSingletons.posixEventLoopGroup

Copy link
Member

Choose a reason for hiding this comment

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

Or NIOSingletons.posixEventLoopGroup

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to use a set number here, which doesn't use all the machines cores. I tend to use this with wrk for performance testing. I need to assign some cores to wrk otherwise it'll clash with the server and results will be inconsistent.

Although that number should be 4 and not 8. Performance seems to top out at 4 cores on macOS for some reason. Possibly related to the limited number of connections you can make on macOS.

@adam-fowler adam-fowler merged commit 94e433e into 2.x.x Nov 18, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants