Use Case

Using MockHero for Load Testing and Performance Benchmarks

The Problem

Load testing with unrealistic data produces unrealistic results. When every simulated request uses the same five test accounts, your database caches aggressively, indexes stay hot, and the benchmark looks great. In production, thousands of unique users with different data patterns hit cold paths, trigger cache misses, and expose performance bottlenecks that your load test completely missed.

The other problem is volume. Load tests need thousands or millions of unique records, but generating that data is a project in itself. Faker.js can produce the values, but you need to handle uniqueness (no duplicate emails), relational consistency (valid foreign keys), and realistic distributions. By the time you have built the data generator, you have spent more time on test setup than on the test itself.

The Solution: MockHero for Load Test Data

MockHero generates large volumes of unique, relationally-consistent data in a single API call. Every email is unique, every foreign key is valid, and the data looks like a real production database. Pipe the output into your database before a load test, and your benchmarks will reflect real-world performance.

Quick Setup

curl -X POST https://api.mockhero.dev/api/v1/generate \
  -H "x-api-key: mh_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "tables": [
    {
      "name": "users",
      "count": 5000,
      "fields": [
        { "name": "id", "type": "uuid" },
        { "name": "email", "type": "email" },
        { "name": "username", "type": "username" },
        { "name": "password_hash", "type": "uuid" },
        { "name": "plan", "type": "enum", "params": { "values": ["free","basic","pro","enterprise"] } },
        { "name": "created_at", "type": "datetime" }
      ]
    },
    {
      "name": "api_requests",
      "count": 50000,
      "fields": [
        { "name": "id", "type": "uuid" },
        { "name": "user_id", "type": "ref", "params": { "ref": "users.id" } },
        { "name": "method", "type": "enum", "params": { "values": ["GET","POST","PUT","DELETE","PATCH"] } },
        { "name": "path", "type": "slug" },
        { "name": "status_code", "type": "enum", "params": { "values": ["200","201","400","401","403","404","500"] } },
        { "name": "latency_ms", "type": "integer", "params": { "min": 5, "max": 2000 } },
        { "name": "created_at", "type": "datetime" }
      ]
    }
  ],
  "format": "json"
}'

Step-by-Step Guide

1. Determine your data volume needs

A good rule of thumb: your test database should have at least as many records as you expect in production. If you have 10,000 users in production, generate at least 10,000 for your load test. This ensures indexes, query plans, and cache behavior match reality.

2. Get your MockHero API key

Sign up at mockhero.dev/sign-up. For load testing volumes, you may want a paid plan that supports higher row counts.

3. Generate and seed the data

Use MockHero's SQL output format for fastest insertion:

# Generate SQL and pipe directly to your database
curl -s -X POST https://api.mockhero.dev/api/v1/generate \
  -H "x-api-key: mh_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{ "tables": [...], "format": "sql" }' \
  | psql $DATABASE_URL

4. Configure your load test tool

Use the generated user IDs in your load test scripts. Here is a k6 example:

import http from "k6/http";
import { check } from "k6";

// Pre-loaded user IDs from MockHero data
const userIds = JSON.parse(open("./user-ids.json"));

export const options = {
  stages: [
    { duration: "1m", target: 100 },
    { duration: "5m", target: 500 },
    { duration: "1m", target: 0 },
  ],
};

export default function () {
  const userId = userIds[Math.floor(Math.random() * userIds.length)];
  const res = http.get(`http://localhost:3000/api/users/${userId}`);
  check(res, { "status is 200": (r) => r.status === 200 });
}

5. Run the benchmark and analyze

Because every request hits a different user record, your load test exercises the full range of database and cache behavior. Compare results against benchmarks with small datasets to see the true performance difference.

Why MockHero vs Faker for Load Testing

  • Unique records — every email, username, and ID is guaranteed unique. No duplicate key errors during seeding.
  • Volume — generate thousands of rows in a single API call. No local script to run and debug.
  • Realistic distributions — data that mimics real-world patterns, so your benchmarks reflect actual production behavior.
  • SQL output — pipe INSERT statements directly into your database for fastest possible seeding.

Get Started

Make your load tests trustworthy with realistic data volumes. Sign up at mockhero.dev and generate the test data your benchmarks deserve.

M

MockHero Team

Guides and tutorials for generating realistic test data with the MockHero API.

Start generating test data for free

1,000 rows/month on the free tier. No credit card required.

Get Your API Key

Related Articles