Polyglot Persistence & Use Cases Flashcards
Know when to combine SQL and NoSQL for the right architectural fit. Sample Interview Questions: "What is polyglot persistence and why is it useful?" "How would you design a system using both MongoDB and PostgreSQL?" Topics: Polyglot persistence: definition and benefits Choosing the right database per component Example architecture: product catalog in MongoDB + orders in PostgreSQL Event sourcing with NoSQL stores Data synchronization between SQL and NoSQL Best practices for multi-datab (23 cards)
What is polyglot persistence?
Polyglot persistence is the practice of using different types of databases within a single system architecture to leverage the strengths of each for specific use cases.
Why is polyglot persistence useful?
It allows developers to optimize each component of a system by using the most suitable database for the job, improving performance, scalability, and flexibility.
When would you use polyglot persistence?
When different parts of an application have different data requirements, such as using MongoDB for flexible document storage and PostgreSQL for transactional integrity.
What are the benefits of polyglot persistence?
Better performance, flexibility, scalability, and the ability to match the right database to specific data access patterns and workloads.
What are the drawbacks of polyglot persistence?
Increased complexity in architecture, data synchronization, maintenance, monitoring, and consistency management.
How would you design a system using both MongoDB and PostgreSQL?
Use MongoDB for the product catalog to store flexible product data, and PostgreSQL for orders and transactions to ensure ACID compliance.
What is an example use case for combining MongoDB and PostgreSQL?
E-commerce platform: MongoDB for the dynamic product catalog and PostgreSQL for order processing and user data.
What is event sourcing and how does it relate to NoSQL?
Event sourcing stores state changes as a sequence of events. NoSQL databases like Cassandra or DynamoDB are often used for storing high-volume event data efficiently.
What is an example architecture using polyglot persistence?
Microservices-based system with: MongoDB for product metadata, Redis for caching, PostgreSQL for transactions, and Elasticsearch for search.
How do you synchronize data between SQL and NoSQL databases?
Use change data capture (CDC), event-driven architecture, or scheduled ETL jobs to ensure consistency and data flow between systems.
What are best practices for multi-database systems?
Clearly define ownership and purpose of each database, maintain consistent identifiers, automate synchronization, and monitor each system independently.
What is the impact of polyglot persistence on system design?
It introduces additional complexity in architecture, data flows, and maintenance, but enables optimal design per domain or microservice.
What are the performance considerations in polyglot persistence?
Latency and throughput may vary across databases; caching, batching, and asynchronous communication help reduce overhead.
What is a fault tolerance strategy in a multi-database setup?
Ensure each database has its own high availability mechanisms; use retry logic and fallback paths for data synchronization.
How do you monitor a polyglot persistence system?
Use distributed monitoring tools like Prometheus, Grafana, ELK stack, and database-native monitoring to track performance and availability.
How do you debug issues in a multi-database architecture?
Trace request flows using correlation IDs, inspect logs across services, and use monitoring data to isolate slow or failing database interactions.
What are real-world tradeoffs in using multiple databases?
You gain optimized components and flexibility but must manage increased complexity, synchronization issues, and deployment overhead.
What are common interview questions about polyglot persistence?
‘What is polyglot persistence?’, ‘Why combine SQL and NoSQL?’, ‘How do you keep data consistent across databases?’, ‘Give a real-world example.’
What are potential gotchas with polyglot persistence?
Inconsistent data models, eventual consistency issues, increased ops overhead, lack of unified query capabilities, and testing challenges.
What does ‘choosing the right database per component’ mean?
It means evaluating the needs of each system component (e.g., scalability, consistency, flexibility) and selecting the best database technology accordingly.
What role does NoSQL play in event sourcing?
NoSQL databases like Cassandra or DynamoDB can efficiently store large volumes of immutable events with fast writes and scalable storage.
What are architectural implications of polyglot persistence?
You must support multiple query languages, manage data flow and consistency between databases, and design services to isolate storage logic.
What is an example of event sourcing with NoSQL?
A financial ledger system where each transaction is stored as an event in DynamoDB, with periodic snapshots in S3 for recovery.