Polyglot persistence - SQL, DocumentDB, Table Storage and Redis for the right job
Polyglot persistence explained by assigning focused responsibilities to Azure SQL, DocumentDB, Table Storage, Redis and Azure Search with rebuild and recovery considerations.
Polyglot persistence - SQL, DocumentDB, Table Storage and Redis for the right job
A single database is attractive because it reduces the number of technologies in the team, but one storage model is not naturally good at every workload. Transactions, documents, audit records, caching and filtering have different access patterns. In the previous article, we discussed Disaster Recovery, RTO, RPO and the fact that every extra data store also needs backup and recovery. In this article, we are going to see polyglot persistence through a fund platform, where Azure SQL, DocumentDB, Table Storage, Redis and Azure Search are each having a focused responsibility.
TL;DR Summary
- Polyglot persistence is using more than one storage technology because data and access patterns are different.
- Azure SQL is a strong default for relational transactions, constraints and reporting joins.
- DocumentDB is useful for JSON documents with a flexible document shape.
- Table Storage is useful for simple key-based records such as audit entries.
- Redis is a cache or session store, not the source of truth.
- Azure Search is an index for filtering and scoring, not the transaction database.
- Every additional store adds consistency, backup, monitoring and rebuild responsibilities.
Challenges
One model is forced everywhere
A fund purchase needs transaction boundaries and constraints, while a news article is read as a JSON aggregate. An audit record is often appended and queried by a partition key. If we force all three into one relational model, either the document becomes difficult to evolve or the audit table becomes a hot spot. The access pattern must lead the choice.
The cache is mistaken for truth
Redis is making a read fast, but it can expire, be evicted or contain an old value. If Redis is treated as the source of a fund unit price, a restart or eviction will change the business result. Cache-aside behaviour must say what happens on a miss and when a value is invalidated.
Consistency is now our responsibility
When SQL updates a price, an event may update DocumentDB, Azure Search and Redis. These are not one hidden transaction. A search index can be behind, and a cache can be stale. The system must explain which view is authoritative and how a projection is rebuilt.
What is polyglot persistence?
Polyglot persistence is an architecture approach where each data capability is stored in the technology which best fits its consistency, query and scale requirements.
In simple terms, the Fund Platform is not having one universal cupboard. It has a ledger for transactions, a document shelf for documents, an audit archive, a fast cache and a search index. We are writing the rules for keeping the derived views aligned.
An everyday analogy is a library. The accounting ledger is like the librarian’s official register, the document store is the archive shelf, the audit log is the visitor book, Redis is the desk’s temporary index and Azure Search is the catalogue. A catalogue can be rebuilt from the books; it should not become the only copy of a book.
Why polyglot persistence is important?
The approach is important when the business domain contains different kinds of data and the cost of a poor fit is visible in performance or maintainability. It can provide better capability, but it is multiplying operational work. The source of truth and rebuild path for every derived store must be known.
The following diagram depicts the Fund Platform and the responsibilities around it:

Azure SQL is used for transactions. DocumentDB keeps fund documents. Table Storage keeps audit logs. Redis serves cache and session reads, while Azure Search supports filtering. The satellites are not saying that every application must use five stores. They show a reason for each store, and the centre reminds us that the platform is one product.
Azure SQL for transactions
SQL is a good fit when the operation requires ACID transactions, foreign keys, unique constraints and relational reporting. A unit purchase can update a holding and an audit row in one transaction:
BEGIN TRANSACTION;
UPDATE Holdings
SET Units = Units + @units
WHERE FundId = @fundId AND InvestorId = @investorId;
INSERT INTO HoldingAudit(FundId, InvestorId, Units, RecordedAt)
VALUES (@fundId, @investorId, @units, SYSUTCDATETIME());
COMMIT TRANSACTION;
The command is validating that the holding exists and that units are not negative. SQL is remaining the source for the financial fact, even if a search index is making the fund list faster.
DocumentDB for fund documents
DocumentDB, called Azure Cosmos DB only in later product naming, is a document-oriented store which is fitting a JSON document model. A fund factsheet can have optional sections and a different shape from another document:
{
"id": "factsheet-123",
"fundId": "FUND-123",
"title": "Fund 123 factsheet",
"language": "en-GB",
"sections": [
{ "name": "Objective", "content": "..." }
]
}
The application is choosing a partition key and query pattern before storing documents. Flexible JSON does not mean unplanned data. Cross-document transactions and relational joins are not being selected as the main capability.
Table Storage for audit records
Table Storage is useful for simple key-based records. A partition key such as Fund-123 and a row key composed from timestamp and event id can support an audit lookup without the relational overhead of every business table. It is not the best fit for a query requiring many relationships, and the design must understand partition distribution.
Redis and Azure Search
Redis is using the cache-aside pattern. The API reads SQL first on a miss, then stores a short-lived value:
var key = "fund-price:" + fundId;
var cached = await cache.GetStringAsync(key);
if (cached != null)
return JsonConvert.DeserializeObject<Price>(cached);
var price = await sql.GetCurrentPriceAsync(fundId);
await cache.SetStringAsync(key, JsonConvert.SerializeObject(price),
TimeSpan.FromMinutes(2));
return price;
Azure Search is receiving a projection of searchable fields and facets. When the SQL record is the source of truth, an indexer or event handler can update Search. If the index is lost, it must be rebuildable from SQL and DocumentDB. It is not becoming the transaction store because it is fast at filtering.
Trade-offs
| Store | Pros | Cons |
|---|---|---|
| Azure SQL | + Transactions and constraints<br>+ Mature relational queries | − Schema and joins need management<br>− Not every document is relational |
| DocumentDB | + JSON aggregates and flexible shape<br>+ Document-oriented reads | − Cross-document transactions are limited<br>− Data modelling still needs discipline |
| Table Storage | + Simple key-based scale<br>+ Good for append-style audit data | − Query model is limited<br>− Relationships are not relational |
| Redis | + Fast cache and session access | − Expiry and eviction are expected<br>− Must not be the system of record |
| Azure Search | + Filtering, facets and scoring<br>+ Good query experience | − Derived data can be behind<br>− Rebuild and indexing failures need handling |
In our case, we are adding a second store only when the access pattern and rebuild story are understood. The fund price is remaining authoritative in SQL, while Redis and Azure Search are derived views. In the next article, we will discuss event-driven architecture with Service Bus topics, which is one way to update those views.
Keeping the stores consistent
The platform is defining which updates are immediate and which are eventual. A unit purchase is committed in SQL before an audit event is published. The event handler can update Table Storage and Azure Search after the transaction. The customer API is reading the SQL result for the confirmation page, while a search page can show “index update pending” for a short period.
An event handler is keeping a checkpoint or processed-event id. If the same PricePublished event is delivered twice, the Search index is receiving one logical update. A failed handler is sending the event to retry or dead-letter handling. It is not writing an empty document to make the error disappear.
A rebuild is tested for each derived store. The Search index can be deleted in a test environment and recreated from SQL and DocumentDB. Redis can be flushed and repopulated through normal cache-aside reads. Table Storage audit rows are exported according to the retention requirement. These exercises also expose schema assumptions which otherwise stay hidden.
Migration begins with one capability. We are not moving all tables because a new database is interesting. A document collection is introduced when JSON documents have a different lifecycle from transactions, and a Search index is introduced when filtering joins become too expensive. The ownership and recovery path are recorded with the migration.
Must Do and Don’ts
- Must Do: Write the source of truth beside every data store, otherwise a cache or index will accidentally become authoritative.
- Must Do: Add a rebuild process for DocumentDB projections and Azure Search, because derived data can be lost or delayed.
- Must Do: Set an expiry and invalidation rule for Redis, otherwise stale prices will be served as current values.
- Must Do: Test the partition key and query pattern with a realistic fund universe, not only with Fund 123.
- Don’t: use Redis as the only copy of holdings, because eviction is a normal cache behaviour.
- Don’t: add a database to avoid one difficult query, otherwise the platform will collect stores without an ownership plan.
Wrap up
In this article, we have looked at Azure SQL, DocumentDB, Table Storage, Redis and Azure Search, and how each store is fitting a different job. Polyglot persistence is not a product shopping list; it is a set of explicit data responsibilities. I hope this article provided you some insights into choosing the right store. In the next article, I will walk you through event-driven architecture with Service Bus topics.
Related Posts
How to use Azure Redis Cache for session state and output cache?
Azure Redis Cache explained for shared session state and output caching, including providers, configuration, cache-aside usage, and multiple web instances.
Azure Service Fabric vs Azure Container Service vs App Service - choosing a hosting model
Azure Service Fabric, Azure Container Service, App Service and Virtual Machines compared through workload fit, operational ownership, scaling and deployment responsibilities.
Designing a multi-region application on Azure - traffic manager and failover
Multi-region Azure application design explained through Traffic Manager routing, primary and secondary regions, SQL replication, latency, health checks and failover practice.