Coder Social home page Coder Social logo

load-test-iot-core's Introduction

load-test-iot-core

Introduction

The repo contains example code for doing comparison performance tests between HTTP and MQTT against Google Cloud IoT Core. The test simulates a virtual device that sends telemetry events to Google Cloud IoT Core. The locust.io framework is utilized to perform the tests as well as gathering and presenting the test results.

Implementation

The httpClient.py adapt the HttpLocust by adding the JWT in request headers, which 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 take to conduct each of the steps are measured and send to locust.io by triggering the request_success and request_failure events.

What are 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 https://github.com/kingman/load-test-iot-core.git
cd load-test-iot-core

Download the google root certificate

curl https://pki.google.com/roots.pem > roots.pem

Set environment variables

cp set_env_template set_env.sh

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

source set_env.sh

Install dependent Python libraries

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

Execute the tests

MQTT

Start locust with the MQTT client

locust --no-reset-stats -f mqttClient.py

Open the web interface at http://127.0.0.1:8089/ and choose the number of simulated user and ramp up pace to execute the test.

HTTP

Start locust with the HTTP client

locust --host='https://cloudiotdevice.googleapis.com/v1' -f httpClient.py

Open the web interface at http://127.0.0.1:8089/ and choose the number of simulated user and ramp up pace to execute the test.

load-test-iot-core's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.