mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-29 03:51:54 +08:00
fix: backend proxy worker count (#22400)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -74,7 +74,7 @@ func (app *Application) InitHandlers() *Application {
|
||||
if options.Options.EnableBackendServiceProxy {
|
||||
// bind backend service API proxy
|
||||
log.Infof("enable backend service proxy")
|
||||
app.BackendServiceProxyHandler = handler.NewBackendServiceProxyHandler("/api/s/<service>")
|
||||
app.BackendServiceProxyHandler = handler.NewBackendServiceProxyHandler("/api/s/<service>", options.Options.BackendProxyReadWorkerCount, options.Options.BackendProxyWriteWorkerCount)
|
||||
}
|
||||
|
||||
app.CloudIdSAMLHandler = handler.NewProxyHandlerWithService(cloudid.SAML_IDP_PREFIX, cloudid.SERVICE_TYPE)
|
||||
|
||||
@@ -33,11 +33,18 @@ import (
|
||||
|
||||
type SBackendServiceProxyHandler struct {
|
||||
prefix string
|
||||
|
||||
readWorker *appsrv.SWorkerManager
|
||||
writeWorker *appsrv.SWorkerManager
|
||||
}
|
||||
|
||||
func NewBackendServiceProxyHandler(prefix string) *SBackendServiceProxyHandler {
|
||||
func NewBackendServiceProxyHandler(prefix string, readWorkerCount, writeWorkerCount int) *SBackendServiceProxyHandler {
|
||||
log.Infof("NewBackendServiceProxyHandler: %s, readWorkerCount: %d, writeWorkerCount: %d", prefix, readWorkerCount, writeWorkerCount)
|
||||
return &SBackendServiceProxyHandler{
|
||||
prefix: prefix,
|
||||
|
||||
readWorker: appsrv.NewWorkerManager("apigateway-backend-api-read", readWorkerCount, appsrv.DEFAULT_BACKLOG, false),
|
||||
writeWorker: appsrv.NewWorkerManager("apigateway-backend-api-write", writeWorkerCount, appsrv.DEFAULT_BACKLOG, false),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +103,9 @@ func (h *SBackendServiceProxyHandler) Bind(app *appsrv.Application) {
|
||||
}
|
||||
var worker *appsrv.SWorkerManager
|
||||
if method == "GET" || method == "HEAD" {
|
||||
worker = appsrv.NewWorkerManager("apigateway-backend-api-read", 8, appsrv.DEFAULT_BACKLOG, false)
|
||||
worker = h.readWorker
|
||||
} else {
|
||||
worker = appsrv.NewWorkerManager("apigateway-backend-api-write", 4, appsrv.DEFAULT_BACKLOG, false)
|
||||
worker = h.writeWorker
|
||||
}
|
||||
hi.SetWorkerManager(worker)
|
||||
return hi
|
||||
|
||||
@@ -44,7 +44,9 @@ type GatewayOptions struct {
|
||||
DisableReporting bool `default:"false" help:"Reporting data every 24 hours, report data incloud version, os, platform and usages"`
|
||||
|
||||
// 启用后端服务反向代理网关
|
||||
EnableBackendServiceProxy bool `default:"false" help:"Proxy API request to backend services"`
|
||||
EnableBackendServiceProxy bool `default:"true" help:"Proxy API request to backend services"`
|
||||
BackendProxyReadWorkerCount int `default:"8" help:"Request worker thread count, default is 8"`
|
||||
BackendProxyWriteWorkerCount int `default:"4" help:"Request worker thread count, default is 4"`
|
||||
|
||||
common_options.CommonOptions `"request_worker_count->default":"32"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user