SproutStackSproutStack home
BeginnerHazelcast

A price cache with no eviction

A Hazelcast map caches prices with default settings. The catalog grows ten times.

The setup today

A three-member Hazelcast cluster caches product prices in an IMap. Entries are loaded from the database on a miss through a MapStore. The map uses the default configuration.

Current configuration

map: prices
eviction-policy: NONE        # default
time-to-live-seconds: 0      # default, forever
backup-count: 1

What you know

  • Each member has an 8 GB heap; the map uses about 3 GB per member today, backups included.
  • Most traffic goes to about 10% of products.

The new requirement

The catalog is growing ten times, and pricing now changes every minute instead of once a day. Members must not run out of memory, and shoppers should see a new price within about a minute.

Make the call

2 questions · first-try answers earn the most XP

1. How do you keep members from running out of memory?
2. How do you make price changes show up within about a minute?
What a strong answer also covers
  • If the pricing service can publish changes, invalidating or updating entries on change beats waiting for a TTL.
  • Expect a burst of database reads as many entries expire together; add jitter or refresh-ahead for hot products.
  • Size limits are approximate per member and per partition; leave heap headroom for garbage collection.
  • Keep backup-count 1 so losing a member does not empty part of the cache under load.

The background

More drills