What is Locust.io?
Locust is an open source load testing tool written in Python. Since it is written in Python, it is possible to containerise it and deploy it on Kubernetes.
Mongolocust allows you to code up MongoDB CRUD operations in Python and visualise their executions in a browser.
Why Load Test?
Load test helps us to understand how well our database performs under various levels of stress, identify performance bottlenecks and presents an opportunity to test our database's auto scaling capabilities.
Goals
In this article, you will learn how to deploy locust on AWS EKS and load test your MongoDB cluster.
Pre-requisites
- Git installed on your local machine
- AWS CLI installed on your local machine
- AWS CLI Profile setup on your local machine, I named my profile "aws-tester"
Steps
Install kubectl, the Kubernetes CLI version of a swiss army knife
brew install kubectl
Install eksctl, a simple CLI tool for creating and managing clusters on AWS EKS
brew tap weaveworks/tap
brew install weaveworks/tap/eksctl
Create AWS EKS Cluster
eksctl --profile aws-tester create cluster \
--name mongo-locust-cluster \
--version 1.30 \
--region ap-southeast-1 \
--nodegroup-name locust-nodes \
--node-type t3.medium \
--nodes 2
Pull a copy of Mongolocust codes
git clone https://github.com/sabyadi/mongolocust.git
Set CLUSTER_URL
within k8s/secret.yaml
to your MongoDB Cluster's URL
cd mongolocust/k8s
vi secret.yaml
Deploy Mongolocust on AWS EKS
cd ..
./redeploy.sh
Forward 8089 port from master service to localhost
kubectl port-forward service/master 8089:8089
Access Locust Web Interface at (http://localhost:8089)
Scale Locust Workers
kubectl scale deployment locust-worker-deployment --replicas 10
Obtain Kubernetes nodes' IP addresses and whitelist on MongoDB Atlas
kubectl get nodes -o wide
Have fun load testing your MongoDB Cluster!
Top comments (0)