How does the storage backend influence Datomic?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
How the Storage Backend Influences Datomic
Datomic is a database system designed to provide ACID transactions, horizontal read scalability, and a unique architecture model that leverages immutable data. One of the foundational aspects of Datomic is its storage backend. The choice of storage backend can have implications on the performance, scalability, data modeling, and operational features of Datomic. This article explores how various storage backends influence Datomic, providing technical explanations and examples where relevant.
Datomic's Architecture
Before diving into storage specifics, it's essential to understand Datomic’s architecture:
- Transactor: The component responsible for processing transactions.
- Peer: An in-memory query engine that allows applications to execute queries and utilize the database.
- Storage: Where data and transactions are durably stored.
Datomic separates the transaction process from the query engine. Continuous read scalability is achieved by using multiple peers, while a single transactor ensures transaction consistency. The storage, or the backend, plays a critical role in persistence and data retrieval.
Types of Storage Backends
Datomic supports various storage backends, each with distinct characteristics:
- DynamoDB
- PostgreSQL
- Cassandra
- H2 (for development and testing)
- Cloud Storage (for Datomic Cloud)
DynamoDB as a Storage Backend
DynamoDB is often the default choice for deployments on AWS due to its managed nature and scalability. Here’s how it influences Datomic:
- Scalability: DynamoDB offers automatic scaling for both storage and throughput, allowing Datomic to handle large volumes of data and high requests without manual intervention.
- Operational Overhead: With DynamoDB, users benefit from a fully managed service, reducing the operational overhead of manually maintaining the storage layer.
- Consistency and Latency: DynamoDB offers eventual consistency by default but can be configured for strong consistency. This impacts how quickly data becomes available to peers after a transaction.
PostgreSQL as a Storage Backend
For deployments requiring relational database support, PostgreSQL offers a familiar SQL-guided experience:
- ACID Properties: PostgreSQL ensures strong ACID compliance, which translates into highly reliable transactions, an advantage when precise data consistency is crucial.
- Data Modeling: Supports complex queries owing to its rich SQL capabilities, allowing Datomic users to benefit from the relational model’s strengths.
- Performance Considerations: PostgreSQL can become a performance bottleneck under intense load compared to specialized NoSQL solutions.
Cassandra as a Storage Backend
Cassandra is another option, often chosen for its distribution model:
- Distributed Nature: With Cassandra, data is distributed across multiple nodes, offering high availability and resilience against data center failures.
- Query Model Limitation: While Cassandra provides excellent write performance and high availability, its read performance for certain complex queries may not match other databases.
- Eventual Consistency Model: It operates on an eventual consistency model, making it suitable for applications that can tolerate some inconsistency or require high availability.
H2 for Development and Testing
H2 is generally used in development and testing scenarios:
- Ease of Use: It is lightweight and requires minimal setup, making it ideal for non-production environments.
- In-Memory Option: Developers can choose in-memory databases for rapid iteration and testing without needing persistent storage.
- Limited Scale: Not suitable for production-grade applications due to its single-node architecture and lower scalability.
Cloud Storage for Datomic Cloud
Datomic Cloud introduces an abstraction over various storage models, shifting the burden of managing storage from users to the cloud infrastructure:
- Integration: Provides seamless integration with AWS services, including advanced security and compliance features.
- Elastic Scalability: Automatically scales to match the workload, benefiting unpredictable workloads and scaling needs.
- Cost Management: Pay-as-you-go model allows for dynamic cost management.
Key Considerations Based on Backend
| Backend | Scalability | Consistency | Operational Overhead | Best Use Case |
| DynamoDB | High | Configurable (eventual/strong) | Low | Large-scale applications on AWS |
| PostgreSQL | Moderate | Strong | Moderate | Applications needing relational data |
| Cassandra | High | Eventual | High | High availability and distributed scenarios |
| H2 | Low | Strong | Low | Development and testing |
| Cloud Storage | High | Configurable | Very Low | Cloud-native applications targeting AWS |
Additional Details
Transaction Latency
The storage backend impacts transaction latency. For instance, DynamoDB might present higher latencies compared to PostgreSQL in scenarios where strong consistency is enforced, due to the round-trip times to AWS's distributed system.
Data Retrieval Patterns
Different storage backends optimize for varying data retrieval patterns. For example, PostgreSQL is highly effective for complex join operations, whereas DynamoDB shines when handling high transaction volumes but may require denormalization for complex reads.
Security and Compliance
The choice of storage backend can significantly influence security and compliance considerations. While Datomic inherently supports encryption, using managed services like DynamoDB or Datomic Cloud leverages AWS's extensive security frameworks.
Conclusion
The choice of storage backend plays a pivotal role in shaping how Datomic performs and scales. Each backend offers a unique balance of trade-offs across scalability, consistency, and operational overhead. Selecting the right backend requires an evaluation of application requirements, deployment environment, and long-term scalability needs. Through this understanding, users can tailor Datomic’s capabilities to best suit their specific use cases.
Related reading
- How does Top-K sort algorithm work in MongoDB
- How does TransactionScope roll back transactions?
- How does waiting & atomic clock help GCP spanner solve Linearizability and Serializability in distributed transaction?
- How does YugaBytes performance compare between Redis client and Postgres client for simple Key-Value schema?
- How efficient is locking an unlocked mutex? What is the cost of a mutex?
- How exactly does a XOR Linked list work?
- How DolphinDB clears historical data from distributed tables?
- How DynamoDB provisions throughput of reads independently of writes

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.