-
Notifications
You must be signed in to change notification settings - Fork 725
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
serverapi:add rate limit for api #4235
Conversation
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
cb2c669
to
f755785
Compare
pkg/apiutil/serverapi/middleware.go
Outdated
@@ -123,6 +130,36 @@ func (h *redirector) ServeHTTP(w http.ResponseWriter, r *http.Request, next http | |||
NewCustomReverseProxies(client, urls).ServeHTTP(w, r) | |||
} | |||
|
|||
type apiLimit struct { | |||
bucket *ratelimit.Bucket | |||
capacity int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why needs to save capacity and rate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already delete these
Signed-off-by: qidi1 <1083369179@qq.com>
f755785
to
ffb8257
Compare
@@ -36,6 +36,8 @@ func NewHandler(ctx context.Context, svr *server.Server) (http.Handler, server.S | |||
router.PathPrefix(apiPrefix).Handler(negroni.New( | |||
serverapi.NewRuntimeServiceValidator(svr, group), | |||
serverapi.NewRedirector(svr), | |||
serverapi.NewAPILimit(svr.GetConfig().PDServerCfg.APIBucketCapacity, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APIBucketCapacity
and APIBucketRate
need to be defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These have been defined in PR #4234
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got
close tikv#4235 Signed-off-by: disksing <i@disksing.com>
Signed-off-by: qidi1 1083369179@qq.com
What problem does this PR solve?
Associated Issue:
ref:PD HTTP API self-protection #4207
What is changed and how it works?
add a middleware which used for rate limit for http request
Check List
Tests
Side effects
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tidb-ansible
:Release note