labring / FastGPT

FastGPT is a knowledge-based platform built on the LLMs, offers a comprehensive suite of out-of-the-box capabilities such as data processing, RAG retrieval, and visual AI workflow orchestration, letting you easily develop and deploy complex question-answering systems without the need for extensive setup or configuration.
https://tryfastgpt.ai
Other
17.45k stars 4.69k forks source link

多用户并发访问报错 Premature close #1632

Closed lktsuer closed 1 month ago

lktsuer commented 4 months ago

例行检查

你的版本

问题描述, 日志截图 多线程使用同一个api key,同时访问一个应用程序,导致应用程序报错。 使用同样的程序直接访问大模型接口,返回是正常的。 Fastgpt日志如下

fastgpt-test  | 188 new ObjectId("663ae44d3cca43f1faf05296")
fastgpt-test  | [INFO] 2024-05-29 08:59:13 [dispatchWorkFlow] nodeRunWithActive: AI 对话(知识库) 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 [dispatchWorkFlow] nodeRunWithSkip: AI 对话(通用) 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 152 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 81 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 119 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 0, token: 35 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 8, token: 2608 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 5, token: 141 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 196 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 69 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 152 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 208 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 116 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 155 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 0, token: 49 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 102 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 5, token: 2235 
fastgpt-test  | [ERROR] 2024-05-29 08:59:14 sse error: Premature close 
fastgpt-test  | {
fastgpt-test  |   message: 'Premature close',
fastgpt-test  |   stack: 'Error: Premature close\n' +
fastgpt-test  |     '    at IncomingMessage.<anonymous> (/app/projects/app/.next/server/chunks/15428.js:9:506432)\n' +
fastgpt-test  |     '    at Object.onceWrapper (node:events:628:28)\n' +
fastgpt-test  |     '    at IncomingMessage.emit (node:events:514:28)\n' +
fastgpt-test  |     '    at emitCloseNT (node:internal/streams/destroy:132:10)\n' +
fastgpt-test  |     '    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)'
fastgpt-test  | }
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Request finish /api/v1/chat/completions, time: 2779ms 
fastgpt-test  | [ERROR] 2024-05-29 08:59:14 sse error: Premature close 
fastgpt-test  | {
fastgpt-test  |   message: 'Premature close',
fastgpt-test  |   stack: 'Error: Premature close\n' +
fastgpt-test  |     '    at IncomingMessage.<anonymous> (/app/projects/app/.next/server/chunks/15428.js:9:506432)\n' +
fastgpt-test  |     '    at Object.onceWrapper (node:events:628:28)\n' +
fastgpt-test  |     '    at IncomingMessage.emit (node:events:514:28)\n' +
fastgpt-test  |     '    at emitCloseNT (node:internal/streams/destroy:132:10)\n' +
fastgpt-test  |     '    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)'
fastgpt-test  | }
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Request finish /api/v1/chat/completions, time: 1100ms 
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Count token time: 7, token: 2338 
fastgpt-test  | [INFO] 2024-05-29 08:59:14 completions running time: 3.023s 
fastgpt-test  | [INFO] 2024-05-29 08:59:14 finish completions {"source":"api","teamId":"66473178bae7715efc361fca","totalPoints":0}
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Request finish /api/v1/chat/completions, time: 3024ms 
fastgpt-test  | [ERROR] 2024-05-29 08:59:14 sse error: Premature close 
fastgpt-test  | {
fastgpt-test  |   message: 'Premature close',
fastgpt-test  |   stack: 'Error: Premature close\n' +
fastgpt-test  |     '    at IncomingMessage.<anonymous> (/app/projects/app/.next/server/chunks/15428.js:9:506432)\n' +
fastgpt-test  |     '    at Object.onceWrapper (node:events:628:28)\n' +
fastgpt-test  |     '    at IncomingMessage.emit (node:events:514:28)\n' +
fastgpt-test  |     '    at emitCloseNT (node:internal/streams/destroy:132:10)\n' +
fastgpt-test  |     '    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)'
fastgpt-test  | }
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Request finish /api/v1/chat/completions, time: 1381ms 

大模型报错如下:

INFO:     192.168.80.5:42760 - "POST /v1/chat/completions HTTP/1.1" 200 OK
INFO:     192.168.80.5:42770 - "POST /v1/chat/completions HTTP/1.1" 200 OK
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/site-packages/sse_starlette/sse.py", line 282, in __call__
    await wrap(partial(self.listen_for_disconnect, receive))
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/site-packages/sse_starlette/sse.py", line 271, in wrap
    await func()
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/site-packages/sse_starlette/sse.py", line 221, in listen_for_disconnect
    message = await receive()
              ^^^^^^^^^^^^^^^
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 568, in receive
    await self.message_event.wait()
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 7f55e6cdfd90

复现步骤 多用户访问即可 预期结果

相关截图

lijiajun1997 commented 4 months ago

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

lktsuer commented 4 months ago

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

大模型并发用的unicorn,开了10个worker,直连压测是OK的 请问咱多用户同时请求大模型的时候,会中断其他的sse连接,仅保留单个连接吗

c121914yu commented 4 months ago

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

大模型并发用的unicorn,开了10个worker,直连压测是OK的 请问咱多用户同时请求大模型的时候,会中断其他的sse连接,仅保留单个连接吗

肯定是每个请求一个哇,saas 版都能几百并发😂

lktsuer commented 4 months ago

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

大模型并发用的unicorn,开了10个worker,直连压测是OK的 请问咱多用户同时请求大模型的时候,会中断其他的sse连接,仅保留单个连接吗

肯定是每个请求一个哇,saas 版都能几百并发😂

我们就是开了10个大模型进程呀,然后同时进行10个请求,通过FastGPT中转之后老是报Premature close,如果直接连大模型的/v1/chat/completion接口就正常,大佬有什么好的建议嘛,感谢!

c121914yu commented 4 months ago

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

大模型并发用的unicorn,开了10个worker,直连压测是OK的 请问咱多用户同时请求大模型的时候,会中断其他的sse连接,仅保留单个连接吗

肯定是每个请求一个哇,saas 版都能几百并发😂

我们就是开了10个大模型进程呀,然后同时进行10个请求,通过FastGPT中转之后老是报Premature close,如果直接连大模型的/v1/chat/completion接口就正常,大佬有什么好的建议嘛,感谢!

不懂。。我们部署的模型还没遇到过这个问题,只有爆显存。