Skip to main content

LiteLLM代理 - Locust负载测试

Locust负载测试 LiteLLM代理

  1. 在您的代理配置文件config.yaml中添加fake-openai-endpoint,并启动您的LiteLLM代理 LiteLLM提供了一个免费的托管fake-openai-endpoint,您可以针对其进行负载测试
model_list:
- model_name: fake-openai-endpoint
litellm_params:
model: openai/fake
api_key: fake-key
api_base: https://exampleopenaiendpoint-production.up.railway.app/
  1. pip install locust

  2. 在您的本地机器上创建一个名为locustfile.py的文件。从LiteLLM负载测试文件中复制内容,该文件位于此处

  3. 启动Locust 在步骤2中的locustfile.py所在目录下运行locust

    locust

    终端输出

    [2024-03-15 07:19:58,893] 启动Web接口于 http://0.0.0.0:8089
    [2024-03-15 07:19:58,898] 启动Locust 2.24.0
  4. 在Locust上运行负载测试

    访问Locust UI于 http://0.0.0.0:8089

    设置用户数=100,用户增长数=10,主机=LiteLLM代理的基本URL

  5. 预期结果

    预期看到以下/health/readiness的响应时间 中位数 → /health/readiness 是 150ms

    平均值 → /health/readiness 是 219ms