ditto-client for java occurs cpu usage 100% #1547
timyang9527
started this conversation in
General
Replies: 1 comment
-
|
Hi. And do I understand correctly that your devices are connected via the Ditto-Client to the Ditto backend? |
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
my application environmen: java8 springboot ditto-client:2.1.0-m3


my application need manage a lot of iot device ,so, i use a ditto-client pool in my application
I create three class : PoolAutoConfiguration DittoClientPool DittoClientFactory
ditto-client-pool param:
maxIdle: 40
maxTotal: 120
minIdle: 20
initialSize: 20
runtime environmen: docker 2 vm (24cpu 48g memory) 8 pod
when I run my application for some time , There will be 100% CPU usage every ten minutes or so
When I check the jvm, I found this thread ‘ditto-client-scheduled-adaptable-bus-n’
I found this thread in MessagingProviders
` public static MessagingProvider webSocket(final MessagingConfiguration configuration,
final AuthenticationProvider authenticationProvider,
final ExecutorService defaultExecutor) {
final ScheduledExecutorService defaultScheduledExecutor = createScheduledExecutorService(
"adaptable-bus-" + authenticationProvider.getConfiguration().getSessionId());
return WebSocketMessagingProvider.newInstance(configuration, authenticationProvider, defaultExecutor,
defaultScheduledExecutor);
}
public static ScheduledExecutorService createScheduledExecutorService(final String name) {
final int corePoolSize;
if (VersionReader.determineJavaRuntimeVersion() <= 8) {
// for Java <= 8, because of bug https://bugs.openjdk.java.net/browse/JDK-8129861, the corePoolSize must be at least 1:
corePoolSize = 1;
} else {
// bug has been fixed since Java 9, so scale down to 0 threads if the scheduledThreadPool is not needed:
corePoolSize = 0;
}
// ScheduledThreadPool executor is by default unbounded in max size, so start smallest possible core-pool-size:
return Executors.newScheduledThreadPool(corePoolSize,
new DefaultThreadFactory("ditto-client-scheduled-" + name));
}
`
I want to know how to solve this problem?
`public class PoolAutoConfiguration {
private final PoolProperties poolProperties;
private DittoClientPool pool;
}`
`public class DittoClientPool extends GenericObjectPool {
}`
`public class DittoClientFactory extends BasePooledObjectFactory {
// @Autowired
// private DittoClientProperties properties;
}`
Beta Was this translation helpful? Give feedback.
All reactions