HTTP协议下,当返回数据较大时,reponse发送延迟极大且并行请求会一起堵塞很久

Open
#2,848 11 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start by reproducing the HTTP server case using the shown response_attachment() and http_response() calls with 100 MB and 1 GB values. Compare one request with 50 concurrent requests on the stated Ubuntu, GCC, and brpc versions, recording server-side and client-observed timings. Done means the cause of the delayed or blocked responses is identified and the large-response behavior is measurably improved or clearly documented.

Written by the indexing model from the issue text.

Description

Describe the bug (描述bug)
HTTP协议的server下,如果请求返回的数据较大时,数据返回延迟过高(不是rpc方法延迟,方法内无阻塞,延迟经测试很低)。返回数据100mb时,并行50个请求需要等到很久后(45s)同时发出的请求才会陆续收到回报,显著慢于只打一个请求(1.3s), 单个请求返回1GB时耗时10s显著慢于网卡的吞吐

To Reproduce (复现方法)
http协议的server返回内容如下,value为大小为100MB或1GB的字符串

std::string value(1024*1024*100, 'a'); 
cntl->http_response().set_status_code(200);
cntl->http_response().set_content_type("text/plain");
cntl->response_attachment().append(value.c_str(), value.length());

打http请求

Expected behavior (期望行为)
当并发50个http请求,返回value为100MB时,50个请求在发出请求45秒后统一陆续返回。如果只有一个请求,返回value 100MB只需要1.3s。

一次请求,如果返回value为1GB,leave method耗时要10多s(不考虑rpc方法内的时间),请求端很久收到返回,延迟过高。
Versions (各种版本)
OS: ubuntu20
Compiler: gcc13
brpc: 1.11.0
protobuf: 3.21.12

Additional context/screenshots (更多上下文/截图)

Dominant language
C++
Stars
17.6k
Forks
4.2k
Avg merge
3d 17h
Merged PRs (30d)
72

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/brpc

All issues in apache/brpc

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.