concurrencylabs / mqtt-locust

Use locust.io to load test IoT applications running on the AWS IoT service
MIT License
51 stars 18 forks source link

Need clarification on "client_id" #2

Open briantully opened 7 years ago

briantully commented 7 years ago

Hey there. First of all I wanted to say thank you for your amazing work and efforts. I am hoping I can leverage locust to load test my first IoT application.

I was hoping you could clarify the comment within mqtt_locust.py where a random client_id is created by Paho. I have 2500 devices/things that I want to simultaneously test against, each with its own client_id/name. When Paho randomly creates a random client_id, is it using one of the existing/known client_ids or is it creating a unique/new one? If it's a new client_id, how valid is the load test if it's not connecting to an existing thing/client_id?

Any clarification would be greatly appreciated! :)

concurrencylabs commented 7 years ago

Since the main goal of this code is to load test the AWS infrastructure behind an AWS IoT application, in most cases it's OK to test with an empty client_id.

You will still generate load that will help you measure how many shards you'll need in a Kinesis stream, how many EC2 instances you'll need, how fast your Lambda functions will run, or the capacity units consumed in a DynamoDB table, etc.

The way the Paho client works is that when client_id is not provided, Paho creates a completely random client_id to connect to the IoT broker. For simplicity, this code was implemented assuming a random client_id would suffice.

I understand this is not ideal in some use cases, but there is a way around it. You would have to:

I hope this helps.

briantully commented 7 years ago

It helps immensely!!! Wow, thank you so much for your detailed and thoughtful response. I really appreciate it!

Best regards, Brian

On Feb 15, 2017, at 10:34 PM, Concurrency Labs notifications@github.com wrote:

Since the main goal of this code is to load test the AWS infrastructure behind an AWS IoT application, in most cases it's OK to test with an empty client_id.

You will still generate load that will help you measure how many shards you'll need in a Kinesis stream, how many EC2 instances you'll need, how fast your Lambda functions will run, or the capacity units consumed in a DynamoDB table, etc.

The way the Paho client works is that when client_id is not provided, Paho creates a completely random client_id to connect to the IoT broker. For simplicity, this code was implemented assuming a random client_id would suffice.

I understand this is not ideal in some use cases, but there is a way around it. You would have to:

Modify the Locust test (in this case aws-iot-publish.py), so it gets a known client_id each time "class MyThing(MQTTLocust)" is instantiated. Locust instantiates this class each time a user is hatched. This can be accomplished by adding client_id as a member variable and populating its value from a text file or something similar. Modify MQTTLocust(Locust) in mqtt_locust.py, so it initializes MQTTClient in the following way: "self.client = MQTTClient(self.client_id)" Modify MQTTClient in mqtt_locust.py, so it contains a self.client_id variable, which will be used by the Paho client. This way Paho will be using using a real client_id that exists in your application. I hope this helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.