Skip to content

[Cherry-Pick][Optimization]Change default workers and max-concurrency when launch api-server(#7457)#7516

Open
EmmonsCurse wants to merge 1 commit intoPaddlePaddle:release/2.6from
EmmonsCurse:cherry-pick/7457/release/2.6
Open

[Cherry-Pick][Optimization]Change default workers and max-concurrency when launch api-server(#7457)#7516
EmmonsCurse wants to merge 1 commit intoPaddlePaddle:release/2.6from
EmmonsCurse:cherry-pick/7457/release/2.6

Conversation

@EmmonsCurse
Copy link
Copy Markdown
Collaborator

Cherry-pick of #7457 (authored by @K11OntheBoat) to release/2.6.

devPR:#7457


Motivation

API-Server 启动服务时,将workers默认从1改为4,服务最大concurrency同步改为2048. 避免了GPU 运行快,但是请求不足的性能瓶颈. Blackwell架构,长输入短输出数据,512并发场景,GLM4.5-Air模型TPS提升1.74倍.
multi_api_server中这两个参数保持不变.

Modifications

API-Server 启动服务时,将workers默认从1改为4,服务最大concurrency同步改为2048.

Checklist

  • Add at least a tag in the PR title.
  • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
  • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 20, 2026

Thanks for your contribution!

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Code Review | 2026-04-20 16:04 CST

📋 Review 摘要

PR 概述:将 API-Server 启动时 --workers 默认值从 1 改为 4,--max-concurrency 从 512 改为 2048,以提升单 API-Server 场景下的吞吐性能;multi_api_server 模式下保持原有默认值不变。
变更范围entrypoints/api_server.pyentrypoints/openai/utils.py
影响面 TagAPIServer Optimization

问题

级别 文件 概述
🟡 建议 openai/utils.py:344 环境变量读取方式与项目规范不一致

🟡 建议:环境变量读取方式不一致(utils.py:344

当前代码使用 os.environ.get("FD_ENABLE_MULTI_API_SERVER") == "1" 直接读取环境变量,而项目中所有其他位置engine/engine.pyengine/args_utils.pyworker/worker_process.py 等)均通过统一的 fastdeploy.envs.FD_ENABLE_MULTI_API_SERVER 访问。

虽然功能上等价,但直接使用 os.environ.get() 存在以下隐患:

  1. 一致性:绕过了 envs 模块的统一管理,后续如果 envs 中对该变量增加校验或默认值变更,此处不会同步生效。
  2. 可维护性:搜索该环境变量的使用方时容易遗漏此处。

建议修改为:

from fastdeploy import envs

def make_arg_parser(parser: FlexibleArgumentParser) -> FlexibleArgumentParser:
    _is_multi_server = envs.FD_ENABLE_MULTI_API_SERVER
    ...

总体评价

变更逻辑清晰,两个入口文件的修改保持了一致性(api_server.py 固定 workers=4,utils.py 根据是否为 multi_api_server 模式动态选择默认值)。建议统一环境变量的读取方式以提高可维护性。



def make_arg_parser(parser: FlexibleArgumentParser) -> FlexibleArgumentParser:
_is_multi_server = os.environ.get("FD_ENABLE_MULTI_API_SERVER") == "1"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 环境变量读取方式与项目规范不一致

当前使用 os.environ.get("FD_ENABLE_MULTI_API_SERVER") == "1" 直接读取环境变量,而项目中其他所有位置(engine/engine.pyengine/args_utils.pyworker/worker_process.py 等)均通过 fastdeploy.envs.FD_ENABLE_MULTI_API_SERVER 统一访问。

建议改为:

from fastdeploy import envs

_is_multi_server = envs.FD_ENABLE_MULTI_API_SERVER

这样可以保持一致性,且后续 envs 模块若增加校验逻辑也能自动生效。

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.

3 participants