The Architecture of Airbnb's Knowledge Graph

Arpit Bhayani

Arpit Bhayani

Sep 23, 2022 • 7 min read

Play

The Architecture of Airbnb’s Knowledge Graph

When a travel platform reaches the scale of Airbnb, presenting contextual and enriched exploratory information becomes a core product requirement. Airbnb does not merely handle apartment rentals; it encompasses a complex ecosystem of experiences, neighborhoods, landmarks, events, restaurants, and geographical areas.

To power downstream services like Search, Discovery, and Trip Planning, Airbnb unified this rich domain data into a Knowledge Graph. This architectural deep-dive examines how Airbnb structures this graph, the pragmatism behind choosing relational storage over dedicated graph databases, and how mutations and queries flow through the platform.


The Limitations of Traditional Relational Schemas for Exploration

In standard transactional architectures, data is siloed by domain entity into dedicated tables (e.g., hotels, events, experiences, listings). Foreign keys connect related entities, supporting transactional, low-latency, point-lookup operations (like booking confirmations or user profile queries).

However, exploratory search demands traversing deeply connected, heterogeneous entities across arbitrary relationship paths. Consider queries such as:

  • “Find the top 5 cities hosting a specific type of surfing experience during July and August.”
  • “Find neighborhoods in Los Angeles where there are huts or treehouses with over 5,000 listings and scenic category designations.”
Traditional SQL Joins Across Silos:
Listing -> Neighborhood -> City -> Experiences (in July/August) -> Category (Scenic)

Executing such cross-domain, multi-hop traversals across disparate microservices and independent database shards via dynamic multi-table JOINs introduces:

  1. Severe Join Latency: Unpredictable relational joins across massive data sets.
  2. Microservice Query Fan-Out: Orchestrating point-to-point RPC calls across several domain services introduces excessive network overhead and tail-latency amplification.
  3. Fragile Schemas: Hardcoded foreign-key structures cannot easily model dynamic, evolving relationships between diverse real-world entities.

To solve this, Airbnb collates these disparate domain models into a centralized Knowledge Graph.


Core Components of the Knowledge Graph Architecture

Airbnb’s Knowledge Graph architecture is broken into three primary infrastructure layers:

  1. Graph Storage: The persistent engine that models and stores nodes and edges.
  2. Graph Query API: The traversal and query interface exposed to consuming services.
  3. Storage Mutator (Ingestion Layer): The mechanism handling synchronous and asynchronous state synchronization.
flowchart TD
    subgraph Ingestion [Storage Mutator / Ingestion Layer]
        Kafka[Kafka Mutation Topics]
        BatchJob[Batch & Streaming Ingestion Jobs]
        SyncAPI[Sync Graph API Mutator]
    end

    subgraph Storage [Graph Storage Layer]
        RDBMS[(Relational Database: Nodes & Edges)]
        Warehouse[(Data Warehouse / S3 / Redshift)]
    end

    subgraph Serving [Graph Query Layer]
        QueryAPI[Graph Query API]
        StorageAbs[Storage Abstraction / SQL Translator]
    end

    subgraph Clients [Downstream Consumers]
        Search[Search Service]
        Planner[Trip Planner]
        Discovery[Discovery / Landing Pages]
        OfflineML[Offline Ranking / RecSys]
    end

    Kafka --> BatchJob
    BatchJob --> RDBMS
    SyncAPI --> RDBMS

    Clients --> QueryAPI
    QueryAPI --> StorageAbs
    StorageAbs --> RDBMS

    RDBMS -.->|Periodic Dump| Warehouse
    Warehouse -.-> OfflineML

1. Graph Storage: Why Relational DBs Instead of Graph DBs?

A standard assumption when architecting a knowledge graph is that one must deploy a specialized graph database (e.g., Neo4j, JanusGraph). However, Airbnb chose to back their Knowledge Graph with a standard Relational Database.

The Operational Trade-Off

Specialized graph databases introduce:

  • High operational maintenance and specialized observability overhead.
  • Unproven horizontal scaling characteristics under high concurrent read loads compared to mature RDBMS engines.
  • A lack of in-house operational expertise within existing platform infrastructure teams.

By leveraging an existing, battle-tested relational database, Airbnb maximized reliability, leveraged well-understood backup/restore systems, and minimized cognitive load for infrastructure engineers.

Modeling Graphs in Relational Tables (S-V-O Triplet)

Graph databases model relationships using subject-predicate-object triples (Subject, Verb, Object): Subject (Node)Verb (Edge)Object (Node)\text{Subject (Node)} \xrightarrow{\text{Verb (Edge)}} \text{Object (Node)}

Example: [New York] (Subject) -> [IS_IN] (Verb) -> [USA] (Object)

In a relational model, this is mapped via two core concepts:

  1. Node Schema Registry:
    • Each node has an entity type and an associated schema.
    • Location Node: Contains name, latitude, longitude.
    • Event Node: Contains name, date, venue_id.
  2. Edge Constraints & Schema:
    • Edge types strictly define what source and destination node types they can link.
    • Example Edge Type: LANDMARK_IN_CITY strictly binds a Landmark source node to a City target node (e.g., Taj Mahal \rightarrow Agra).
    • This strict edge-type validation prevents schema rot and enforces structural integrity across the graph.

Offline Dumps for Bulk Analytical Processing

Online real-time graph engines should not be bogged down by heavy, read-intensive machine learning workloads.

Airbnb executes periodic database dumps of the Knowledge Graph into offline data lakes/warehouses (such as Amazon S3, Redshift, or Hive). Offline systems—such as listing ranking, contextual search weighting, and recommendation engines—process these snapshots in bulk without placing read contention on the primary graph database.


2. Graph Query API: Abstraction & Translation

Consuming services (Search Service, Trip Planner, Listing Service) do not write raw SQL against the underlying relational tables. Instead, they interact with a specialized Graph Query API.

sequenceDiagram
    autonumber
    participant Client as Search / Planner Service
    participant API as Graph Query API
    participant Abs as Storage Abstraction
    participant DB as Relational Storage

    Client->>API: POST /query (Declarative JSON Graph Query)
    API->>Abs: Parse & Validate Node/Edge Predicates
    Abs->>Abs: Compile JSON into Optimized SQL
    Abs->>DB: Execute SQL Query
    DB-->>Abs: Raw Tabular Result Set
    Abs-->>API: Map Rows to Graph Response DTO
    API-->>Client: Structured Entity Graph Response

Declarative JSON Query Syntax

Clients specify graph traversals declaratively using a structured JSON dialect. The payload articulates the source nodes, target edges, conditions, and filter predicates.

Conceptual query payload:

{
  "source_node": {
    "type": "City",
    "name": "Los Angeles"
  },
  "edge": {
    "type": "CONTAINS_LOCATION"
  },
  "target_node": {
    "type": "Place",
    "filters": [
      {"field": "listing_count", "operator": ">=", "value": 5000},
      {"field": "category", "operator": "=", "value": "scenic"}
    ]
  }
}

The Storage Abstraction Layer

The Graph Query engine receives this JSON AST (Abstract Syntax Tree), validates edge constraints against the schema registry, and maps the graph traversal into optimized SQL queries executed directly against the relational database index layer.

This abstraction shields downstream consumers from knowing whether the underlying storage engine is an RDBMS, a graph database, or an in-memory key-value cache.


3. Storage Mutator: Asynchronous Updates at Scale

In a distributed microservice topology, individual entities change constantly: listing descriptions update, prices change, new experiences are registered, and reviews are submitted. Propagating these changes to the Knowledge Graph requires careful capacity planning.

The Failure Mode of Synchronous Mutation

If every domain microservice fired a synchronous HTTP/gRPC mutation call to the Knowledge Graph API whenever an entity changed:

  • Spike Traffic & Contention: Sudden surges in write traffic would saturate database connections and degrade online read latency for search.
  • Cascading Failures: A slowdown in the Knowledge Graph would block upstream domain services.
  • Lack of Bulk Efficiencies: Individual micro-writes prevent write-batching optimizations.

The Asynchronous Kafka Pipeline

To decouple domain services from graph ingestion, Airbnb uses an event-driven architecture powered by Apache Kafka:

flowchart LR
    Microservices[Domain Microservices<br/>Listing, Events, Locations] 
    -->|Emit Change Events| Kafka[(Kafka Topics)]
    Kafka --> Mutator[Storage Mutator Service]
    Mutator -->|Batched Writes| RDBMS[(Relational DB)]
  1. Event Streaming: When a domain microservice modifies an entity, it publishes a schema-validated mutation event to Kafka.
  2. Buffer & Absorption: Kafka serves as an elastic shock absorber, holding mutation requests safely on disk.
  3. Batch Mutations: The Storage Mutator Service consumes messages from Kafka and performs bulk insertions and updates against the relational graph tables, minimizing lock contention and transactional overhead.
  4. Dual-Ingestion Support: While the overwhelming volume of updates occurs asynchronously via Kafka, a synchronous Graph Mutation API remains available for edge cases requiring immediate read-your-own-writes consistency.

Key Architectural Takeaways

Design DecisionAirbnb ApproachPrimary Advantage
Storage EngineRelational Database (S-V-O format)Operational maturity, established reliability, low maintenance overhead.
Query LayerDeclarative JSON translated to SQLHigh-level graph interface; isolates clients from low-level relational schemas.
Data IngestionAsynchronous Kafka consumptionAbsorbs high-volume write spikes; enables batched persistence.
Analytical AccessPeriodic Dumps to Data WarehouseKeeps resource-intensive machine learning/ranking jobs off the active transactional graph.

“Simple systems scale best.”

Airbnb’s Knowledge Graph demonstrates that powering state-of-the-art exploratory search does not mandate adopting nascent or operationally complex graph database technology. By combining standard relational structures, strict edge constraints, declarative query translation, and asynchronous event streaming, they achieved a scalable, resilient system using mature primitives.

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses