How to Capture and Replay Real HTTP Traffic with GoReplay for Accurate Testing

This guide explains how to use GoReplay to capture live HTTP requests from a production environment, filter and store them, and replay them in a test environment with adjustable speed, enabling realistic load testing and debugging without affecting real users.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How to Capture and Replay Real HTTP Traffic with GoReplay for Accurate Testing

When testing a staging environment, using real production HTTP requests can provide more accurate results.

GoReplay captures live HTTP traffic and replays it.

Usage Example

Real-time forwarding

For instance, forward requests from port 8000 (production) to port 8001 (test):

./gor --input-raw :8000 --output-http="http://localhost:8001"

The command listens on port 8000 and forwards all traffic to the specified address until stopped.

Recording and replay

Recording ./gor --input-raw :8000 --output-file=requests.gor The --output-file option specifies the file to save captured requests.

After stopping, a requests_0.gor file is generated.

Replay

./gor --input-file requests_0.gor --output-http="http://localhost:8001"

The --input-file selects the recorded file, and --output-http defines the target address.

Request filtering

Collect only requests under /api:

./gor --input-raw :8080 --output-http staging.com --http-allow-url /api

Collect requests with header api-version matching ^1\.0\d:

./gor --input-raw :8080 --output-http staging.com --http-allow-header api-version:^1\.0\d

Adjust playback speed

Replay at twice the real speed:

./gor --input-file "requests.gor|200%" --output-http "staging.com"

Installation and Testing

Download from https://github.com/buger/gor/releases, extract the binary, and run it directly.

For quick experimentation, start the built‑in file server: ./gor file-server :8000 Visiting http://localhost:8000 lists local files, allowing you to simulate different environments.

Official website: https://goreplay.org with detailed documentation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backend testingLoad TestingGoReplayHTTP replayrequest capture
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.