No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



The repo contains example code to execute performance tests that compare between HTTP and MQTT. The tests are performed against API endpoints that are exposed by Google Cloud IoT Core. The tests simulate a virtual device that sends telemetry events to Google Cloud IoT Core. The framework is utilized to perform the tests as well as gathering and presenting the test results.


The implementation in httpClient.pyfile adapts the POST request sent by HttpLocust by adding the JWT in request headers. This is needed to authenticate against the Cloud IoT Core - HTTP Bridge. The telemetry events is delivered to Cloud IoT Core by calling the publishEvent endpoint with payload data.

For the MQTT part of the test, a custom locust client is implemented using the paho mqtt python client to properly interact with Cloud IoT Core - MQTT Bridge. The client handles connect and disconnect to MQTT server and is capable of sending multiple events. The time it takes to conduct each of the steps are measured and is sent to by triggering the request_success and request_failure events.

What is being tested

For event publishing through HTTP the request and response time is measured for each event. For the MQTT case because of the protocol is publish/subscribe oriented there is a connection establishing process between the client and the server before event could be published. So we choose to measure the connect and disconnect time together with the event publishing time, as the total time it takes to publish event. We also choose to send the events with QoS 1 which guarantees at least once delivery through a PUBACK response which matches the HTTP request and response cycle. With a established MQTT connection multiple events could be send, we choose to measure the time it takes to send 1, 10, 100 and 1000 events between one connect/disconnect cycle.

Environment setup

We assume you already have a GCP project setup with an IoT Core registry created, and inside of registry there's a device created with a public/private key pair stored in you local environment. Follow the Getting Started and Creating Registries and Devices to create this prerequisite cloud environment. Following steps are all done on your local environment where the tests will be conducted.

Local Prerequisites

  • Git
  • Python 2.7

Clone the repoistory:

git clone
cd iot-core-load-test-python

Download the google root certificate

curl > roots.pem

Set environment variables

cp set_env_template

Put in the proper values for you setup by editing then file and set the variables


Install dependent Python libraries

virtualenv env && source env/bin/activate
pip install -r requirements.txt

Execute the tests


Start locust with the MQTT client

locust --no-reset-stats -f

Open the web interface at and choose the number of simulated user and ramp up pace to execute the test.


Start locust with the HTTP client

locust --host='' -f

Open the web interface at and choose the number of simulated user and ramp up pace to execute the test.