Choosing technologies: criteria, spikes and exit costs
Choose an event schema format for Kafka topics: screen candidates against fit, maturity, licensing, team skills, operating cost and exit cost, price the exit with stated assumptions, and de-risk the leading option with a two-day spike whose success criteria are written before it starts.
Contentsand lesson path
On this page
- Why it matters
- Step 1: Candidates and knock-outs
- Step 2: Criteria, and the evidence behind them
- Step 3: Put a price on leaving
- Step 4: A time-boxed spike with written success criteria
- Step 5: Record the choice
- Common mistakes
- Check your understanding
- Apply it
- Review prompt
Lessons of Architecture Decision Records
- What makes a decision architectural: reversibility and blast radius Concept · 15 min
- Options analysis with weighted drivers Worked example · 25 min
- ADR anatomy, templates and the decision log Concept · 15 min
- Recording and later superseding a messaging decision Lab · 25 min
- Choosing technologies: criteria, spikes and exit costs Worked example · 25 min
- Decision quality check Knowledge check · 8 questions
What you will learn
- Evaluate candidate technologies against explicit criteria (fit to drivers, maturity, licensing, team skills, operating and exit cost) and de-risk the leading option with a time-boxed spike that has stated success criteria.
01. Why it matters
Technology choices are where architecture meets marketing. Popularity does not tell you whether it fits your drivers, whether your team can run it at 3 a.m., what happens if its licence changes, or what it would cost to leave.
This example follows Parcelpoint, the shop from the lab. After ADR-0004 moved order events to Kafka, seven consumer teams read them, in Python and TypeScript. Events are plain JSON with no schema, and twice last quarter a producer renamed a field and broke a consumer in production. The team must choose how to define and encode event schemas.
02. Step 1: Candidates and knock-outs
The team lists four candidates, again including doing nothing:
- A, do nothing: plain JSON, with field lists on a wiki page;
- B, JSON Schema in CI: JSON payloads, a JSON Schema for each event in a shared repository, and a CI job that compares every schema change with the previous version;
- C, Avro with a registry: Apache Avro's compact binary encoding, with schemas kept in a schema registry, a service that stores every version of each schema and refuses a new version that breaks the compatibility rule set for it;
- D, Protobuf with a registry: Protocol Buffers encoding with generated code, and the same kind of registry.
Two knock-outs come first: maintained libraries for Python 3.12 and for TypeScript on Node 22, and licences that allow internal commercial use. All four pass. The specifications and libraries use permissive licences such as MIT, BSD-3-Clause and Apache-2.0, but the TypeScript evidence for C and the registry's licence need a closer look.
The weighted drivers come from the incidents and the platform: D1 stop a breaking change before it reaches the topic (5); D2 serve Python and TypeScript consumers (5); D3 keep events small, since the topic keeps 30 days of them (3); D4 let people read events while debugging (2).
03. Step 2: Criteria, and the evidence behind them
Each criterion needs evidence that others can check. A and D drop out early: A does nothing for D1, the top driver, and D scores like C but costs more, because nobody has used Protobuf code generation. The sheet for the top two:
Criterion B: JSON + JSON Schema in CI C: Avro + schema registry
fit, D1 (w5) stops breaking changes only in in FULL or FORWARD mode, refuses
repos that run the shared CI job versions that old readers cannot
read, from every producer
fit, D2 (w5) Python and TypeScript: yes Python: yes; TypeScript: see
maturity
fit, D3 (w3) JSON text compact binary
fit, D4 (w2) readable as it is needs a decoder to read
maturity jsonschema 4.26 (Jan 2026) and Avro spec 1.12; fastavro 1.13.1
ajv 8.20 (Apr 2026) (Oct 2026); avsc 5.7.9 (Jul 2025,
one npm maintainer, 6.0 in alpha)
licensing MIT libraries Apache-2.0 spec, MIT libraries;
registries: Karapace and Apicurio
are Apache-2.0, Confluent's is
source-available
team skills everyone can read JSON Schema 2 engineers have used Avro; nobody
has run a registry
operating cost one CI job a highly available registry
exit cost low: payloads stay JSON medium: encoders in 7 services,
Avro files in the data lakeMaturity means release history, maintainers and governance, not stars or conference talks. The TypeScript Avro library, avsc, had its last stable release in July 2025, npm lists one maintainer, and its 6.0 line has been in alpha since 2017. For a decision meant to last years, that is a risk to test.
Licensing means the licence of each component and who controls it. Licences can change after you adopt a product: Redis moved from the BSD licence to source-available licences in March 2024, starting with Redis 7.4, then added the open-source AGPLv3 as an option in Redis 8 in May 2025; Elasticsearch left Apache 2.0 in 2021 and added AGPL as an option in 2024. Record the licence, recheck it at each major upgrade, have your legal contact confirm your use, and note the fork or alternative you could move to.
Team skills means who has run it in production, and operating cost includes people's time, not only the infrastructure bill.
04. Step 3: Put a price on leaving
Exit cost is what it would take to move off an option later: rewriting the code that depends on it, migrating or keeping readable the data stored in its format, and retraining people. Gregor Hohpe's article on lock-in treats it like insurance: the expected cost is the switching cost times the likelihood that you switch. In the small model below, every number is a labelled assumption from the review, and exit costs are ranges.
"""Three-year cost of each option, including the expected cost of leaving it.
Every number below is an assumption agreed in the review, not a vendor price.
"""
DAY_RATE = 700 # EUR per engineer-day
MONTHS = 36
# setup days, engineer-days per month, infra EUR per month,
# exit days (low, likely, high) if we must move off the option later
OPTIONS = {
"A JSON, no schemas": (0, 2.0, 0, (0, 0, 0)),
"B JSON Schema + CI": (15, 1.0, 0, (3, 5, 10)),
"C Avro + registry": (30, 1.5, 150, (25, 40, 70)),
"D Protobuf + registry": (40, 1.5, 150, (30, 50, 80)),
}
def run_cost(setup: float, monthly_days: float, infra: float) -> float:
return setup * DAY_RATE + MONTHS * (monthly_days * DAY_RATE + infra)
print(f"{'option':<24}{'run 3y':>9}{'exit range':>17}"
f"{'p=0.2':>9}{'p=0.5':>9}")
for name, (setup, days, infra, (low, likely, high)) in OPTIONS.items():
base = run_cost(setup, days, infra)
exit_range = f"{low * DAY_RATE / 1000:.1f}-{high * DAY_RATE / 1000:.1f}k"
if high == 0:
exit_range = "none"
expected = [base + p * likely * DAY_RATE for p in (0.2, 0.5)]
print(f"{name:<24}{base / 1000:>8.1f}k{exit_range:>17}"
f"{expected[0] / 1000:>8.1f}k{expected[1] / 1000:>8.1f}k")python3 exit_cost.pyoption run 3y exit range p=0.2 p=0.5
A JSON, no schemas 50.4k none 50.4k 50.4k
B JSON Schema + CI 35.7k 2.1-7.0k 36.4k 37.5k
C Avro + registry 64.2k 17.5-49.0k 69.8k 78.2k
D Protobuf + registry 71.2k 21.0-56.0k 78.2k 88.7krun 3y is set-up plus 36 months of running cost; the last two columns add the likely exit cost times a 20% or a 50% chance of leaving within three years. B is the cheapest to run and to leave. Doing nothing is not free: breaking-change incidents cost this team about two engineer-days a month. C costs about 33 thousand euros more than B at 20%, and its exit range is wide because Avro files would stay in the data lake. At 50% the gap grows by about 7 thousand euros: C's lock-in is real, but it does not decide the question.
D1 decides it. Two of the producers are built by a partner and do not run Parcelpoint's CI, so B cannot stop their breaking changes, and both incidents last quarter came from those producers. The team judges that worth the extra cost, so C leads. Two unknowns could still sink it: whether Avro's compatibility rules stop the incident's kind of change, and whether TypeScript consumers can rely on the flagged library.
05. Step 4: A time-boxed spike with written success criteria
A spike, a term from Extreme Programming, is a short, time-boxed experiment that answers one question with working code. It is only as good as its success criteria, so the team agrees the plan, with what it will do for each result, before writing code:
Question Can Avro schemas protect our consumers, in Python and in TypeScript?
Time box 2 days, 2 engineers; stop at the end of day 2, whatever the state
S1 A consumer on schema v1 reads events written with v2 (one new optional
field), and a v2 consumer reads v1 events: 1000 of 1000 match
S2 Under FULL compatibility, the rename behind last quarter's incidents is
rejected with or without an alias, and the expand step is accepted
S3 A TypeScript consumer on v1 decodes Python-written v2 events: 100 of 100
S4 Avro events, with the registry's 5-byte header, are at most 50% of the
size of the same events as JSON
Not in scope registry high availability, throughput, production code
Decision rule all pass: write the ADR for C
S1, S2 or S3 fails: choose B and record why
only S4 fails: choose C, and note the size in the consequencesThe writer schema is the schema the producer used; the reader schema is the one the consumer expects. Avro's schema resolution rules match fields by name, ignore fields the reader does not know, fill fields the writer lacked from the reader's defaults, and fail when such a field has no default. A registry applies these rules when it checks a new schema version against the old ones; the spike applies them directly, in both directions.
"""OrderPlaced schemas for the spike, written as Avro schemas in Python dicts."""
V1 = {
"type": "record",
"name": "OrderPlaced",
"namespace": "parcelpoint.orders",
"fields": [
{"name": "event_id", "type": "string"},
{"name": "order_id", "type": "string"},
{"name": "customer_id", "type": "string"},
{"name": "total_cents", "type": "long"},
{"name": "currency", "type": "string"},
{"name": "placed_at_ms", "type": "long"},
{"name": "item_count", "type": "int"},
],
}
# v2 adds an optional field WITH a default, so old and new readers both cope.
COUPON = {"name": "coupon_code", "type": ["null", "string"], "default": None}
V2 = {**V1, "fields": V1["fields"] + [COUPON]}
def renamed(alias: bool) -> dict:
"""The change behind last quarter's incident: total_cents -> amount_cents."""
fields = []
for field in V1["fields"]:
if field["name"] == "total_cents":
field = {"name": "amount_cents", "type": "long"}
if alias:
field["aliases"] = ["total_cents"]
fields.append(field)
return {**V1, "fields": fields}
def expanded() -> dict:
"""The safe first step: add amount_cents WITH a default, keep total_cents."""
new = {"name": "amount_cents", "type": ["null", "long"], "default": None}
return {**V1, "fields": V1["fields"] + [new]}"""Spike: can Avro schemas protect order-event consumers? (time box: 2 days)"""
import base64
import io
import json
import random
from fastavro import parse_schema, schemaless_reader, schemaless_writer
from schemas import V1, V2, expanded, renamed
N = 1000
HEADER = 5 # registry wire format: 1 magic byte + 4-byte schema id
def events(n: int, with_coupon: bool, seed: int = 7) -> list[dict]:
rng = random.Random(seed)
out = []
for i in range(n):
e = {"event_id": f"evt-{i:06d}", "order_id": f"ord-{rng.randrange(10**6):06d}",
"customer_id": f"cus-{rng.randrange(10**5):05d}",
"total_cents": rng.randrange(500, 50_000), "currency": "EUR",
"placed_at_ms": 1_793_000_000_000 + i * 60_000,
"item_count": rng.randint(1, 6)}
if with_coupon:
e["coupon_code"] = rng.choice([None, None, None, "WINTER10"])
out.append(e)
return out
def encode(event: dict, schema: dict) -> bytes:
buf = io.BytesIO()
schemaless_writer(buf, parse_schema(schema), event)
return buf.getvalue()
def decode(data: bytes, writer: dict, reader: dict) -> dict:
fo = io.BytesIO(data)
return schemaless_reader(fo, parse_schema(writer), parse_schema(reader))
def verdict(ok: bool) -> str:
return "PASS" if ok else "FAIL"
v1_events, v2_events = events(N, False), events(N, True)
v1_keys = [f["name"] for f in V1["fields"]]
v2_bytes = [encode(e, V2) for e in v2_events]
v1_bytes = [encode(e, V1) for e in v1_events]
# S1: old consumers read new events, new consumers read old events.
old_reads_new = sum(decode(b, V2, V1) == {k: e[k] for k in v1_keys}
for b, e in zip(v2_bytes, v2_events))
new_reads_old = sum(decode(b, V1, V2) == {**e, "coupon_code": None}
for b, e in zip(v1_bytes, v1_events))
print(f"S1 v1 reader, v2 events: {old_reads_new}/{N} match "
f"{verdict(old_reads_new == N)}")
print(f"S1 v2 reader, v1 events: {new_reads_old}/{N} match "
f"{verdict(new_reads_old == N)}")
# S2: the incident change must fail the check that FULL compatibility runs:
# new readers read old events (backward) AND old readers read new events (forward).
def readable(writer: dict, reader: dict, event: dict) -> bool:
try:
decode(encode(event, writer), writer, reader)
return True
except Exception: # fastavro raises SchemaResolutionError
return False
old = v1_events[0]
moved = {k: v for k, v in old.items() if k != "total_cents"}
moved["amount_cents"] = old["total_cents"]
changes = [("rename, no alias", renamed(alias=False), moved),
("rename with alias", renamed(alias=True), moved),
("add amount_cents, default", expanded(),
{**old, "amount_cents": old["total_cents"]})]
print("S2 change backward forward under FULL")
full = {}
for name, schema, new_event in changes:
back, fwd = readable(V1, schema, old), readable(schema, V1, new_event)
full[name] = back and fwd
print(f" {name:<27}{str(back):<10}{str(fwd):<9}"
f"{'accepted' if full[name] else 'rejected'}")
ok = full == {"rename, no alias": False, "rename with alias": False,
"add amount_cents, default": True}
print(f"S2 renames rejected, expand step accepted {verdict(ok)}")
# S4: size per event, JSON text against Avro binary plus the registry header.
json_size = sum(len(json.dumps(e, separators=(",", ":"))) for e in v2_events) / N
avro_size = sum(len(b) + HEADER for b in v2_bytes) / N
ratio = avro_size / json_size
print(f"S4 bytes per event: JSON {json_size:.1f}, Avro {avro_size:.1f} "
f"({ratio:.0%}) {verdict(ratio <= 0.5)}")
# S3 input: 100 events for the TypeScript consumer to decode with schema v1.
sample = {"writer": V2, "reader": V1, "events": [
{"b64": base64.b64encode(b).decode(), "expected": {k: e[k] for k in v1_keys}}
for b, e in zip(v2_bytes[:100], v2_events[:100])]}
with open("events.json", "w", encoding="utf-8") as fh:
json.dump(sample, fh)
print("S3 input: wrote events.json with 100 v2 events")python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install fastavro==1.13.1python spike.pyS1 v1 reader, v2 events: 1000/1000 match PASS
S1 v2 reader, v1 events: 1000/1000 match PASS
S2 change backward forward under FULL
rename, no alias False False rejected
rename with alias True False rejected
add amount_cents, default True True accepted
S2 renames rejected, expand step accepted PASS
S4 bytes per event: JSON 176.2, Avro 53.9 (31%) PASS
S3 input: wrote events.json with 100 v2 eventsS2 holds a trap. An alias helps only a reader whose schema carries it: new consumers can read old events (backward), but consumers still on v1 cannot read events written with the new name (forward). A registry in BACKWARD mode, the default in Confluent Schema Registry, checks only the first direction; its documentation says to upgrade every consumer before producing new events. It would accept the aliased rename, and the incident would happen again. When producers change first, set the subject to FORWARD or FULL, or their transitive variants, which check every earlier version. Under FULL only the expand step passes: add amount_cents with a default next to total_cents, then move the consumers. Removing total_cents later is a planned exception, since it has no default: FULL accepts the removal only after an earlier version gives it a default, and FULL_TRANSITIVE, which also checks v1, refuses it even then. Plan a controlled step for it, such as relaxing the subject's mode for that one change, or a new subject. S4's 31% holds for these sample events only.
The TypeScript check uses avsc, the library the maturity check flagged. npm pkg set type=module tells Node to load the .ts file as an ES module.
// S3: a TypeScript consumer still on schema v1 reads events that Python wrote with v2.
import { readFileSync } from 'node:fs';
import avro from 'avsc';
interface Sample {
writer: object;
reader: object;
events: { b64: string; expected: Record<string, unknown> }[];
}
const sample: Sample = JSON.parse(readFileSync('events.json', 'utf8'));
const writer = avro.Type.forSchema(sample.writer);
const reader = avro.Type.forSchema(sample.reader);
const resolver = reader.createResolver(writer);
let matches = 0;
for (const event of sample.events) {
const decoded = reader.fromBuffer(Buffer.from(event.b64, 'base64'), resolver);
if (JSON.stringify(decoded) === JSON.stringify(event.expected)) matches += 1;
}
const total = sample.events.length;
const verdict = matches === total ? 'PASS' : 'FAIL';
console.log(`S3 TypeScript v1 reader, v2 events: ${matches}/${total} match ${verdict}`);npm install --no-fund --no-audit [email protected]added 1 package in 2mnpm pkg set type=module
node consumer.tsS3 TypeScript v1 reader, v2 events: 100/100 match PASSAll four criteria pass, so the rule says: write the ADR for C. The TypeScript library's maintenance risk remains, but the spike shows it meets today's needs, and the record tracks the rest.
06. Step 5: Record the choice
The ADR for C quotes the criteria sheet, the cost model and the spike results, so a reviewer can check each claim. Its consequences include the accepted extra cost, the registry the Platform team must now run, the tool people need to read binary events, and the TypeScript library risk, with a trigger: re-evaluate if avsc does not support the next Node version the services move to. It also names the compatibility mode, FULL_TRANSITIVE for order-event subjects, so a breaking change is refused whichever side deploys first. More Information links the spike code and states the exit plan: a registry REST API that more than one product implements, so the registry at least can be swapped without touching producers.
07. Common mistakes
08. Check your understanding
09. Apply it
For the technology-choice ADR in this skill's practice project, write a criteria sheet like the one in step 2 for your top two candidates, with a source for every maturity and licence claim. Copy exit_cost.py and replace its numbers with your own, labelling each one as an assumption. Then write a spike plan with a question, a time box, three or four measurable success criteria and a decision rule, and get it agreed before you start. Run the spike, record each criterion as pass or fail with the measured value, and quote the results in the ADR.
10. Review prompt
Without looking back: name the six criteria used in this lesson and the kind of evidence that counts for each. Explain how the exit-cost model combines switching cost and likelihood. List the parts of a spike plan and say why each one is agreed before the spike starts, and describe what the S2 result showed about Avro's schema resolution.
References
- Don't get locked up into avoiding lock-in (Gregor Hohpe)
- Apache Avro 1.12.0 specification: schema resolution
- fastavro
- avsc: Avro for JavaScript
- Confluent Schema Registry: schema evolution and compatibility types
- Confluent Schema Registry: serializer wire format
- Karapace schema registry
- Redis adopts dual source-available licensing (March 2024)
- Redis is now available under the AGPLv3 (May 2025)
- Elasticsearch is open source again (August 2024)
- Spike (software development)
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.