Skip to content
Back to Deployment

Deploying Neo4j

Graph database for connected data, Cypher query language, and graph algorithms.

PlatformsAdvanced

Why

Neo4j stores data as nodes and relationships, making connected queries (friends-of-friends, recommendations) O(1) instead of O(n) joins in SQL. Cypher is a declarative graph query language.

Platform-as-a-Service adoption grew 24% in 2024 as teams shift from VM management to git-push deploys. the cloud infrastructure market reached $330B in 2024, growing 22% year-over-year (Synergy Research), and PaaS layers capture the majority of new workloads.

When

Use Neo4j for social networks, recommendation engines, fraud detection, and knowledge graphs. Avoid for simple CRUD (use SQL).

How

1. Docker — neo4j:5 image with volume 2. Auth — NEO4J_AUTH=neo4j/password 3. Cypher — Cypher Shell or Browser at :7474 4. Import — LOAD CSV or APOC procedures 5. Index — CREATE INDEX FOR (n:User) ON (n.email) 6. Cluster — Neo4j Enterprise for causal clustering 7. Driver — neo4j-driver for JS/Python/Java

Example

# docker-compose.yml services: neo4j: image: neo4j:5 environment: NEO4J_AUTH: neo4j/password ports: ["7474:7474", "7687:7687"] volumes: [neo4jdata:/data] volumes: { neo4jdata: } # Cypher — create and query CREATE (alice:User {name: "Alice"})-[:KNOWS]->(bob:User {name: "Bob"}); MATCH (u:User {name: "Alice"})-[:KNOWS*1..2]-(friend) RETURN friend.name; # JS driver import neo4j from "neo4j-driver"; const driver = neo4j.driver("bolt://localhost:7687", neo4j.auth.basic("neo4j", "password")); const session = driver.session(); const result = await session.run("MATCH (u:User) RETURN u");

Common Problems

  • ⚠No indexes — full graph scans, create indexes on lookup properties
  • ⚠Memory too low — Neo4j needs 2-4GB minimum, set NEO4J_server_memory_heap_max__size
  • ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical

Best Practices

  • ✓Create indexes on all lookup properties — huge query speedup
  • ✓Use APOC procedures — utility functions for import, traversal, and ETL
  • ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit

FAQ