I've been asked to come up with a quick and dirty ...
# cfml-general
d
I've been asked to come up with a quick and dirty load/performance test that's easy to set up, and easy to point at different servers. This is to compare performance of a current server to a disaster recovery server we're setting up. Doesn't have to be fancy. We don't have anything like this currently. Any tooling suggestions?
a
JMeter is pretty quick to get started with [ https://jmeter.apache.org/ ]. For more serious load testing I've used gatling https://github.com/gatling/gatling
👍 1
r
+1 for JMeter: we've also used it for this.
👍 1
d
Lame question: I set JAVA_HOME to my jdk-11.0.20 path, same as in cf admin, but JMeter doesn't think it's right. Where should I point it instead?
b
n
K6 or Locust,io
s
Re:
JAVA_HOME
-- does
$JAVA_HOME/bin/java
exist? (that's Linux --
%JAVA_HOME%\bin\java
on Windows I think?) What exactly does JMeter says when you try to run it (and it fails)?
d
Thanks for jumping in @seancorfield. Yes %JAVA_HOME%\bin\java.exe exists. But actually, for unrelated reasons, I've installed JMeter on a different machine instead, and it's working fine there with the default configs, so this question is moot. Don't remember the error exactly, but it wasn't a crash, more an alert that it couldn't find java, and I should set JAVA_HOME. But anyway, moot.
👍🏻 1
j
+1 for Locust if you are familar with Python. I recently played around with K6 as well and it looks very neat. JMeter is ... JMeter - it works but I've always found it over complicated ... 🤷
d
What about Locust if I haven't used Python for decades and never knew it well? Will I need to spend tons of time figuring out basic stuff, or will just following obvious documented patterns get me going? Don't need anything fancy, for now at least, just log into a CF app, make a number of threads hit a bunch of URLs, record performance and any errors. Will Mr Flintstone be happy here?
n
Here's an example Locust file which posts a username and password and listens for a JWT token to send in all subsequent requests:
Copy code
from locust import HttpUser, task, between
import json
import logging
import time
class UserBehavior(HttpUser):
    wait_time = between(2, 9)  # Equivalent to min_wait and max_wait

    # Set the host as an environment variable or directly
    host = "<http://localhost:3000>" 

    def on_start(self):
        """
        on_start is called when a Locust start before any task is scheduled
        """
        self.login()

    def login(self):
        """
        Login and store the token
        """
        response = self.client.put("/v2/auth/login?min=0", json={"username":"<mailto:foo@foo.com|foo@foo.com>", "password":"testfoo"})
        result = json.loads(response.text)
        self.token = result['token'] 
        """
        Get Something
        """
        self.client.get("/something", headers=self.get_headers())  

    def get_headers(self):
        """
        Returns the authorization headers with the token
        """
        return {
            'Authorization': f'Bearer {self.token}'
        }

    @task()
    def task1(self):
        self.client.get("/foo", headers=self.get_headers())
        self.client.get("/bar", headers=self.get_headers())
        self.client.get("/bas", headers=self.get_headers())
Basically you should be able to do
pip install locust
Then in the same dir as your locustfile.py
$ locust
Open GUI to start (Note - 127.0.0.1 isn't bound so use localhost)
<http://localhost:8089/>