diff --git a/atsf_server/common/constants.go b/atsf_server/common/constants.go index 65a86e47..05f5bdb8 100644 --- a/atsf_server/common/constants.go +++ b/atsf_server/common/constants.go @@ -65,10 +65,13 @@ var OpenRestyKeepaliveTimeout = 65 var OpenRestyKeepaliveRequests = 1000 var OpenRestyClientHeaderTimeout = 15 var OpenRestyClientBodyTimeout = 15 +var OpenRestyClientMaxBodySize = "64m" +var OpenRestyLargeClientHeaderBuffers = "4 16k" var OpenRestySendTimeout = 30 var OpenRestyProxyConnectTimeout = 5 var OpenRestyProxySendTimeout = 60 var OpenRestyProxyReadTimeout = 60 +var OpenRestyProxyRequestBufferingEnabled = true var OpenRestyProxyBufferingEnabled = true var OpenRestyProxyBuffers = "16 16k" var OpenRestyProxyBufferSize = "8k" @@ -104,10 +107,13 @@ http { keepalive_requests {{OpenRestyKeepaliveRequests}}; client_header_timeout {{OpenRestyClientHeaderTimeout}}; client_body_timeout {{OpenRestyClientBodyTimeout}}; + client_max_body_size {{OpenRestyClientMaxBodySize}}; + large_client_header_buffers {{OpenRestyLargeClientHeaderBuffers}}; send_timeout {{OpenRestySendTimeout}}; proxy_connect_timeout {{OpenRestyProxyConnectTimeout}}; proxy_send_timeout {{OpenRestyProxySendTimeout}}; proxy_read_timeout {{OpenRestyProxyReadTimeout}}; + proxy_request_buffering {{OpenRestyProxyRequestBuffering}}; proxy_buffering {{OpenRestyProxyBuffering}}; proxy_buffers {{OpenRestyProxyBuffers}}; proxy_buffer_size {{OpenRestyProxyBufferSize}}; diff --git a/atsf_server/model/option.go b/atsf_server/model/option.go index a801a44c..93c5b175 100644 --- a/atsf_server/model/option.go +++ b/atsf_server/model/option.go @@ -64,10 +64,13 @@ func InitOptionMap() { common.OptionMap["OpenRestyKeepaliveRequests"] = strconv.Itoa(common.OpenRestyKeepaliveRequests) common.OptionMap["OpenRestyClientHeaderTimeout"] = strconv.Itoa(common.OpenRestyClientHeaderTimeout) common.OptionMap["OpenRestyClientBodyTimeout"] = strconv.Itoa(common.OpenRestyClientBodyTimeout) + common.OptionMap["OpenRestyClientMaxBodySize"] = common.OpenRestyClientMaxBodySize + common.OptionMap["OpenRestyLargeClientHeaderBuffers"] = common.OpenRestyLargeClientHeaderBuffers common.OptionMap["OpenRestySendTimeout"] = strconv.Itoa(common.OpenRestySendTimeout) common.OptionMap["OpenRestyProxyConnectTimeout"] = strconv.Itoa(common.OpenRestyProxyConnectTimeout) common.OptionMap["OpenRestyProxySendTimeout"] = strconv.Itoa(common.OpenRestyProxySendTimeout) common.OptionMap["OpenRestyProxyReadTimeout"] = strconv.Itoa(common.OpenRestyProxyReadTimeout) + common.OptionMap["OpenRestyProxyRequestBufferingEnabled"] = strconv.FormatBool(common.OpenRestyProxyRequestBufferingEnabled) common.OptionMap["OpenRestyProxyBufferingEnabled"] = strconv.FormatBool(common.OpenRestyProxyBufferingEnabled) common.OptionMap["OpenRestyProxyBuffers"] = common.OpenRestyProxyBuffers common.OptionMap["OpenRestyProxyBufferSize"] = common.OpenRestyProxyBufferSize @@ -240,6 +243,14 @@ func updateOptionMap(key string, value string) { if v, err := strconv.Atoi(value); err == nil && v > 0 { common.OpenRestyClientBodyTimeout = v } + case "OpenRestyClientMaxBodySize": + if strings.TrimSpace(value) != "" { + common.OpenRestyClientMaxBodySize = value + } + case "OpenRestyLargeClientHeaderBuffers": + if strings.TrimSpace(value) != "" { + common.OpenRestyLargeClientHeaderBuffers = value + } case "OpenRestySendTimeout": if v, err := strconv.Atoi(value); err == nil && v > 0 { common.OpenRestySendTimeout = v @@ -256,6 +267,8 @@ func updateOptionMap(key string, value string) { if v, err := strconv.Atoi(value); err == nil && v > 0 { common.OpenRestyProxyReadTimeout = v } + case "OpenRestyProxyRequestBufferingEnabled": + common.OpenRestyProxyRequestBufferingEnabled = value == "true" case "OpenRestyProxyBufferingEnabled": common.OpenRestyProxyBufferingEnabled = value == "true" case "OpenRestyProxyBuffers": diff --git a/atsf_server/web/features/performance/components/performance-page.tsx b/atsf_server/web/features/performance/components/performance-page.tsx index 0e9515fe..7172b713 100644 --- a/atsf_server/web/features/performance/components/performance-page.tsx +++ b/atsf_server/web/features/performance/components/performance-page.tsx @@ -61,6 +61,47 @@ const defaultPerformanceFields = { 'error timeout updating http_500 http_502 http_503 http_504', }; +const performanceFieldTooltips: Record = { + worker_processes: + 'Nginx worker 进程数。通常建议保持 auto,让 OpenResty 按 CPU 核数自动分配。', + worker_connections: + '每个 worker 可同时处理的最大连接数。值越大,可承载的并发连接越多。', + worker_rlimit_nofile: + '提升 worker 可打开的文件描述符上限,避免高并发下连接或文件句柄不足。', + events_use: + '指定事件驱动模型。Linux 常见是 epoll,留空时由 OpenResty 自动选择。', + multi_accept: + '开启后,worker 会尽可能一次接受多个新连接,适合高吞吐接入场景。', + keepalive_timeout: '客户端 Keep-Alive 空闲保持时间,单位秒。', + keepalive_requests: '单个长连接允许复用的最大请求数。', + client_header_timeout: '读取客户端请求头的超时时间,单位秒。', + client_body_timeout: '读取客户端请求体的超时时间,单位秒。', + send_timeout: '向客户端发送响应时的超时时间,单位秒。', + proxy_connect_timeout: '连接上游源站的超时时间,单位秒。', + proxy_send_timeout: '向上游发送请求的超时时间,单位秒。', + proxy_read_timeout: '等待上游返回响应的超时时间,单位秒。', + proxy_buffering: + '控制是否启用代理响应缓冲。开启后通常有更平滑的吞吐,但会增加内存占用。', + proxy_buffers: '设置代理响应缓冲区的数量和大小,例如 16 16k。', + proxy_buffer_size: '保存响应头等小块数据的基础缓冲区大小。', + proxy_busy_buffers_size: '限制 busy 状态下可同时占用的缓冲区总大小。', + gzip: '控制是否启用 gzip 压缩响应。', + gzip_min_length: + '只有响应体超过该字节数时才会启用 gzip,避免对极小响应做无意义压缩。', + gzip_comp_level: 'gzip 压缩等级,1 更省 CPU,9 压缩更高但更耗 CPU。', + proxy_cache_path: '缓存目录路径,对应 proxy_cache_path 指令中的磁盘位置。', + levels: '缓存目录层级,例如 1:2,可控制缓存文件的目录分布。', + inactive: '缓存对象在未命中访问时的失活时间,例如 30m。', + max_size: + '缓存目录允许占用的最大磁盘空间,会渲染到 proxy_cache_path 的 max_size。', + cache_key_template: '生成缓存 Key 的模板,决定不同请求如何命中同一缓存对象。', + proxy_cache_lock: + '启用后,同一缓存 Key 未命中时只允许一个请求回源,减少击穿。', + proxy_cache_lock_timeout: '等待缓存锁的最长时间,例如 5s。', + proxy_cache_use_stale: + '上游异常时允许返回旧缓存的条件列表,例如 error、timeout、http_500。', +}; + type PerformanceTab = 'settings' | 'editor'; type FeedbackState = { @@ -609,7 +650,10 @@ export function PerformancePage() { } >
- + @@ -621,7 +665,10 @@ export function PerformancePage() { placeholder="auto" /> - + - + - + @@ -665,6 +719,7 @@ export function PerformancePage() { setPerformanceFields((previous) => ({ @@ -673,7 +728,10 @@ export function PerformancePage() { })) } /> - + - + - + - + - +
- + - + - + setPerformanceFields((previous) => ({ @@ -800,7 +880,10 @@ export function PerformancePage() { })) } /> - + @@ -812,7 +895,10 @@ export function PerformancePage() { placeholder="16 16k" /> - + @@ -824,7 +910,10 @@ export function PerformancePage() { placeholder="8k" /> - + @@ -860,6 +949,7 @@ export function PerformancePage() { setPerformanceFields((previous) => ({ @@ -882,7 +972,10 @@ export function PerformancePage() {

)}
- + - + - + - + - + - + @@ -1099,7 +1209,12 @@ export function PerformancePage() { })) } /> - + - + - {label} - {children} - {error ? ( - {error} - ) : hint ? ( - {hint} - ) : null} - - ); -} - -export function ResourceInput(props: InputHTMLAttributes) { - return ( - - ); -} - -export function ResourceTextarea(props: TextareaHTMLAttributes) { - return ( -