GoReplay has no built-in old-vs-new response comparison, so an FDE validating a migration has to write the middleware themselves.

Key points at a glance

  • Replaying an entire file without errors does not prove the new version is correct, because GoReplay has no built-in comparison step.
  • Only when --input-raw-track-response is enabled during recording will the original responses be passed to the middleware.
  • The middleware receives three kinds of messages (requests, original responses, and replayed responses) in no fixed order, so they must be paired by a shared ID.

An article on DEV Community comparing traffic replay tools puts it bluntly about GoReplay: if you want to compare original and replayed data, you have to write the middleware yourself. GoReplay has no built-in comparison step.

For a Forward Deployed Engineer (FDE) preparing to migrate a customer to a new integration, this detail matters a lot. Replaying an entire file of real traffic to the new version may show zero errors, but the only conclusion you can draw is: the new version can accept requests.

Whether its responses are correct remains unknown. The GoReplay wiki also states a prerequisite: only when

--input-raw-track-response

is enabled will the original responses be passed to the middleware. Forget this flag, and there is no baseline for comparison.

The steps below cover the full workflow: record real requests, sanitize them, replay them to the new version at a limited rate, then pair the old and new responses. You can practice on a service running locally first, then apply the same workflow unchanged at the customer's site when they ask, "Can we switch over?"

What to do and what you need

The example scenario is hypothetical. The customer has an old service listening on port 8080, serving an API under

/api

. You have just written a new integration for the same set of endpoints. Before switching over, you need to prove with real traffic that both versions return identical results.

You will need: the GoReplay

gor

binary installed on the machine running the old service, with permission to read that machine's network traffic; an environment isolated from production to receive the replayed requests; and Python 3 for writing the middleware. GoReplay runs only in a terminal, with no web interface; all results are written to logs, with no dashboard.

Set one safety rule before you start: the environment receiving replayed requests must be isolated. If the new version accidentally writes to the production database, a test becomes a real incident.

Step 1: Record to a file, along with the original responses

The comparison needs the original responses as its baseline. The minimal recording command below enables

--input-raw-track-response

, so the middleware can receive the original responses afterwards. For the file output parameter names, verify against the

./gor --help

of the version you installed:

sudo ./gor --input-raw :8080 \
  --input-raw-track-response \
  --output-file requests.gor

Check: Send a few requests to port 8080 and see whether the file grows. If it stays empty, you may be listening on the wrong port.

Step 2: Sanitize before replaying

Real traffic always contains things that should not be replayed. Replaying a logout request could invalidate a session; carrying a real token into another environment amounts to leaking credentials. GoReplay provides three flags for this.

--http-allow-url

Forwards only URLs matching a pattern, so you can keep only the endpoints being migrated.

--http-disallow-url

The opposite: discards matching URLs.

--http-header

Sets a header on requests, overwriting it if it already exists. In this example, the three flags look like this (

TEST_TOKEN

is the test user's token):

--http-allow-url /api \
--http-disallow-url "sign_(in|out)" \
--http-header "Authorization: Bearer TEST_TOKEN"

One exception to remember: according to the wiki, the header flag cannot override

Host

. So don't rely on it to change the target machine; the target is set by the

--output-http

flag in the next step.

Step 3: Replay to the new version at a limited rate

When replaying from a file, GoReplay preserves the intervals between requests from the recording. You can adjust the replay speed, e.g. double speed, or use

--input-file-loop

to loop the file. For a freshly written integration, double speed is usually too fast.

A safer approach is to limit the number of requests sent to the target per second. The GoReplay wiki has an example that ensures a staging environment receives no more than ten requests per second.

Combined with the sanitization flags from step 2, you get the full replay command below. It is a simplified version;

|10

verify the suffix syntax against the

./gor --help

of the version you installed:

./gor --input-file requests.gor \
  --http-allow-url /api \
  --http-disallow-url "sign_(in|out)" \
  --http-header "Authorization: Bearer TEST_TOKEN" \
  --output-http "http://new-integration.internal|10" \
  --middleware "python3 diff.py"

Check: The new version's logs contain only requests sent to

/api

, with no

sign_in

or

sign_out

, and the

Authorization

header carries the test token.

Step 4: Pair the old and new responses

The middleware receives three kinds of messages:

1

is a request,

2

is an original response, and

3

is a replayed response. Each message carries an ID; the original and replayed responses share the same ID, and pairing relies on it.

The trap is ordering. The wiki warns that requests and responses are not guaranteed to arrive in sequence, so the middleware must hold state until both halves arrive.

The code below is a simplified version, based on a few assumptions you must verify yourself: each input line is a hex-encoded message, the message type is the first value on the first line, and the ID is the value immediately after it. It also compares only the status line. Check the exact format against the Middleware page of the GoReplay wiki.

import sys, binascii

pending = {}
for line in sys.stdin:
    raw = binascii.unhexlify(line.strip())
    header, _, body = raw.partition(b"\n")
    kind, msg_id = header.split(b" ")[:2]
    if kind == b"1":
        sys.stdout.write(line)   # 把请求原样交还给 GoReplay
        sys.stdout.flush()
        continue
    pair = pending.setdefault(msg_id, {})
    pair[kind] = body.split(b"\r\n", 1)[0]
    if b"2" in pair and b"3" in pair:
        if pair[b"2"] != pair[b"3"]:
            sys.stderr.write(f"{msg_id.decode()} {pair[b'2']!r} -> {pair[b'3']!r}\n")
        del pending[msg_id]

Results are written to STDERR. GoReplay runs only in a terminal, so this is where you view results; it's best to redirect them to a file for easier filtering later. In real use, you would also compare response bodies, ignore fields that change every time (like timestamps), and clean up pairs that never get both halves.

Mistakes that make the test meaningless

Before looking at the results, confirm the middleware received messages of both type

2

and type

3

. If you forgot

--input-raw-track-response

during recording, there are no original responses to compare against.

If either type is missing, the middleware can never form a pair, and the diff log will be empty. An empty log is easily misread as "no differences."

Also, don't carry real tokens into the new version, and don't let it touch the real database. Avoid replaying too fast and mistaking timeouts for logic errors. Start at 10 requests per second, and only increase the rate once the diff list is clear.

How this skill helps at the customer's site

Before an integration switchover, you must answer one question: "How do we know the new version won't break things?" A list of IDs with inconsistent responses, plus an explanation for each pair, is far more convincing than a simple "tests passed."

Once on site, the first thing to do is clarify which environment is truly isolated from production and which endpoints are in scope for the migration.

On a resume or in an interview, describe this skill in terms of outcomes: recorded real traffic before a switchover, sanitized requests, replayed at a controlled rate, and compared responses. If an FDE job description mentions migrations, shadow traffic, or zero-downtime switches, that's exactly when to walk through this four-step workflow.

Was this article helpful?

Thanks for your feedback!

Next on the roadmap · Phase 5: Deploying to production — where is data processed? Storage regions can't answer where data lives; where the model runs inference and where data is stored are two independent settings, and the customer's security review requires evidence for both.