Introduction to Terracotta
Terracotta is a comprehensive, distributed in-memory data management solution which caters to caching and operational storage use cases, and enables transactional and analytical processing. Terracotta has one of the most powerful query and computation capabilities in its class, leveraging native JDK features such as Java Streams, collections, and functions.
Terracotta supports the following sub-systems:
1. A storage sub-system called TCStore, that caters to operational store and compute functionality. The API exposing this sub-system's functionality is the TCStore API.
2. A caching sub-system called Ehcache, that caters to caching functionality. The API exposing this sub-system's functionality is the Ehcache API.
Both sub-systems are backed by the Terracotta Server, which provides a common platform for distributed in-memory data storage with scale-out, scale-up and high availability features.
The Terracotta APIs
Terracotta offers two distinct APIs for caching and storage:
Ehcache API
The Ehcache API is an improved version of Java's de facto caching API, Ehcache. It has a powerful, streamlined, modernized caching API taking advantage of newer Java features as well as the capability to be used via the JSR-107 "JCache" API. Some of the key high level feature of this API include:
Leverages Java generics and simplifies cache interactions
Full compatibility with javax.cache API (JSR-107)
Storage
In-memory storage with optional persistence to disk and ultra-fast recovery
Java-based Key/Value store optimized for caching workloads
The industry's first and best Offheap storage capabilities
Distributed Store
Supports various scale-out and HA deployment configurations
Flexible, fine-granular configuration of availability, consistency, and durability
TCStore API
TCStore API is an interface for distributed in-memory data storage and computation, which has powerful ties to JDK features related to streams, collections and functions. Under the hood it is powered by a completely new and powerful storage engine which is an "Aggregate oriented, Key-Value, wide-column store" built upon a very high performance and highly scalable architecture. Some of the key high level feature of this API include:
Flexible Data Model
Aggregate oriented, Key-Value store
Loose schema: modeling of data with structured and typed aggregate values within records
Storage
In-memory storage with optional persistence to disk and ultra-fast recovery
Java-based Key/Value store optimized for data storage workloads
Secondary in-memory indexes to speed-up search and compute
Distributed Store
Supports various scale-out and HA deployment configurations
Flexible, fine-granular configuration of availability, consistency, and durability
Data Analysis
Search and Analyze capabilities that work naturally with Java 8 technologies
Java stream API to filter, aggregate, map data
DSL with a library of pre-implemented lambda functions enabling server-side execution of queries
Along with the two separate APIs, Terracotta is built upon the next generation of Terracotta Server/Server Array. Both the Ehcache API and the TCStore API leverage the power of this new distributed computing platform with reduced complexity and enhanced performance and scalability. Similarly the shared platform provides common monitoring and management capabilities.
Illustration of the separation of use cases. Ehcache versus TC Store API with a common platform and management.
Ehcache versus TCStore: Why Two Different APIs?
The two different APIs help simplify development and separation of data management concerns based upon use case. In a nutshell:
Ehcache is the right API to: ...
... access relevant data, in large amounts, at maximum speed by simple key/value look-up
... load hot, fresh data for as short as you may need it and replace stale data by more relevant data from the System of Record
... offload work from the System of Record
because Ehcache ...
... continually works to keep hotter, fresher entries available at the fastest, in-memory speeds
... is optimized to for application caching needs
TCStore is the right API to: ...
... store data that you always expect to be there (free from eviction concerns)
... store data that you expect to perform reliable search and queries on, at in-memory speeds
... be your database of record
because TCStore ...
... allows data to be structured and strongly typed
... entries can be looked up by key and queried on by field
It's important to understand that there is a strict separation between the Ehcache API and the TCStore API, even when used with the same Terracotta Server:
Any information placed using the TCStore API cannot be retrieved using the Ehcache API and vice versa.
Terracotta Server provides the core distributed storage platform and is common for data placed using both the Ehcache API and the TCStore API, yet the cache data is managed separately from stored data.