Faster URL Validation in JMeter — Without HTTP Request Sampler
Validating thousands of URLs in JMeter using the HTTP Request sampler is slow and memory-heavy. Here is a smarter Groovy-based approach that runs the same check in a fraction of the time.
As performance engineers, we often face a common problem: "I have thousands of URLs. How do I quickly check they return HTTP 200 without slowing down my JMeter test?"
If you've ever tried validating sitemap or image URLs using the HTTP Request sampler, you may have noticed:
- ❌ Test becomes slow
- ❌ Too many samplers clutter the test plan
- ❌ High memory usage
- ❌ Hard to scale for thousands of URLs
In one of my recent validations (~2,000+ URLs), the traditional approach was taking 30+ minutes. That's when I switched to a smarter method. Today I'll show you a simple, human-friendly way to validate URLs using JSR223 (Groovy) — no HTTP Request sampler needed.
🎯 What We Want to Achieve
- ✅ Read URLs from a CSV
- ✅ Build target image URL
- ✅ Check HTTP status = 200
- ✅ Write PASS/FAIL to output CSV
- ✅ Run much faster than traditional approach
🧠 Why Avoid HTTP Request Sampler Here?
HTTP Request sampler is great for load testing, but for bulk URL health checks, it adds overhead:
- Thread scheduling
- Cookie manager
- Redirect handling
- Listener load
When you only need status validation, a lightweight HTTP call is much faster.
Simple Test Plan Structure
Keep your JMeter test plan minimal:
Test Plan
└── Thread Group (1 user is enough)
└── JSR223 Sampler (Groovy)
That's it. Clean and fast.
📥 Step 1: Prepare Your CSV
url
https://www.example.com/product/4ABCD25h
⚙️ Step 2: Add User Defined Variables (Recommended)
| Variable |
|---|
| URLS_CSV |
| FOLDER_PATH |
| imagePath |
💡 Step 3: Add JSR223 Sampler (Language = Groovy)
Paste this simple and fast version:
import java.io.*
import java.net.URL
import java.net.HttpURLConnection
String csvPath = vars.get("URLS_CSV")
String outFile = vars.get("FOLDER_PATH") + "/output.csv"
String imagePath = vars.get("imagePath")
BufferedReader br = new BufferedReader(new FileReader(csvPath))
BufferedWriter out = new BufferedWriter(new FileWriter(outFile))
// skip header
br.readLine()
String line
int total = 0
int failed = 0
out.write("url,status")
out.newLine()
while ((line = br.readLine()) != null) {
if (!line.trim()) continue
String[] parts = line.split(",", 2)
if (parts.length < 2) continue
String urlStr = parts[1].replace("\"","").trim()
// extract product id
URL urlObj = new URL(urlStr)
String baseUrl = urlObj.getProtocol() + "://" + urlObj.getHost()
String[] segments = urlObj.getPath().split("/")
String productId = segments[segments.length - 1]
String finalUrl = baseUrl + imagePath + productId + ".png"
total++
int code = -1
String status = "FAIL"
try {
HttpURLConnection conn = (HttpURLConnection) new URL(finalUrl).openConnection()
conn.setRequestMethod("HEAD")
conn.setConnectTimeout(5000)
conn.setReadTimeout(10000)
conn.connect()
code = conn.getResponseCode()
if (code == 200) {
status = "PASS"
} else {
failed++
}
conn.disconnect()
} catch (Exception e) {
failed++
}
out.write(finalUrl + "," + status)
out.newLine()
}
br.close()
out.close()
log.info("Done. Total=" + total + " Failed=" + failed)
❤️ Why I Like This Approach
From my experience working on large e-commerce platforms (like Direct Wines ecosystem), this method is:
- ✔ Simple to maintain
- ✔ Very fast
- ✔ Low memory footprint
- ✔ Perfect for sitemap/image validation
- ✔ Clean test plan
Sometimes simpler beats heavier tools.
🔴 Important Caveats
Before you use this in production:
- This is NOT a load test — only a health check
- Some servers block HEAD requests → switch to GET if needed
- For very large files (>10k URLs), consider parallel version
- If site has rate limiting, reduce speed
🧩 When Should You Still Use HTTP Request Sampler?
Use the standard sampler when you need:
- Full response validation
- Cookies/session handling
- Real user journey
- Load testing
Use this lightweight method when you need: "Just tell me which URLs are alive."
✍️ Final Thoughts
As test architects, our job is not just to test — but to test smartly. When the requirement is simple URL validation, don't over-engineer the solution. A small Groovy script inside JMeter can save hours of execution time and keep your test plan beautifully clean.
Explore Topics
Written by
Madeshwaran Kotteswaran
Content creator and writer sharing insights and stories.