I want to loadtest redis with jmeter. I already have a working JSR223Sampler with a groovy-script
import redis.clients.jedis.Jedis;
import java.util.concurrent.ThreadLocalRandom;
String varuser = "user:" + ThreadLocalRandom.current().nextInt(1, 500);
Jedis jedis = new Jedis(IP, port);
String result = jedis.hgetAll(varuser);
SampleResult.setResponseData(result.toString().getBytes());
under a ThreadGroup with 10 'users'. Works fine. Now I want to raise the number of 'users' to 1000. Performance will be influenced negatively by the high number of connections, right? So I want to get the advantages of a connection pool. According to
https://github.com/xetorthio/jedis/wiki/Getting-started
JedisPool is the answer. My question is how my jmeter testplan have to look like? Where do I have to put the jmeter-element (which one?) in which JedisPool will be created? Not under my ThreadGroup, right? And how I can use the connections from the pool in my sampler-script from above?
EDIT
So with Dmitris advise I createt two different testplans. Both not working. Maybe somebody sees my mistake?
First plan:
TestPlan
|---setUp Thread Group
----|---JSR223 Sampler (1)
|---Thread Group
----|---JSR223 Sampler (2)
|---View Results Tree
with JSR223 Sampler (1)
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
JedisPool pool = new JedisPool(new JedisPoolConfig(), IP);
prop.put('pool', pool);
and JSR223 Sampler (2)
import redis.clients.jedis.Jedis;
import java.util.concurrent.ThreadLocalRandom;
String varuser = "user:" + ThreadLocalRandom.current().nextInt(1, 500);
Jedis jedis = props.get('pool');
String result = jedis.hgetAll(varuser);
SampleResult. ...
jedis.close();
My second TestPlan looks like
TestPlan
|---ThreadGroup
----|---Test Action
--------|---JSR223 PreProcessor
----|---JSR223 Sampler
----|---View Results Tree
with PreProcessor like the above JSR223 Sampler (1) and JSR223 Sampler like the above JSR223 Sampler (2).
First Plan comes with the response message
cannot cast object 'redis.clients.jedis.JedisPool@642715fb' with class
'redis.clients.jedis.JedisPool' to class 'redis.clients.jedis.Jedis'
Second Plan responds
no such property: pool for class: Script41082
What I'm doing wrong?