Skip to content

Configuration

Grafeo can be configured for different use cases, from small embedded applications to high-performance server deployments.

Database Modes

In-Memory Mode

For temporary data or maximum performance:

import grafeo

# In-memory database (default)
db = grafeo.Database()
use grafeo::Database;

let db = Database::open_in_memory()?;

Data Persistence

In-memory databases do not persist data. All data is lost when the database is closed.

Persistent Mode

For durable storage:

import grafeo

# Persistent database
db = grafeo.Database(path="my_graph.db")
use grafeo::Database;

let db = Database::open("my_graph.db")?;

Configuration Options

Memory Limit

Control the maximum memory usage:

db = grafeo.Database(
    path="my_graph.db",
    memory_limit=4 * 1024 * 1024 * 1024  # 4 GB
)
use grafeo::{Database, Config};

let config = Config::builder()
    .memory_limit(4 * 1024 * 1024 * 1024)  // 4 GB
    .build()?;

let db = Database::open_with_config("my_graph.db", config)?;

Thread Pool Size

Configure parallelism:

db = grafeo.Database(
    path="my_graph.db",
    threads=8
)
use grafeo::{Database, Config};

let config = Config::builder()
    .threads(8)
    .build()?;

let db = Database::open_with_config("my_graph.db", config)?;

Default Thread Count

By default, Grafeo uses the number of available CPU cores.

Configuration Reference

Option Type Default Description
path string None Database file path (None for in-memory)
memory_limit int System RAM Maximum memory usage in bytes
threads int CPU cores Number of worker threads
read_only bool false Open database in read-only mode

Environment Variables

Grafeo can also be configured via environment variables:

Variable Description
GRAPHOS_MEMORY_LIMIT Maximum memory in bytes
GRAPHOS_THREADS Number of worker threads
GRAPHOS_LOG_LEVEL Logging level (error, warn, info, debug, trace)

Performance Tuning

For High-Throughput Workloads

db = grafeo.Database(
    path="high_throughput.db",
    memory_limit=8 * 1024 * 1024 * 1024,  # 8 GB
    threads=16
)

For Low-Memory Environments

db = grafeo.Database(
    path="embedded.db",
    memory_limit=256 * 1024 * 1024,  # 256 MB
    threads=2
)

For Read-Heavy Workloads

# Multiple read replicas can be opened read-only
db = grafeo.Database(
    path="replica.db",
    read_only=True
)

Next Steps