The architecture has three roles and understanding what each does explains most of the cluster's behaviour. Coordinators are stateless: they receive a query, plan it, dispatch work to DB-Servers, combine the results and respond. You scale them with query concurrency, and because they hold no data you can add and remove them freely. DB-Servers hold the shards and do the actual reading and writing; you scale them with data volume. The agency is a Raft-based configuration and coordination store, always three or five agents, holding the cluster's authoritative view of who holds what - it is small, critical, and the thing to protect.
Sharding is per collection and three settings matter. numberOfShards fixes how many pieces the collection is cut into - and it is set at creation and not changed afterwards, so it is a decision rather than a knob. shardKeys chooses the attributes whose hash decides a document's shard, defaulting to _key. replicationFactor is how many copies of each shard exist; one is no redundancy, and two or more is what makes failover possible at all. writeConcern says how many copies must acknowledge a write before it returns, which is your durability-against-latency dial.
The shard key is the decision with consequences. A query filtering on the shard key goes to one shard; a query that does not goes to all of them and the coordinator combines the results. Writes that share a shard key land on one DB-Server and can be transactional cheaply. So choose the shard key to co-locate the things you query and write together - and accept that this is the same trade as every sharded system: you are optimising for one access pattern and paying for the others.
And now the thing that makes this course require two deployments: why cluster traversal is slower. A traversal walks from vertex to vertex. In a sharded cluster, the next vertex may live on a different DB-Server, so a hop can require a network round trip - and a traversal is a sequence of hops, each one potentially crossing the network. A three-hop traversal that is seven milliseconds on a single server can be two hundred on three nodes, not because the cluster is badly built but because the work is now distributed and graph traversal is the access pattern that distributes worst.
Two features address it and both are Enterprise. SmartGraphs co-locate a vertex with its edges by making the shard key part of the vertex key, so a traversal that stays within a logical partition - a tenant, a region, a document cluster - stays on one DB-Server. OneShard databases place an entire database on a single DB-Server, with replicas for availability, so every traversal and every transaction is local; you get cluster failover and cluster operations with single-server query performance, at the cost of that database being limited to what one DB-Server can hold. For a great many graph workloads OneShard is the right answer and is under-used, because it gives you the availability you actually wanted without the distribution you did not.
The consequence to take away: decide the topology at design time, with a measurement. "We will shard it later" works for a document workload and does not work for a graph workload, because the fix is either an Enterprise feature or a remodelling. If you are on Community and your graph will not fit one server, that is a finding to surface early, not late.
Backup, and the honest edition split. arangodump and arangorestore are the logical path and work everywhere: readable output, portable, selective by collection. Their limit on a cluster is consistency - dumping a running cluster does not give you a single consistent moment across all shards unless you stop writes, so a logical dump taken under load can contain an edge whose vertex is missing. arangobackup hot backups are consistent and near-instantaneous and are an Enterprise feature. So on Community, a consistent cluster backup means quiescing writes, and the honest plan is a maintenance window, a replica you dump from, or acceptance plus a rebuild path from a source of record - which, after several courses, should be a familiar conclusion. Decide which, write it in the runbook, and test it.
Failover is the agency's job and it works: when a DB-Server stops responding, the agency promotes a follower shard to leader, and the coordinators route to the new leader. It requires replicationFactor of two or more, the promotion takes seconds during which writes to affected shards fail, and your RPO depends on writeConcern - a write acknowledged by only the leader can be lost when that leader dies. Drill it, time it, and record what the application saw, because "it failed over" and "the application stayed up" are different claims.
Laboratory exercise 5 - the topology experiment and the drill.
On your three-DB-Server cluster, create the same graph collections with three different shard key strategies: _key default, a key chosen to co-locate a logical partition, and a deliberately poor choice. Load the same data into each.
Measure traversal at depths one through four against all three, plus the single-server baseline - so four curves. That table is the course's central finding and it should be the first thing in your capstone's design defence.
If you have an Enterprise licence available, measure SmartGraphs and a OneShard database on the same workload. If you do not, do it as a costed design exercise: state what each would change, what you would need to measure to confirm it, and what the licence costs - including that the Community licence terms for your version are a question for someone qualified.
Measure the sharding effects: a query filtering on the shard key against one that does not; a write batch within one shard against one spanning shards; and an aggregation, which may be faster on the cluster.
Then backup consistency, demonstrated. Take an arangodump of the cluster under write load, restore it, and find the inconsistency - an edge whose vertex is absent, or a document referencing a missing entity. Write the query that finds it. Then quiesce writes, dump again, and show it clean. Record the duration of both and what quiescing cost you.
Then the failover drill: with the system under load and replicationFactor 2, kill a DB-Server. Record what the application saw - errors, duration, which operations failed - and time the full recovery. Repeat with writeConcern 1 and 2 and demonstrate the data loss difference. Then kill an agent and show the cluster surviving; then kill a second and show it not.
Write the verification suite: counts per collection, dangling edge detection in both directions, named graph constraint re-verification, index presence, and a sample query comparison.
Deliverable: the four traversal curves across shard strategies, the SmartGraph and OneShard measurement or costed design exercise, the sharding effect measurements, the inconsistent dump demonstrated with the query that found it and the consistent one timed, the failover drill with measured RPO and RTO at two write concerns, the agency quorum demonstration, and the verification suite.
// ==================================================================
// THREE ROLES, and what each does explains most of the cluster's
// behaviour.
// ==================================================================
// *** COORDINATORS *** STATELESS. Receive a query, PLAN it,
// DISPATCH to DB-Servers, COMBINE results, respond. Scale with
// QUERY CONCURRENCY; add and remove freely.
// *** DB-SERVERS *** hold the SHARDS; do the actual reading and
// writing. Scale with DATA VOLUME.
// *** AGENCY *** a RAFT-based configuration store, ALWAYS 3 OR 5
// agents, holding the AUTHORITATIVE view of who holds what.
// *** SMALL, CRITICAL, AND THE THING TO PROTECT. ***
//
// GET /_admin/cluster/health
// GET /_admin/cluster/shardDistribution
// ==================================================================
// SHARDING: per collection, three settings that matter.
// ==================================================================
// db._create("entity", {
// numberOfShards: 9, // *** SET AT CREATION. NOT CHANGED
// // AFTERWARDS. A DECISION, NOT A
// // KNOB. ***
// shardKeys: ["tenant"], // whose hash decides the shard
// // (default: _key)
// replicationFactor: 2, // *** 1 = NO REDUNDANCY. 2+ IS
// // WHAT MAKES FAILOVER POSSIBLE AT
// // ALL. ***
// writeConcern: 2 // copies that must ACK before the
// // write returns -> your
// // DURABILITY-vs-LATENCY dial
// });
//
// *** THE SHARD KEY IS THE DECISION WITH CONSEQUENCES: ***
// filtering ON the shard key -> ONE shard
// not filtering on it -> ALL shards, combined by the
// coordinator
// writes sharing a shard key -> one DB-Server, and
// TRANSACTIONAL CHEAPLY
// -> *** CHOOSE IT TO CO-LOCATE THE THINGS YOU QUERY AND WRITE
// *** TOGETHER *** - and accept the usual trade: you are
// OPTIMISING FOR ONE ACCESS PATTERN AND PAYING FOR THE OTHERS.
// ==================================================================
// *** AND NOW THE REASON THIS COURSE REQUIRES TWO DEPLOYMENTS: WHY
// *** CLUSTER TRAVERSAL IS SLOWER. ***
// ==================================================================
// A traversal walks VERTEX TO VERTEX. In a sharded cluster *** THE
// NEXT VERTEX MAY LIVE ON A DIFFERENT DB-SERVER, SO A HOP CAN
// REQUIRE A NETWORK ROUND TRIP *** - and a traversal is A SEQUENCE
// OF HOPS, each one potentially crossing the network.
//
// 3-hop pruned traversal:
// single server *** 7 ms ***
// cluster, shardKey _key (RANDOM placement) *** 210 ms ***
// cluster, shardKey tenant (co-located) 34 ms
// cluster, deliberately poor key 480 ms
//
// *** NOT BECAUSE THE CLUSTER IS BADLY BUILT - BECAUSE THE WORK IS
// *** NOW DISTRIBUTED AND GRAPH TRAVERSAL IS THE ACCESS PATTERN THAT
// *** DISTRIBUTES WORST. ***
//
// *** TWO FEATURES ADDRESS IT, AND BOTH ARE ENTERPRISE: ***
// *** SMARTGRAPHS *** co-locate a vertex WITH ITS EDGES by making
// the shard key part of the vertex key, so a traversal STAYING
// WITHIN A LOGICAL PARTITION (a tenant, a region, a document
// cluster) STAYS ON ONE DB-SERVER.
// _key: "acme:entity-8812" // shard key EMBEDDED in the key
// *** ONESHARD *** places an ENTIRE DATABASE ON A SINGLE
// DB-SERVER, with REPLICAS for availability, so *** EVERY
// TRAVERSAL AND EVERY TRANSACTION IS LOCAL. *** You get CLUSTER
// FAILOVER and CLUSTER OPERATIONS with SINGLE-SERVER QUERY
// PERFORMANCE - at the cost of that database being limited to
// WHAT ONE DB-SERVER CAN HOLD.
// db._createDatabase("kg", { sharding: "single",
// replicationFactor: 2 });
//
// *** FOR A GREAT MANY GRAPH WORKLOADS ONESHARD IS THE RIGHT ANSWER
// *** AND IS UNDER-USED - IT GIVES YOU THE AVAILABILITY YOU ACTUALLY
// *** WANTED WITHOUT THE DISTRIBUTION YOU DID NOT. ***
//
// *** THE CONSEQUENCE: DECIDE THE TOPOLOGY AT DESIGN TIME, WITH A
// *** MEASUREMENT. "We will shard it later" works for a DOCUMENT
// *** workload and DOES NOT WORK FOR A GRAPH WORKLOAD ***, because
// the fix is either AN ENTERPRISE FEATURE or A REMODELLING. On
// Community, with a graph that will not fit one server, *** THAT IS
// A FINDING TO SURFACE EARLY. ***
// ==================================================================
// *** BACKUP, AND THE HONEST EDITION SPLIT. ***
// ==================================================================
// arangodump --server.endpoint tcp://coordinator:8529 \
// --all-databases true --threads 8 \
// --output-directory /backups/$(date +%F)
// arangorestore --input-directory /backups/2026-11-30 \
// --create-database true
// -> works EVERYWHERE. Readable, portable, selective.
//
// *** THEIR LIMIT ON A CLUSTER IS CONSISTENCY: dumping a RUNNING
// *** cluster does NOT give you a single consistent moment ACROSS
// *** ALL SHARDS unless you STOP WRITES. *** A logical dump taken
// under load can contain *** AN EDGE WHOSE VERTEX IS MISSING. ***
// DEMONSTRATE IT, and write the query that finds it:
FOR e IN employs
LET a = DOCUMENT(e._from)
LET b = DOCUMENT(e._to)
FILTER a == null OR b == null
LIMIT 100
RETURN { edge: e._key, from: e._from, to: e._to,
missing: a == null ? "from" : "to" }
// Expected after a CONSISTENT restore: NO ROWS.
//
// *** arangobackup HOT BACKUPS ARE CONSISTENT AND NEAR-INSTANTANEOUS
// *** - AND ARE AN ENTERPRISE FEATURE: ***
// arangobackup create --label nightly
// arangobackup list / restore --identifier <id>
//
// *** SO ON COMMUNITY, A CONSISTENT CLUSTER BACKUP MEANS QUIESCING
// *** WRITES. *** The honest plan is one of:
// a MAINTENANCE WINDOW,
// a REPLICA you dump from,
// or *** ACCEPTANCE PLUS A REBUILD PATH FROM A SOURCE OF
// RECORD *** - which, after several courses, should be a
// familiar conclusion.
// *** DECIDE WHICH, WRITE IT IN THE RUNBOOK, AND TEST IT. ***
// quiesced dump: write pause 6 min, dump 41 min, 0 inconsistencies
// live dump: no pause, dump 38 min, *** 1,847
// dangling edges ***
// ==================================================================
// FAILOVER IS THE AGENCY'S JOB, and it works.
// ==================================================================
// When a DB-Server stops responding, the agency PROMOTES A FOLLOWER
// SHARD TO LEADER and the coordinators ROUTE TO THE NEW LEADER.
//
// *** REQUIRES replicationFactor >= 2. *** With 1, the shard is
// simply GONE until the server returns.
// promotion takes SECONDS, during which *** WRITES TO AFFECTED
// SHARDS FAIL. ***
// *** YOUR RPO DEPENDS ON writeConcern: a write ACKNOWLEDGED BY
// ONLY THE LEADER CAN BE LOST WHEN THAT LEADER DIES. ***
//
// THE DRILL, under load:
// writeConcern 1: failover 11 s, *** 2,140 acknowledged writes
// LOST ***, p99 write latency 24 ms
// writeConcern 2: failover 13 s, *** 0 writes lost ***,
// p99 write latency 61 ms
// -> *** THAT PAIR OF ROWS IS THE DURABILITY DECISION, PRICED. ***
//
// AGENCY QUORUM - demonstrate both halves:
// kill 1 of 3 agents -> *** cluster survives *** (2 of 3 = quorum)
// kill 2 of 3 agents -> *** no quorum. THE CLUSTER STOPS
// ACCEPTING WRITES. *** Not a crash - a
// deliberate refusal, which is correct
// and alarming to watch.
//
// *** DRILL IT, TIME IT, AND RECORD WHAT THE APPLICATION SAW ***,
// because "it failed over" and "the application stayed up" ARE
// DIFFERENT CLAIMS.
// ==================================================================
// VERIFICATION after any recovery - a CORRECTNESS check.
// ==================================================================
FOR c IN ["entity","document","place","employs","located_in","mentions"]
RETURN { c, n: COLLECTION_COUNT(c) } // vs the source
// *** DANGLING EDGES IN BOTH DIRECTIONS - the check that catches an
// *** inconsistent restore: ***
FOR e IN employs
FILTER DOCUMENT(e._from) == null OR DOCUMENT(e._to) == null
COLLECT WITH COUNT INTO n RETURN n // Expected: 0
// NAMED GRAPH CONSTRAINTS re-verified - the definition came back,
// and it still rejects:
// graph._graph("knowledge")._edgeDefinitions();
// then attempt a known-invalid edge and confirm the rejection.
// INDEXES PRESENT - a restore that dropped a UNIQUE index is a
// CORRECTNESS defect waiting to happen (Module 2's UPSERT):
// db.entity.indexes();
// *** AND TIME THE DRILL: ***
// detect ___ decide ___ promote/restore ___ verify ___ resume ___
// *** TOTAL RTO ___ *** RPO: ___ (from writeConcern, measured)
Discussion
No questions on this topic yet. Sign in to ask the first one.