Rehearse a Change and Retire an Old Tool

Lesson 2 of 4

Copy the Request, Not Its Effects

Estimated time: 10 minutes

Send the request, not the consequences

A request answered twice produces two sets of consequences unless the acting part is held back. If the new version may write, send, charge or remove, then copying real traffic doubles every one of those actions, and the second set is caused by a version nobody has approved.

Split the reading from the acting

Most requests have a part that reads and a part that acts. The reading can be done by both versions, because it changes nothing. The acting belongs to the version that is serving the user.

def trial(request, serving_version, trial_version):
    readable = request.without_actions()
    served = serving_version.handle(request)
    recorded = trial_version.handle_read_only(readable)
    return {"served": served, "recorded": recorded}

Keep the trial off shared resources

A trial version that still opens a connection to a shared store, a queue or an outside service competes with the serving version for the same capacity. Point it at a spare of the resource, or hold its writes at the boundary.

Record what the trial would have done

When the acting part cannot run, have the trial version report the action it would have taken, so the comparison covers the consequences and not only the reply. That report is what shows whether the new version would have changed the world differently.