立即试用 商务报价
社区版

Setup AWS instances

Step 1. Launch EC2 instance.

To run clear test lets spin up two instances for ThingsBoard and for performance tool. Operating system is Linux, image Ubuntu 20 LTS. Architecture x64 or ARM depending on instance type. Assign Elastic IP to get permanent access to the instances between restarts. We need at least two instances: first is to run ThingsBoard itself and second is to run the Performance test application.

ThingsBoard and Performance test instances

At the beginning, the firewall does not allow to connect your instances. Lest open the necessary ports to enable connectivity between instances and your admin machine.

Let’s setup the network Security groups for both instances and open TCP ports 22 (SSH), 8080 (HTTP), 1883 (MQTT), 9999 (JMX) for inbound rules for source IPs (office, home, perf-test).

Setup network security group for performance test

As fas as we experience the number of rules will affect the network performance, so another good option is to allow the “All traffic” for the trusted IPs and local network IP subnet.

Security group inbound rules

Step 2. Setup SSH to the instance.

Optionally, setup SSH private keys to access the instances. It is convenient to put your PEM key file to the ~/.ssh/aws.pem and set up ~/.ssh/config like:

1
2
3
4
5
6
Host tb
 Hostname 52.50.5.45
 Port 22
 IdentityFile /home/username/.ssh/aws.pem
 IdentitiesOnly yes
 User ubuntu

To connect ThingsBoard instance simply use the command below:

1
ssh tb

Step 3. Install Docker and Docker-compose.

We are going use docker and docker-compose to run performance tests under non-root users. To save the setup time and make the environment the same all the time we provide an all-in-one setup script below.
Login with ssh and run the commands both on ThingsBoard and Performance test instances:

1
2
3
4
5
6
7
8
9
10
sudo apt update
sudo apt install -y docker docker-compose
# setup some utilities
sudo apt install -y htop iotop
# manage Docker as a non-root user
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
# test non-root docker run
docker run hello-world

Step 4. Launch ThingsBoard and third-party components using docker-compose

Download the docker-compose file to the work directory. The docker-compose file is listed in the “How to reproduce the test” section that corresponds to your performance test scenario.

Make sure your file is present in the working directory and is named as “docker-compose.yml”, then execute the following commands:

1
2
3
4
5
6
# stop previous instance (if any)
docker-compose stop
# remove previous instance (old data will be lost)
docker-compose rm
# run new instance from scratch 
docker-compose up 

Note: For the sake of simplicity, we are using a docker-compose host network mode. This also helps to avoid docker-proxy overhead during active network communication between microservices.