The system. A knowledge graph and document search service: entities of several types with typed, property-carrying relationships; documents with substantial text attached to entities; search over that text ranked by relevance and combined with traversal in single queries; an ingestion path that merges entities and asserts relationships idempotently from a stream of source records; and multi-tenant access. Deployed on a cluster, with a single server as the development and comparison baseline.
This is the right capstone for this engine because it uses all three models for the reasons they exist and it forces the topology question - a knowledge graph is exactly the workload where sharding hurts traversal and where the answer has to be measured rather than assumed.
Three invariants must hold:
- The graph has no dangling edges and no invalid edge types, verified by a scheduled check in both directions and by named graph definitions that reject invalid endpoints - including after every restore, because an inconsistent dump produces exactly this and nothing reports it.
- The ingestion path is idempotent and cannot create duplicate entities under concurrency, verified by a concurrency test asserting one document per logical entity - backed by a unique index, a deterministic key, or both.
- Traversal latency on the deployed topology meets a declared budget at a declared depth, verified by measurement on the cluster, not on a single server, with the measurement repeated after every topology or shard key change.
Invariant 3 is this capstone's distinguishing requirement. Every other engine in this programme lets you measure performance on one node and reason about scale afterwards. Here, the single-server number and the cluster number for a traversal can differ by an order of magnitude, the fixes are an Enterprise licence or a remodelling, and "we will shard it later" is not available. A capstone whose traversal numbers come from a single server has not demonstrated invariant 3 - it has demonstrated that the queries are well written, which is a different and lesser claim.
What is assessed. 20% knowledge checks, 35% laboratory portfolio, 15% troubleshooting practical, 30% capstone. Three things carry the capstone.
The topology measurement and the decision it drove. Traversal at your shipped depth on a single server and on the cluster, across at least two shard key strategies, with the shard key you chose and why - and, if SmartGraphs or OneShard would change the answer, what they would be worth against your numbers and the licence position as an open item with an owner.
Atomicity and idempotency, demonstrated rather than claimed. The concurrency test producing one entity, the intermediate-commits demonstration showing a transaction you believed atomic was not, and a statement of which operations depend on single-document atomicity by design.
A recovery with real verification. The dump taken under load with the dangling edges it produced, the consistent dump and what quiescing cost, the failover drill at two write concerns with the lost writes measured, and the verification suite including dangling edges, graph constraints and index presence - because a restore that silently dropped a unique index is a correctness defect waiting for its first concurrent upsert.
Deliverables: architecture diagram including the cluster topology and what one engine replaced; the data model with every edge-against-attribute decision and the edge collection split justified; schema validation rules with the audit query; source code including the idempotent ingestion path, pruned traversals with their depth bounds, per-query memory limits and the tenant filtering with its bypass tests; the dataset generator; benchmark report on both topologies; security review including the document-level authorisation gap stated explicitly; recovery runbook with measured RPO and RTO; sizing and cost checklist with the licence open item; and a short design defence saying honestly where separate components would have served better.
// ================= Invariants, as runnable checks ==================
// 1. *** NO DANGLING EDGES AND NO INVALID EDGE TYPES. ***
// BOTH DIRECTIONS, on every edge collection:
FOR coll IN ["employs", "located_in", "mentions", "cites"]
LET broken = (
FOR e IN COLLECTION(coll)
FILTER DOCUMENT(e._from) == null OR DOCUMENT(e._to) == null
LIMIT 10
RETURN { edge: e._key,
missing: DOCUMENT(e._from) == null ? e._from : e._to }
)
RETURN { coll, broken_count: LENGTH(broken), sample: broken }
// Expected: all zero. *** ON A SCHEDULE, AND AFTER EVERY
// RESTORE - BECAUSE AN INCONSISTENT DUMP PRODUCES EXACTLY THIS
// AND NOTHING REPORTS IT. ***
// and the type invariant, enforced by the graph definition:
// graph._graph("knowledge")._edgeDefinitions();
// then attempt an edge outside it and confirm the rejection.
// A named graph makes this the ENGINE'S job rather than a
// convention - which is why the capstone uses one.
// 2. *** THE INGESTION PATH IS IDEMPOTENT AND CANNOT CREATE
// *** DUPLICATE ENTITIES UNDER CONCURRENCY. ***
FOR e IN entity
COLLECT name = e.name, kind = e.kind WITH COUNT INTO n
FILTER n > 1
LIMIT 50
RETURN { name, kind, duplicates: n }
// Expected: no rows - *** AFTER 500 CONCURRENT MERGES OF
// OVERLAPPING ENTITIES. ***
//
// backed by one or both:
// db.entity.ensureIndex({ type: "persistent",
// fields: ["name","kind"], unique: true }); // MANDATORY for
// // UPSERT
// INSERT { _key: CONCAT(@kind,"--",@slug), ... } INTO entity
// OPTIONS { overwriteMode: "update" } // atomic:
// // NO RACE TO LOSE
// *** AND THE UNIQUE INDEX MUST BE VERIFIED PRESENT AFTER EVERY
// *** RESTORE *** - see invariant 3's verification. A restore
// that dropped it is a correctness defect WAITING FOR ITS FIRST
// CONCURRENT UPSERT.
// 3. *** TRAVERSAL LATENCY ON THE DEPLOYED TOPOLOGY MEETS A DECLARED
// *** BUDGET AT A DECLARED DEPTH - MEASURED ON THE CLUSTER, NOT
// *** ON A SINGLE SERVER. THIS CAPSTONE'S DISTINGUISHING
// *** REQUIREMENT. ***
FOR v, e, p IN 1..3 OUTBOUND @start GRAPH "knowledge"
OPTIONS { bfs: true, uniqueVertices: "global" }
PRUNE v.kind NOT IN @kinds OR v.tenant != @tenant
FILTER v.kind IN @kinds
LIMIT 200
RETURN DISTINCT { name: v.name, kind: v.kind,
depth: LENGTH(p.edges) }
//
// *** THE MEASUREMENT TABLE - THE FIRST THING IN THE DESIGN
// *** DEFENCE: ***
// depth 3, pruned, 200 limit:
// single server *** 7 ms ***
// cluster, shardKey _key *** 210 ms ***
// cluster, shardKey tenant (CHOSEN) 34 ms
// cluster, poor key 480 ms
// budget: p99 < 80 ms at depth 3 -> *** MET, with the tenant
// shard key and NOT
// OTHERWISE ***
//
// *** A CAPSTONE WHOSE TRAVERSAL NUMBERS COME FROM A SINGLE
// *** SERVER HAS NOT DEMONSTRATED THIS *** - it has demonstrated
// THAT THE QUERIES ARE WELL WRITTEN, which is a different and
// lesser claim. *** REPEAT THE MEASUREMENT AFTER EVERY TOPOLOGY
// OR SHARD KEY CHANGE. ***
// ================= Declare the baseline BEFORE measuring ==========
//
// Version / edition: ______ / ______
// *** licence review: OPEN - owner ______ , due ______ ***
// Topology: 3 agents, 3 coordinators, 3 DB-Servers
// entity/document/edges: numberOfShards 9,
// *** shardKeys ["tenant"] ***, replicationFactor 2,
// *** writeConcern 2 *** (0 writes lost, measured)
// *** considered: OneShard per tenant - would give
// *** 7 ms traversal AND enforced isolation; Enterprise.
// *** Worth ______ against our numbers. ***
// Model: ATTRIBUTES entity.kind, document.published
// *** SEPARATE EDGE COLLECTIONS *** per relationship
// type (14 ms vs 890 ms against one + type filter)
// edges carry properties: role, since, confidence,
// source - *** an edge is a document, so this is
// free ***
// *** NAMED GRAPH "knowledge" *** - the shape is an
// invariant, so the engine enforces it
// Schema: JSON Schema level "strict" on entity and document
// *** + the audit query in CI, because a schema added
// *** late validates nothing retroactively ***
// Search: view over document.title/body (text_en) and
// entity.name (norm + ngram)
// *** commitIntervalMsec 1000; eventual consistency
// *** ACCEPTED, and the writer is shown their own write
// *** from the write's response ***
// Ingestion: deterministic _key + overwriteMode "update"
// (atomic) AND a unique index on (name, kind)
// *** intermediate commits: OFF for the merge path,
// *** ON for the bulk backfill - stated per path ***
// Traversal: depth 3, PRUNE at every level, bfs +
// uniqueVertices global, LIMIT 200
// Limits: every application query carries memoryLimit 512 MB
// and maxRuntime 15 s
// Tenancy: one database + application filtering, *** with the
// *** document-level authorisation gap STATED and the
// *** bypass tests written *** - or OneShard per
// tenant, stated either way
// Recovery: arangodump nightly from a quiesced window;
// source-of-record replay for anything newer
//
// Claim:
// entity by key p99 < 3 ms
// filtered + sorted entity list p99 < 20 ms
// 1-hop neighbourhood p99 < 10 ms
// *** 3-hop pruned, ON THE CLUSTER p99 < 80 ms ***
// search, BM25 ranked p99 < 40 ms
// search + 2-hop combined p99 < 150 ms
// ingestion, idempotent > 25,000 records/s
// duplicate entities under 500-way concurrency = 0
// dangling edges = 0, scheduled
// view commit lag p99 < 2 s (user-visible)
// failover RTO, measured ______ s
// writes lost at writeConcern 2 = 0, drilled
// consistent dump duration ______ (write pause ______)
// ================= Failure modes ==================================
// *** concurrent UPSERT without a DUPLICATE ENTITIES. No error.
// unique index Invariant 2. ***
// *** intermediate commits on a THE TRANSACTION WAS NOT
// path you believed atomic ATOMIC. Half the work
// survived a failure. ***
// *** a graph workload sharded on TRAVERSAL 30x SLOWER. The fix
// a key that does not is Enterprise or a
// co-locate remodelling. Invariant 3. ***
// "we will shard it later" *** NOT AVAILABLE for a graph
// workload. ***
// *** arangodump under load DANGLING EDGES on restore.
// Invariant 1, and the reason
// the check runs after every
// restore. ***
// a restore that dropped a *** a correctness defect
// unique index waiting for its first
// concurrent upsert. ***
// replicationFactor 1 no failover. The shard is
// gone until the server
// returns.
// writeConcern 1 acknowledged writes lost on
// leader failure. Priced, not
// assumed.
// 2 of 3 agents lost no quorum; writes refused.
// Correct, and alarming.
// FILTER instead of PRUNE depth 4 visits 13,000
// vertices instead of 74.
// no memory limit on a query the server swaps, then the
// OOM killer.
// a subquery in a LET over an an N+1 at 20,000,000 rows.
// unlimited outer FOR LIMIT first.
// insert-then-search in a test passes locally, fails in CI,
// with a sleep succeeds on retry.
// *** assuming collection NO DOCUMENT-LEVEL ACCESS
// permissions isolate tenants CONTROL EXISTS. Every tenant
// is readable. State it; test
// the bypass. ***
// upgrading coordinators first breaks the cluster. Agents,
// DB-Servers, coordinators.
// a schema added to a populated validates NOTHING
// collection retroactively.
//
// Verify after every recovery with the three invariants - counts,
// dangling edges in both directions, graph constraints, index
// presence and the traversal budget. A restored cluster with the
// right counts and a missing unique index looks exactly like a
// correct one.
//
// *** AND THE DESIGN DEFENCE MUST SAY HONESTLY WHERE SEPARATE
// *** COMPONENTS WOULD HAVE SERVED BETTER. *** One engine instead of
// four is a real win; it is not a win in every dimension, and a
// capstone that finds nothing has not looked.
Discussion
No questions on this topic yet. Sign in to ask the first one.