客户端SDK性能问题 #1066
Unanswered
Lucifer-ck
asked this question in
Q&A
客户端SDK性能问题
#1066
Replies: 3 comments 9 replies
-
|
你把SDK_GenerateKeyPair_ECC封装成了一个同步阻塞调用的函数,然后放到线程池里面执行,那么线程就会被同步阻塞,并发上限等于线程池中的线程数,导致高并发场景下的性能下降。
async_simple::coro::Lazy<int> SDK_GenerateKeyPair_ECC(...);
async_simple::coro::Future<int> SDK_GenerateKeyPair_ECC_async(...) {
async_simple::coro::Promise<int> p;
auto fut=p.getFuture();
my_work().start([p=std::move(p)](auto && ret){
p.set_value(ret.value());
});
co_return fut;
}
Lazy<void> call() {
//....
for (std::size_t i=0;i<10000;++i) {
auto future = SDK_GenerateKeyPair_ECC_async();
// 除非有重计算任务,否则直接等待future即可。
co_await std::move(future);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
我们需要对外提供标准的c同步接口,根据标准中定义的接口参数,无法自定义接口参数,那这种使用同步异步回调就不行了吧?另外测试过程中发现如果用两台客户端压一个客户端是可以将性能拉满的。单客户端只是封装了同步接口后压测性能就有损耗,线程池内的线程数量多配置点。性能反而下来了。这种情况有没有更好解决方案 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
同步接口的话,可以创建多个client代理,内部使用同一个client pool也行,几个client就相当于几个并发,并发高一点就能拉满了。 |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
RPC调用



SDK接口
性能测试
客户端封装成SDK后,性能测试压力上不去了,像这种将客户端RPC调用封装成SDK接口的形式,客户端要如何调用才能保证像下面这种直接在RPC调用时进行并发请求产生的压力呢?
直接使用thread池调用时,也是相同的结果。
Beta Was this translation helpful? Give feedback.
All reactions