apache / apache/brpc

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

Open
#2,848 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

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 (更多上下文/截图)**

Contributor guide

Open the contributing guide

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.

Assessment

Tech stack
cpp
Domain
backend-api-design, networking, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.