I’m currently running a JMeter load test on my laptop and I’m encountering an issue where my test plan is not achieving the expected throughput. Here are the details of my test configuration:
Test Plan
—Thread Group ( number of threads =40, ramp up =20, loop count =250)
—— Directory Listing Data source ( listed our source directory and unchecked all the checkboxes)
—— Post API HTTP Request with body as ${fileContent}
—— Post API Header Manager with one of the headers as Authorization and hardcoded the token as Bearer
—— JSR223 PreProcessor to read data from directory listing data source
—— Constant throuput Timer with target trhoutput as 2400 and calculate throuput based on all active threads in current thread group
I have a folder on my desktop that has 10000 txt files with naming convention like 1a.txt, 2a.txt etc.
This is the code inside my JSR223 preprocessor:-
import org.apache.jmeter.services.FileServer
import java.util.concurrent.TimeUnit
// Get the filename
def file = vars.get("filename")
// Skip unwanted files
if (file == ".DS_Store" || !file.endsWith(".txt")) {
return
}
def path = "/Users/username/Desktop/ten/" + file
def fileContent = new File(path).text
// Log the file being posted
log.info("Thread " + ctx.getThreadNum() + " is posting file: " + file)
// Save the file content to a variable
vars.put("fileContent", fileContent)
// Save the start time
long startTime = System.nanoTime()
vars.put("startTime", startTime.toString())
vars.put("fileName", file)
Configuration Details:
Thread Group Settings:
Number of Threads (users): 40
Ramp-Up Period (seconds): 20
Loop Count: 250
Constant Throughput Timer Settings:
Target Throughput: 2400 requests per minute (40 requests per second)
Calculate Throughput based on: All active threads in current thread group
Total Number of Messages: 10000
Expected Behavior:
The test should execute 40 requests per second.
Actual Behavior:
The test is only executing roughly 10-12 requests per second.