Polyglot persistence is simply the notion that one should leverage multiple data storage technologies chosen based upon the way the data will be used by the application.
In short, use the best tool for the job.
- Attempting to make a single data store (or database if you prefer) encapsulate all your application contexts breeds complexity. When each context, entity or value object can tune the data store leveraged to the unique requirements of that domain complexity is reduced and feature velocity is increased.
- Polyglot enables in data store transformation, materialized views and projections of the data into alternate stores for the purpose of enabling specific application features. Simply put, you can have multiple representations of the same data where and when it is convenient in your application context.
- Data store spend is targeted toward the features and contexts in the application which actually require the investment.
- Joins – perceived complexity due to the inability to create a single “query” joining multiple contexts, entities or value objects.
- Understanding the benefits of composition allows us to see this as a false barrier – it is simply an issue of changing from the old way of doing things.
- Maintenance cost – expertise and management of multiple data stores adds to the overall cost of operating the application.
- In a monolithic data store system extensive effort is put into the “tuning” of the data store. This is always due to either the massive complexity of data stores that try to do everything or the need to make a single data store solve too many disparate persistence models. When we use data stores which are “natural” to the domain, context or entity this overhead is massively reduced.
- Developer Complexity – finding and staffing developers that can work with multiple data stores is impossible.
- When transforming from a monolithic data store architecture this will absolutely be problematic. However, as your polyglot practice matures this issue will diminish with time.
All of the above relies on having a solid domain driven design and flexible, adaptable architecture for your application.