Overview
What Red Hat Data Grid is, how a cluster of caches behaves, and when to run it instead of Redis.
Red Hat Data Grid is the supported build of Infinispan, a distributed in-memory store. Applications put keys in a cache. The cache is spread across pods, so one pod dying does not take the entries with it, provided you asked for more than one copy. Clients talk to it over Hot Rod, a binary protocol on port 11222, or over REST on the same port. The thing you install on OpenShift is the Data Grid Operator, which owns an Infinispan custom resource.
Redis, from the Redis labs, is the other in-memory service in this series. They overlap. They are not the same product, and picking the wrong one shows up as a client you have to babysit or a feature you do not have.
What a cluster actually does
You ask the operator for three replicas. It runs a StatefulSet. The pods find each other and form a cluster. A distributed cache splits keys across those pods, with an owner count: owners: 2 means every entry lives on two pods, so you can lose one pod and keep the data. A replicated cache keeps every entry on every pod. A local cache keeps entries on the pod that wrote them and does not pretend otherwise. The cache modes lab is the detail.
Hot Rod clients are topology-aware by default. The server tells the client which pod owns a key, and the next call goes there. Inside Kubernetes that intelligence often points at a pod IP the client cannot route to, so Java clients on OpenShift usually set client intelligence to BASIC and talk to the Service. The connecting applications lab shows the setting. It is the one that saves an afternoon.
Entries can expire, they can be evicted when the cache is full, and they can be written through to a store. Memory is still the working copy. A JDBC store, in the persistence lab, is how an entry survives all the pods being down. A backup of the cluster state is a different operation, in Backup and restore.
Data Grid and Redis
| Data Grid | Redis | |
|---|---|---|
| Clients we wire up | Java (Hot Rod, Spring, Quarkus), EAP sessions, a .NET REST client | Polyglot, one protocol, a client in every language |
| Cluster model | Pods are peers. Owners and state transfer are built in | Primary and replica, or Cluster with hash slots. You choose Sentinel or Cluster |
| Query | Ickle queries over indexed fields, Protobuf schemas | Key access, plus the Redis 8 query engine where the image includes it |
| Sessions | A supported path for JBoss EAP and JBoss Web Server | A supported path for Spring Session and most other frameworks |
| Cross-site | Backup caches between two clusters, relayed by the operator | A snapshot you ship, or a replica you operate yourself |
| When it is the one we install | The application is Java or .NET and wants a clustered cache with queries, or EAP needs its sessions out of the pod | The access is by key, the clients are mixed, or the feature is pub/sub, streams, or a small vector index |
Use PostgreSQL when the data is the system of record. Use Kafka when other systems must replay the event. Data Grid and Redis both sit in front of those, holding the copy a request needs this instant. The data pipeline overview shows that serving slot.
A cache of a database row has to be invalidated when the row changes. Data Grid will not notice a commit it did not do. The application deletes or updates the key, or a change-data-capture flow does. The same rule as Redis.
What this series runs
The operator API is infinispan.org/v1 for the cluster and infinispan.org/v2alpha1 for a Cache, a Backup and a Restore. Data Grid 8.5 is the line the YAML in these labs targets. A later 8.x operator uses the same resources. If a field is rejected, oc explain on that field beats a guess.
- Data Grid on OpenShift: the operator, a cluster, a cache.
- Caches and cache modes: distributed, replicated, local, eviction, expiration.
- Connecting applications: Hot Rod and REST from Spring Boot, Quarkus and .NET.
- Session externalisation: EAP, Spring Boot and Tomcat.
- Persistence: a JDBC store on PostgreSQL.
- Querying: Protobuf, indexes, Ickle.
- Cross-site replication: DC and DR.
- Backup and restore: the operator's Backup CR.
- Security and monitoring: auth, roles, TLS, Prometheus.
What you operate
Day to day you care about four objects:
- The
Infinispancluster: are the podsWellFormed, and is the version the one you meant to run. - The
Cacheresources in Git: mode, owners, encoding, expiration. A cache created by hand in the console will drift from Git. Prefer the CR. - The Secret the operator generated, or the identities Secret you replaced it with. It is a credential. It does not belong in a ticket.
- The clients: Hot Rod with
BASICintelligence, or REST, both over TLS toexample-infinispan.datagrid.svc:11222.
Backups and cross-site links are extra objects, added in their own labs, once a single cluster can lose a pod and still return the key. Start there. A cross-site design on top of a cache with owners: 1 replicates a layout that already loses keys inside one site.
Data Grid is memory. Size the container for the entries you will actually hold, and for the JVM on top of them. A pod at its memory limit will be killed, and state transfer from the survivors will make the remaining pods busier. The monitoring lab is where that graph lives. The cache-modes lab is where eviction is a choice instead of a surprise.
A first put and get
After the next lab has a cluster and a cache named catalog, the REST port answers. The operator stores a developer user in <cluster>-generated-secret.
PASS=$(oc get secret -n datagrid example-infinispan-generated-secret \
-o jsonpath='{.data.password}' | base64 -d)
oc exec -n datagrid example-infinispan-0 -- \
curl -sk -u "developer:${PASS}" \
-X POST -H 'Content-Type: application/json' \
https://localhost:11222/rest/v2/caches/catalog/sku-42 \
-d '{"sku":"42","price":120}'
Reading it back with GET on the same URL should return the JSON. The pod IP and the Service both work from inside the namespace. That is enough to prove the cluster is a cache and not only a StatefulSet.
What a cache is not
A cache entry is a copy. If the application writes only to Data Grid and nowhere else, Data Grid has become the system of record, and a flush, an eviction, or a restore from yesterday will delete data you cannot rebuild. Put the durable row in PostgreSQL, the event on Kafka, and the hot key here.
Three pods with owners: 2 survive one pod. They do not survive the namespace being deleted, and they do not survive both owners restarting before state transfer finishes. That is why persistence and backup are separate labs, and why a single-replica cache is a lab convenience rather than a design.
Watch oc get infinispan -n datagrid and expect WellFormed. Any other condition means the pods have not finished joining, and a client timeout at that moment is the cluster, not the application. Wait for WellFormed before the first put. A cache CR can exist before that and still refuse writes.
The namespace in these labs is datagrid and the cluster name is example-infinispan. Change both if your platform reserves them. Keep the name stable once clients embed it.
What's next
Data Grid on OpenShift builds the cluster this page assumed. If the clients are not Java and you only need keys, start with Redis instead. Cross-site copies of the cache are Cross-site replication.