Redis & Hazelcast
- Anand Nerurkar
- Nov 4, 2023
- 4 min read
Updated: Apr 19
Redis | Hazelcast |
Opensource inMemory data structure which can be used as database,cache and messaging broker | opensource in memory data grid that provide distributed caching,distributed computing and messaging capabilities |
support various types of data structure such as list,set,map etc | support distributed data structure like map,queues |
support persistent capabilities to disk, including both snapshotting ,append only files | support persistent capabilities to disk only |
support horizontal scaling with sharding technique | support horizontal scaling by adding more nodes to cluster, vertical scaling by incresing power of existing node |
low latency,high throughput, ideal for usecases that require fast response time | slightly higher latecies as it focuses on strong consistency and distrbuted computing |
replication for high availability but require manual set up | built in replication for high availability |
eventual consistency | strong consistency gurantee |
support for cloud deployment like gcp,aws,azure | support for cloud deployment like gcp,aws,azure |
open spurce and releasd under permissive license | open source and releaded under more restrictive licensecs that may require payment for commercial use |
what is the use case for stateful distributed processing, cluster-wide memory, or shared computation logic where we need hazelcast
ChatGPT said:
Great question! In enterprise microservices architecture, most services are designed to be stateless. However, there are specific use cases where stateful distributed processing, cluster-wide memory, and shared computation logic are essential — and this is where Hazelcast shines.
🔍 Use Cases for Hazelcast in Enterprise Architecture
1. 🕵️ Fraud Detection in Real-Time
Why Hazelcast? Needs high-speed access to a shared, in-memory customer transaction history across multiple services/nodes to detect patterns.
Features Used: Distributed maps, in-memory storage, distributed computation, low-latency event processing.
2. 🧠 Rules Engine or Decision Engine
Scenario: Processing business rules or eligibility checks (e.g., in Loan Origination, Insurance, or Credit Scoring).
Why Hazelcast? All microservices need access to common rule sets and must evaluate complex logic in parallel.
Features Used: Cluster-wide shared data structures, MapReduce, entry processors.
3. 📊 Real-Time Analytics and Dashboards
Scenario: Showing real-time operational dashboards across millions of transactions (e.g., digital wallet transactions, trading apps).
Why Hazelcast? Performs distributed aggregations in-memory without hitting the database.
Features Used: Hazelcast Jet, distributed stream processing.
4. 🔐 Distributed Caching with Compute Logic
Scenario: Caching a product catalog or pricing engine that needs real-time calculations (e.g., personalized pricing).
Why Hazelcast? You cache data AND apply transformation or computation at the node level.
Features Used: EntryProcessors, distributed tasks.
5. ⚙️ Distributed Locking / Coordination
Scenario: Preventing race conditions in multi-service orchestration (e.g., concurrent updates to a shared ledger).
Why Hazelcast? It supports distributed locks, semaphores, and atomic counters.
Features Used: ILock, ISemaphore, IAtomicLong.
6. 🔁 Stateful Microservices that Need Session Affinity
Scenario: Services handling long-running workflows or complex user sessions (e.g., insurance policy creation, claim lifecycle).
Why Hazelcast? Supports session replication and shared memory across nodes.
Features Used: Session replication, cluster-wide object storage.
7. 🌐 Geo-Replication / Disaster Recovery
Scenario: Multi-data-center deployments needing synchronous or asynchronous replication (e.g., global digital banking).
Why Hazelcast? Offers WAN replication of in-memory data between regions.
Features Used: WAN Replication module.
🧩 When Hazelcast Complements Microservices
Microservice Type | Role of Hazelcast |
Orchestrator or Workflow | Shared state, lock handling |
Event Processor | Stream analytics, rule-based filtering |
API Rate Limiter | Shared counters across nodes |
Distributed Scheduler | Centralized task management across services |
Personalization Engine | Realtime user profile + business logic |
✅ Conclusion
Use Hazelcast when your microservices need:
Shared memory/state
Distributed computing on in-memory data
Low-latency processing without DB round-trips
Cluster coordination (e.g., locks, counters)
Real-time data pipelines (Hazelcast Jet)
Otherwise, if your microservices are stateless and data is fetched from DB or external APIs, Redis is typically sufficient.
in enterprise application with microservices based architecture, do we need to use redis or hazelcast
ChatGPT said:
In an enterprise microservices-based architecture, the decision between Redis and Hazelcast depends heavily on your system’s design goals, deployment style, and specific use cases.
Here's a breakdown tailored for enterprise environments:
✅ When to Use Redis in Enterprise Microservices
Best For: Stateless, cloud-native, scalable caching
Scenario | Why Redis Works |
🔁 Caching DB queries, auth tokens, sessions | Redis provides blazing-fast, in-memory access with optional persistence |
🧪 Rate limiting / throttling | Redis supports atomic counters and TTLs natively |
📡 Pub/Sub or lightweight messaging | Redis supports simple Pub/Sub patterns (low-latency) |
🌐 Multi-region distributed apps | Redis can be scaled and replicated (e.g., Azure Cache for Redis with geo-replication) |
🧰 Microservices need shared cache but not shared state | Redis is ideal for stateless microservices |
✔ Recommended when:
You are on cloud platforms like Azure or AWS
You want serverless or container-based deployments (AKS, ECS, etc.)
You prioritize low latency and scalability
You follow an API-first, decoupled architecture
✅ When to Use Hazelcast in Enterprise Microservices
Best For: Stateful services, distributed computing, in-memory data grids
Scenario | Why Hazelcast Works |
🔄 Stateful services that need shared memory (e.g., rules engine, fraud detection) | Hazelcast provides distributed data structures |
⚙️ Need for distributed computation (e.g., MapReduce, in-memory aggregation) | Hazelcast allows co-location of compute and data |
🧵 Complex coordination between services (e.g., distributed locks, atomic counters) | Hazelcast has built-in support for concurrency patterns |
☁️ Kubernetes-native deployments | Hazelcast supports K8s service discovery and auto-clustering |
✔ Recommended when:
You need distributed state, not just caching
You want to process data in-memory across services
You want cluster-wide data structures
You’re building event-driven systems needing stateful coordination
🧩 Real-World Enterprise Guidance
Layer | Suggested Component |
API Gateway | Azure API Management / Istio Ingress |
Session Store | Redis (e.g., Azure Cache for Redis) |
Shared State or Coordination | Hazelcast (only if needed) |
Caching (e.g., user profiles) | Redis |
Async Messaging | Kafka or Redis Pub/Sub (simple) |
Complex Event Processing | Hazelcast (with Jet engine) or Flink |
DevOps | Azure DevOps + Azure Monitor |
⚖️ Final Recommendation
In most cloud-native, stateless microservices, Redis is the go-to default. It’s faster, simpler, and better supported across cloud platforms.
🔄 Use Hazelcast only when your architecture truly needs stateful distributed processing, cluster-wide memory, or shared computation logic — especially in financial, fraud detection, or IoT systems.
Comments