Use Leshan Client to launch thousands LWM2M clients in the same VM.
See original GitHub issueCurrently by default a Leshan client uses 10 threads :
- 1 UDP sender (from element-connector)
- 1 UDP receiver (from element-connector)
- 2 Deduplicator (from californium)
- 1 Coap Server (from californium)
- 1 DTLS sender (from scandium)
- 1 DTLS receiver (from scandium)
- 1 DTLS retransmit (from scandium)
- 1 DTLS connectionHandler (from scandium)
- 1 registration engine (from leshan)
We can reduce it by removing 3(UDP+1deduplicator) or 5(DTLS+1deduplicator) threads if your are using only UDP or only DTLS. To do that LeshanClientBuilder.disableUnsecuredEndpoint() or disableSecuredEndpoint()…
But this is still 5 or 7 threads by clients, if you want to create a simulator which would run thousands of clients that’s means thousands of threads there is no way this was a good design…
I suppose we should change the code a bit to be able to use only one thread pool executor for all the clients. Currently this is partially done in californium/scandium, you can set a common executor for DTLSConnectionHandler and CoAP server so you will save 2 more thread by clients.
With Leshan 1.0.0-M5, this will looks like this :
final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
builder.setEndpointFactory(new EndpointFactory() {
@Override
public CoapEndpoint createUnsecuredEndpoint(InetSocketAddress address, NetworkConfig coapConfig,
ObservationStore store) {
return new CoapEndpoint(address, coapConfig);
}
@Override
public CoapEndpoint createSecuredEndpoint(DtlsConnectorConfig dtlsConfig, NetworkConfig coapConfig,
ObservationStore store) {
DTLSConnector dtlsConnector = new DTLSConnector(dtlsConfig);
dtlsConnector.setExecutor(new StripedExecutorService(executor));
return new CoapEndpoint(dtlsConnector, coapConfig, null, null);
}
});
client = builder.build();
client.getCoapServer().setExecutor(executor);
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (8 by maintainers)
Top GitHub Comments
@nkvaratskhelia see #744
#794 is now integrated in master.
You can now use :