Comments (5)
这个issue解决了不必要的response,是否能再加个功能,避免不必要的request,即:
用户的service可能是同步实现,因为过载而导致堵塞。server端收到request后,要排队调用用户的service,在真正调用用户service前,请求可能已经超时,这时候继续调用用户的service,产生response,再丢弃,其实也是很浪费的。
from sofa-pbrpc.
GREAT WORK!
from sofa-pbrpc.
@bluebore ,我明白你的意思,我要说几点:
- server端其实是没有队列的,我们的server端线程模型是work线程既负责处理网络IO也负责处理服务,因此是没有显式的等待队列的;如果有work线程空闲,它就会从socket中读取request数据(通过epoll的方式),然后立即处理它;
- 但并不是说server端request就不会等待,实际上,work线程从socket中有可能一次性读取到多个request,这取决于epoll一次返回多少数据,有可能多个request合并成一个数据块返回。如果一次获取了多个request,目前做发是逐个串行执行,参见RpcServerMessageStream::on_read_some()函数:
... ...
// process messages
while (!is_closed() && !received_messages.empty())
{
on_received(received_messages.front());
received_messages.pop_front();
}
... ...
- 因此从work线程读取到request到真正开始执行request之间确实是可能有一段时间延迟的,这个延迟就是在其之前执行的同一批request的执行时间之和。
- 目前RpcControllerImpl中针对server端记录了这三个时间点:_request_received_time、_start_process_time、_finish_process_time。通过计算 server_wait_time = _start_process_time - _request_received_time 可以得到在server端的等待时间。如果server_wait_time >= server_timeout,那么就可以放弃执行了。
- 另外在client端,从开始计时到开始发送之间也可能在pending buffer中排队,这段时间记为client_wait_time,那么client传递给server的server_timeout实际上要减去这段时间才更准确,即server_timeout = client_timeout - client_wait_time。现在没有减去client_wait_time,是因为server_timeout是存放在RpcMeta中,而RpcMeta在放入pending buffer之前就需要序列化到buffer中,在后面发送时很难修改。除非我们的序列化操作推迟到发送时再做。
from sofa-pbrpc.
赞这个主题!
可以考虑把用户最初掉用rpc的start_time和time_out附带上,在真正发送rpc时判断一下超时;
对端收到请求时记录一下receive_time,处理过程中或者response时都可判断一下是否已经超时
from sofa-pbrpc.
参见#86 ,目前已经考虑了server_wait_time,现在就差client_wait_time需要考虑了
from sofa-pbrpc.
Related Issues (20)
- sofa-server端耗时异常
- sofa-client请求超时之后不关闭tcp连接导致同一个连接上请求连续超时 HOT 1
- try_start_receive是否可以省略_receive_token
- RpcServerMessageStream和RpcMessageStream类是否可抽取公共父类
- boost async_write_some可否用async_write替换 HOT 1
- sofa-pbrpc 需要引入可配置参数
- 客户端超时设置 HOT 2
- sofa-pbrpc-client health超时
- Too many threads in sofa ,how use epoll to overlap large number of socket events HOT 2
- sofa使用snapy压缩请求体大小为100+K时解压缩出错 HOT 5
- GOOGLE_ATTRIBUTE_DEPRECATED 替换成 __attribute__((deprecated)) HOT 2
- 什么时候支持window? HOT 2
- CPU使用问题 HOT 3
- 内存问题 HOT 2
- server如何主动向client发送消息? HOT 1
- bugs on weak memory model arch.(arm/power)
- server端如何主动发消息?
- 关于volatile变量相关的问题
- 有没有这种服务互相调用的方法
- cross compile error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sofa-pbrpc.