FileDummy Logo
FileDummy
Testing & QA with Files

Load Testing File Download Endpoints with k6 and JMeter

Load test file download servers with k6 (JavaScript) and Apache JMeter. Measure throughput, latency, and error rate under concurrent download load. Free 1GB test file.

September 17, 202611 min read1,420 views
k6jmeterload-testingperformancefile-download

Stress testing file download endpoints guarantees that your CDN, edge caching rules, and origin object storage servers handle concurrent spikes without throttling or high error rates. This guide demonstrates how to build load tests using Grafana k6 and Apache JMeter.

Writing a File Download Load Test with Grafana k6

k6 is a modern, developer-friendly load testing tool written in Go with JavaScript test scripting.

JavaScript
import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
  stages: [
    { duration: '30s', target: 20 },  // Ramp up to 20 users
    { duration: '1m', target: 50 },   // Maintain 50 concurrent downloads
    { duration: '20s', target: 0 },   // Ramp down
  ],
  thresholds: {
    http_req_duration: ['p(95)<1500'], // 95% of requests must finish under 1.5s
    http_req_failed: ['rate<0.01'],    // Error rate must remain under 1%
  },
};

export default function () {
  const url = 'https://filedummy.dev/api/download?type=pdf&size=10mb';
  const res = http.get(url, {
    responseType: 'binary',
  });

  check(res, {
    'status is 200': (r) => r.status === 200,
    'content length matches': (r) => r.body.length === 10485760,
    'cache-control is present': (r) => r.headers['Cache-Control'] !== undefined,
  });

  sleep(1);
}
Verified Test Asset.pdf

Run high-concurrency download benchmarks using our globally cached 10MB test file.

Download 10MB PDF Test Sample β†’

Configuring Apache JMeter for Download Load Testing

  1. Create a Thread Group with your desired number of concurrent virtual users (e.g. 100 threads, 30-second ramp-up).
  2. Add an HTTP Request sampler pointing to your download URL.
  3. Check the Save response as MD5 hash box if you do not want JMeter to retain massive multi-gigabyte payloads in test runner memory.
  4. Add a Response Assertion checking for HTTP 200 and valid headers.

Metrics to Track During File Download Tests

  • Throughput (MB/s): Aggregate network egress from your origin or CDN.
  • Time to First Byte (TTFB): Highlights whether origin lookup or presigned URL signing is creating bottlenecks.
  • Error Spikes (HTTP 429 / 503): Indicates rate limiting or upstream connection pool saturation.
NDL

Nguyen Dai Long

Author

Backend Lead β€’ Distributed Systems & Cloud Edge Architecture Specialist

4+ years designing high-throughput file ingestion pipelines, database architectures, and distributed edge storage on Cloudflare R2 & AWS S3. Founder of FileDummy and the NDL Ecosystem.

Was this article helpful?

Click Like to support the author and help other developers discover this guide.

Engineering Discussion & Feedback (0)

Share benchmark results, report edge cases, or ask technical questions.

0/3000

No comments yet. Be the first developer to start the discussion!

Frequently Asked Questions

What is the difference between k6 and JMeter for load testing?β–Ύ

k6 uses JavaScript test scripts, has a modern CLI, generates no GUI overhead, and integrates well with CI/CD. JMeter is a mature Java tool with a GUI, supports more protocol types (FTP, JDBC, SOAP), and has a larger plugin ecosystem. k6 is preferred for HTTP/API load testing.

How do I measure download throughput in k6?β–Ύ

k6 automatically tracks http_req_receiving duration and data_received bytes per request. Calculate throughput as data_received / test_duration. Use k6's Trend metric type for custom throughput measurements.

How many virtual users do I need to load test a CDN?β–Ύ

CDNs handle massive concurrency. To meaningfully test, bypass the CDN and test the origin directly. Typical origin servers should handle 50–500 concurrent file download requests before saturating CPU or bandwidth.

Related Articles