-
Notifications
You must be signed in to change notification settings - Fork 4
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
issues/324: When an acme challenge request is malformed, fail the request #326
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Owner
komuw
commented
Jul 15, 2023
- Updates: ong/acme: well-known/acme-challenge rate limited #324
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #326 +/- ##
==========================================
- Coverage 74.41% 74.19% -0.22%
==========================================
Files 43 43
Lines 4878 4891 +13
==========================================
- Hits 3630 3629 -1
- Misses 1002 1016 +14
Partials 246 246
☔ View full report in Codecov by Sentry. |
komuw
added a commit
that referenced
this pull request
Jul 15, 2023
…uest (#326) - Most of the time in the acme challenge handler is spent on reading file from disk. Out of a total of 23 seconds, 5seconds is spent reading from disk. That is over `b.N * 10` iterations. So for one http request, the time is negligible. So this should not really cause the handler to be loadshedded. go test -run=XXXX -bench=BenchmarkHandler -count=10 github.com/komuw/ong/internal/acme -cpuprofile=cpu.out -memprofile=mem.out go tool pprof acme.test cpu.out (pprof) list acme.Handler Total: 23.23s ROUTINE ======================== github.com/komuw/ong/internal/acme.Handler.func1 in /home/komuw/mystuff/ong/internal/acme/acme.go 10ms 7.30s (flat, cum) 31.42% of Total . . 154: return func(w http.ResponseWriter, r *http.Request) { . . 159: { // error cases . 10ms 160: isTls := strings.EqualFold(r.URL.Scheme, "https") || r.TLS != nil . . 161: if isTls { . 10ms 187: if strings.Contains(domain, ":") { . . 201: . 310ms 202: certPath := filepath.Join(diskCacheDir, domain, tokenFileName) . 5.67s 203: tok, errE := os.ReadFile(certPath) . . 212: 10ms 1.30s 213: _, _ = w.Write(tok) (pprof) exit - We have however made a change so that bad requests to the acme challenge handler are failed promptly instead of falling through to the application handler. This should help in minimizing the time taken in the acme handler. - Updates: #324
komuw
added a commit
that referenced
this pull request
Jul 16, 2023
…uest (#326) - Most of the time in the acme challenge handler is spent on reading file from disk. Out of a total of 23 seconds, 5seconds is spent reading from disk. That is over `b.N * 10` iterations. So for one http request, the time is negligible. So this should not really cause the handler to be loadshedded. go test -run=XXXX -bench=BenchmarkHandler -count=10 github.com/komuw/ong/internal/acme -cpuprofile=cpu.out -memprofile=mem.out go tool pprof acme.test cpu.out (pprof) list acme.Handler Total: 23.23s ROUTINE ======================== github.com/komuw/ong/internal/acme.Handler.func1 in /home/komuw/mystuff/ong/internal/acme/acme.go 10ms 7.30s (flat, cum) 31.42% of Total . . 154: return func(w http.ResponseWriter, r *http.Request) { . . 159: { // error cases . 10ms 160: isTls := strings.EqualFold(r.URL.Scheme, "https") || r.TLS != nil . . 161: if isTls { . 10ms 187: if strings.Contains(domain, ":") { . . 201: . 310ms 202: certPath := filepath.Join(diskCacheDir, domain, tokenFileName) . 5.67s 203: tok, errE := os.ReadFile(certPath) . . 212: 10ms 1.30s 213: _, _ = w.Write(tok) (pprof) exit - We have however made a change so that bad requests to the acme challenge handler are failed promptly instead of falling through to the application handler. This should help in minimizing the time taken in the acme handler. - Updates: #324
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.