在等待状态中
我们使用Micronaut框架开发了我们的服务。早些时候,我们使用20个线程的Eventloop配置了默认配置。我们注意到很多线程都处于阻塞状态。如下图所示。
进行了一些分析后发现,由于我们的客户端呼叫花费时间,我们应该为客户端调用创建单独的Eventloop。按照微守年的文档化: https:// https://docs.micronaut.io/latest/guide/guide/guide/guide/guide/udguide/pguide/pguide/pguide/pguide/unp clientconfiguration - >第7.1节 - >配置事件循环组。我们更新了以下配置:
http:
client:
event-loop-group: client
read-timeout: 5m
timeout: 5m
max-content-length: '100MB'
netty:
event-loops:
default:
num-threads: 25
prefer-native-transport: true
client:
num-threads: 25
prefer-native-transport: true
使用上述配置,我们注意到很少有RXCACHEDTHREADSCHEDULER线程,Wehereas,我们看到了很多OKHTTP任务Runner线程在阻止状态中。我无法理解所有过程的工作原理,为什么我们看到的RXCACHEDTHREADSCHEDULER线程和许多OKHTTP任务Runner线程在阻止状态下。
We have our service developed using the micronaut framework. Earlier we had default configuration for EventLoop with 20 threads. We were noticing a lot of thread were going in blocking state. As we can see in the below image.
After doing some analysis found that since our client calls were taking time, we should create separate eventloop for the client calls. As per the micronaut documenation : https://docs.micronaut.io/latest/guide/#clientConfiguration -> section 7.1 -> Configuring Event Loop Groups . We updated our configuration as below :
http:
client:
event-loop-group: client
read-timeout: 5m
timeout: 5m
max-content-length: '100MB'
netty:
event-loops:
default:
num-threads: 25
prefer-native-transport: true
client:
num-threads: 25
prefer-native-transport: true
With the above configuration, we noticed that we see very few RxCachedThreadScheduler thread , wehereas we are seeing a lot of OkHttp task Runner thread in blocking state. I am not able to understand how this all process is working and why did we saw very less RxCachedThreadScheduler threads and so many OkHttp task runner thread in blocking state.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在创建多少个OkhttpClient的实例?如果超过1可能会导致某些性能问题,因为线程和连接不会尽可能积极地重复使用。
(使用
OKHTTPCLIENT.NEWBUILDER()
很好;与源okhttpclient共享资源。)How many instances of OkHttpClient are you creating? If it's more than 1 that could cause some performance problems because threads and connections aren’t reused as aggressively as they could be.
(Using
OkHttpClient.newBuilder()
is fine; that shares resources with the source OkHttpClient.)