Capstone - Identity Resolution Graph

Article · 7:00

Duplicate detection, secure ingestion and a failover design, with the model choice defended.

The system. An identity resolution graph: records arrive from several sources with overlapping and conflicting attributes - names, emails, phones, addresses, device fingerprints - and the system links records that represent the same person, with a confidence score and provenance for every link. Queries return a person's full identity cluster, explain why two records were linked, and list unresolved candidates for review. Ingestion is from S3 through the bulk loader, inside a VPC, authenticated by IAM.

Three invariants must hold:

  1. Every link between records carries its confidence and its provenance - which source asserted it and by what method - and the query that explains a link returns both.
  2. No query is unbounded: every traversal has an explicit hop limit, a typed or predicate-constrained start, and a result limit - demonstrated with explain or profile for each.
  3. Identity clusters are stable under re-ingestion: loading the same source data twice produces the same clusters, with no duplicate records and no duplicate links.

Invariant 3 is this capstone's distinguishing requirement. The bulk loader is not idempotent in the way you might assume - updateSingleCardinalityProperties and the choice of supplied identifiers determine whether a reload updates or duplicates - and demonstrating stability means loading twice and comparing, not reasoning about it.

What is assessed. 20% knowledge checks, 35% laboratory portfolio, 15% troubleshooting practical, 30% capstone. Three things carry the capstone.

A model choice defended with the four questions. Property graph or RDF, Gremlin or openCypher or SPARQL, with the reasoning from Module 2 - and specifically, for an identity resolution problem, an honest answer on whether external interoperability and provenance-by-named-graph matter enough to pay the reification cost. A capstone that chose a model without addressing that question has skipped the course's central decision.

Measured consistency and performance against a declared baseline. Declare it first: cluster topology, capacity mode, endpoints used per operation, dataset, and p50/p95/p99 measured from inside the VPC. Include the replica lag miss rate from Module 3, because the routing decision depends on it, and the connection limit for your instance size.

A defensible account of failure modes, operational limits and cost. Four things specifically: the authorisation granularity limit, with the compensating application design; the bulk loader's error behaviour, because a half-successful load is the realistic incident; the failover behaviour per endpoint, with the measurement; and the capacity decision with both costs.

Deliverables: architecture diagram including VPC, endpoints and the ingestion path; the model choice with the four-question reasoning; the numbered query list with an explain or profile for each; source code including request signing, retry handling and the loader wrapper that reads errors; reproducible S3 dataset; benchmark report measured from inside the VPC; security review including the IAM policies and the granularity limitation; recovery runbook with measured RPO and RTO and the full restore command; capacity comparison with costs; and a short design defence.

# ================= The model choice, defended =====================
# Module 2's four questions, answered for THIS problem:
#
#  1. INTEGRATING OR PUBLISHING EXTERNAL STANDARDS-BASED DATA?
#     Identity resolution OFTEN DOES - external reference data,
#     published entity identifiers. If yes -> RDF, and the named
#     graph per source gives you PROVENANCE FOR FREE, which is
#     invariant 1.
#     If the sources are all internal -> no.
#
#  2. DO RELATIONSHIPS CARRY DATA?
#     *** YES, DECISIVELY: every link needs a CONFIDENCE and a
#     *** METHOD. *** In a property graph that is two edge
#     properties. In RDF it is REIFICATION - 7 triples per link
#     instead of 1 edge - on what is the most numerous element in
#     this graph.
#
#  3. DOES THE TEAM KNOW CYPHER? -> openCypher, lowest friction.
#  4. INFERENCE? -> test it first (Module 2). Do not assume.
#
# *** A CAPSTONE THAT CHOSE A MODEL WITHOUT ADDRESSING QUESTION 1
# *** AGAINST QUESTION 2 HAS SKIPPED THE COURSE'S CENTRAL DECISION. ***
# Both answers are defensible here; an unexamined one is not.
#
# This example takes the PROPERTY GRAPH, because question 2 dominates
# at this link volume - and then has to solve provenance explicitly,
# which RDF would have given it. SAY THAT.

# ================= Invariants, as runnable checks ==================

# 1. EVERY LINK CARRIES CONFIDENCE AND PROVENANCE.
%%oc
MATCH (a:Record)-[r:SAME_AS]->(b:Record)
WHERE r.confidence IS NULL OR r.source IS NULL OR r.method IS NULL
RETURN count(*) AS incomplete_links
#   Expected: 0.
#
# And the query that EXPLAINS a link - part of the deliverable, not
# an extra:
%%oc
MATCH (a:Record {`~id`: $aId})-[r:SAME_AS]-(b:Record {`~id`: $bId})
RETURN r.confidence, r.method, r.source, r.created_at,
       [(a)-[:HAS_EMAIL|HAS_PHONE|HAS_ADDRESS]->(shared)
          <-[:HAS_EMAIL|HAS_PHONE|HAS_ADDRESS]-(b) | labels(shared)[0]]
         AS shared_attributes
#   An investigator must be able to see WHY two records were linked.
#   That is a product requirement and it is why the properties exist.

# 2. *** NO QUERY IS UNBOUNDED. *** Demonstrated per query:
%%oc
EXPLAIN
MATCH (seed:Record {source_id: $sourceId})-[:SAME_AS*1..4]-(r:Record)
WHERE r <> seed
RETURN DISTINCT r.`~id`, r.source
LIMIT 200
#   * an upper hop limit (1..4)
#   * a TYPED relationship
#   * an anchored, predicate-constrained start
#   * a LIMIT
#   And because Neptune has NO per-query memory cap, the cluster
#   query timeout is the backstop - set it, and say so:
#     neptune_query_timeout = 30000   (ms)

# 3. *** IDENTITY CLUSTERS ARE STABLE UNDER RE-INGESTION. ***
#    Load the same source data TWICE and compare. Do not reason
#    about it - the bulk loader is NOT idempotent in the way you
#    might assume:
#
#      "updateSingleCardinalityProperties": "TRUE"
#        -> a reload UPDATES single-cardinality properties
#      "updateSingleCardinalityProperties": "FALSE"
#        -> a reload may ADD a second value, or error
#
#      AND: SUPPLYING ~id YOURSELF is what makes a reload update the
#      same vertex. Letting Neptune generate ids means a reload
#      creates NEW VERTICES - duplicates, silently.
#
%%oc
MATCH (r:Record) WITH r.source, r.source_id AS sid, count(*) AS n
WHERE n > 1 RETURN sid, n
#   Expected: empty, after loading twice.
%%oc
MATCH (a:Record)-[r:SAME_AS]->(b:Record)
WITH a, b, count(r) AS links WHERE links > 1
RETURN a.`~id`, b.`~id`, links
#   Expected: empty. Duplicate EDGES are the other half of
#   invariant 3, and an edge without a supplied ~id duplicates on
#   reload exactly as a vertex does.

# ================= Secure ingestion ===============================
#   S3 (source data, server-side encrypted)
#     -> S3 VPC ENDPOINT (traffic stays off the internet)
#     -> Neptune bulk loader, via an IAM ROLE attached to the cluster
#     -> inside the VPC, no public endpoint
#     -> IAM database authentication, SigV4-signed requests
#     -> audit log to CloudWatch, ATTRIBUTABLE TO AN IAM PRINCIPAL
#
# *** AND THE LOADER WRAPPER MUST READ THE ERRORS. *** A load with
# failOnError FALSE reports 200 OK having rejected thousands of
# rows, and THE ONLY WAY TO KNOW IS TO ASK:
#   curl -G https://<endpoint>:8182/loader/<loadId> \
#     --data-urlencode 'details=true' --data-urlencode 'errors=true' \
#     --data-urlencode 'page=1' --data-urlencode 'errorsPerPage=100'
#   -> {"overallStatus":{"status":"LOAD_COMPLETED",
#        "totalRecords":4000000,"totalDuplicates":0,
#        "parsingErrors":12402, ...},
#       "errors":{"errorLogs":[...]}}
#
# *** A HALF-SUCCESSFUL LOAD IS THE REALISTIC NEPTUNE INCIDENT ***,
# and the wrapper that fails the pipeline on a non-zero error count
# is what prevents it reaching production quietly.

# ================= Declare the baseline BEFORE measuring ==========
#
#   Cluster:    1 writer + 2 replicas, multi-AZ, promotion tiers set
#   Capacity:   Serverless 2-16 NCU  (AND the provisioned comparison)
#   Endpoints:  writes and read-your-writes  -> CLUSTER endpoint
#               investigator reads (tolerant) -> READER endpoint
#               heavy review queries          -> INSTANCE endpoint
#                                                (isolated replica)
#   Auth:       IAM database authentication, SigV4
#   Timeout:    neptune_query_timeout = 30000 ms
#   Dataset:    8,000,000 Record, 3,000,000 Email, 2,500,000 Phone,
#               1,800,000 Address, 12,000,000 SAME_AS
#   MEASURED:   from an EC2 instance IN THE SAME SUBNETS
#
#   Claim:
#     resolve one identity cluster (4 hops)  p99 < 120 ms
#     explain a link                         p99 <  25 ms
#     unresolved candidate list              p99 < 200 ms
#     ingest 1,000,000 records (bulk)        < 20 min
#     failover window (cluster endpoint)     <  60 s, MEASURED
#     acknowledged writes lost on failover   0
#     PITR restore RTO                       <  90 min, MEASURED
#     RPO                                    < 5 min (PITR window)
#
#   AND the two numbers the routing and pooling depend on:
#     *** replica lag miss rate (reader endpoint)  ___ %  MEASURED ***
#     *** connection limit at this instance size   ___    MEASURED ***
#     BufferCacheHitRatio at steady load         > 99.9%
#
#   Then the CAPACITY COMPARISON, both costed:
#     monthly cost, p99 steady, p99 under a spike, idle cost
#     -> a recommendation with the numbers

# ================= Failure modes ==================================
#   half-successful bulk load   200 OK with thousands of rejected
#                               rows. THE REALISTIC INCIDENT. Read
#                               the errors; fail the pipeline.
#   reload creates duplicates   no supplied ~id, or
#                               updateSingleCardinality FALSE.
#                               Invariant 3, by loading twice.
#   unbounded traversal         no per-query memory cap in Neptune -
#                               only the cluster TIMEOUT. Set it,
#                               and bound every query anyway.
#   ConcurrentModification      a write conflict. RETRY with backoff.
#                               Every write path.
#   reader endpoint stale read  no bookmarks. Cluster endpoint for
#                               read-your-writes, or tolerate the
#                               MEASURED lag.
#   connection pool pinned      reader endpoint DNS round-robin. A
#                               new replica is never used. Set a
#                               connection lifetime.
#   instance endpoint + failover  does NOT follow the promotion. Use
#                               the cluster endpoint for writes.
#   restore without parameter   DEFAULT query timeout, audit logging
#   and security groups         OFF, and possibly no connectivity.
#                               Full command in the runbook.
#   openCypher gap shipped      a CLIENT error spike after a deploy,
#                               not an infrastructure problem.
#                               Monitor them separately.
#   no label-level authz        every caller sees everything unless
#                               the application prevents it. State
#                               the compensating design.
#   IAM auth disabled           NO AUTHENTICATION AT ALL inside the
#                               VPC.
#   PageRank expected from      NOT AVAILABLE. Neptune Analytics is
#   the cluster                 a second service, a data movement
#                               step, and a separate cost.
#   Serverless minimum too low  slow to absorb a spike; too high and
#                               you pay for idle. One number, chosen.
#
# Verify after every restore with the three invariants AND the
# parameter group. "The cluster is available" is not verification.

Where to go from here

Longer reading about this subject, written alongside the course.

Course guide How to work through this course Why the model choice comes first, the AWS tax, what the notebook is for, and what to skip. 4 min read

Discussion

No questions on this topic yet. Sign in to ask the first one.