question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use Leshan Client to launch thousands LWM2M clients in the same VM.

See original GitHub issue

Currently 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:closed
  • Created 6 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sbernard31commented, Sep 25, 2019
0reactions
sbernard31commented, Feb 7, 2020

#794 is now integrated in master.

You can now use :

ScheduledExecutorService sharedExecutor = Executors.newScheduledThreadPool(100,
        new NamedThreadFactory("shared executor"));

LeshanClient[] clients = new LeshanClient[3000];
for (int i = 0; i < clients.length; i++) {
    LeshanClientBuilder builder = new LeshanClientBuilder("myclient" + i);
    builder.setSharedExecutor(sharedExecutor);
    clients[i] = builder.build();
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

nRF5 SDK v15.0.0: Setting up the Leshan LWM2M server
First install maven and java using apt-get. sudo apt-get install openjdk-8-jdk maven git-core · Step into the Leshan folder and run "mvn install"....
Read more >
Emulation of IoT Devices - CORE
using IoT specific protocols and data models, such as CoAP, LWM2M and IPSO objects. As device management is an important aspect of IoT,...
Read more >
Secure LwM2M IoT streaming data pipelines in Hospworks ...
In this thesis, IoT Gateway used Leshan to run a LwM2M server and IoT Nodes simulator ... clients and servers using a binary,...
Read more >
ELIoT – Emulating IoT devices - Ericsson
Emulated IoT Platform (ELIoT) is a new open source IoT testbed that can emulate thousands of IoT devices using well-known standards and ...
Read more >
Development of a scalable architecture for Industrial Internet ...
4.4 Memory usage per container against number of clients (left) ... To start the observer/notify mechanism, the client indicates in a CoAP.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found