1

In one of our project, we are using openshift v3.X to host our spring boot rest services. In the services, we have implemented Guava Cache and we do clear the cache in certain actions.

eg. When user wants the list employees from a table, it returns the all employee list and cache it. Now If any update happens to any employee record, we do clear the cache and reload it.

But we observed that while immediately it gives the updated cache, it gives original old cache in some cases. Suppose, we refresh our UI where we are displaying the records. Does this behavior when there are more than one pods?

Note: We are observing this issue when we use more than one POD for the service. So, do we need to take any special care when we use multiple pods for a service to manage cache?

We use @CacheEvict to clear the clear the Cache.

Any pointers will be much appreciated.

Thanks in Advance.

user3913069
  • 31
  • 1
  • 3
  • This reads like you have created a local cache in each JVM and then started multiple pods each containing a JVM with a local cache. The problem wouldn't have anything to download with Openshift it would be a problem that you are running multiple JVMs with independent caching. – simbo1905 Dec 24 '17 at 15:30
  • I have created the cache using @Cacheable in service layer. does it create in local ?? How do we create single cache independent of pods/jvm in spring boot? Thanks – user3913069 Jan 24 '18 at 04:09
  • you are asking does a pure Java feature running inside a particular linux container stack workout how to deploy a shared cache into the hosting container orchestrator. There are many such technologies, OpenShift, CloudFoundry, Marathon, Mesos, .. plus solutions such as Amazon ECS, Azure ACS. It is unreasonable to expect that putting an annotation on your Java would deploy a shared cache into any one of those solutions you happen to be using on your current project. You should aim to be able move your code to a new project that uses a totally different container platform. (dependency injection) – simbo1905 Jan 24 '18 at 08:58
  • you need to split you question "How do we create single cache independent of pods/jvm in spring boot" into two google queries. the first "how to create a shared cache on openshift" and the other "how to integrate with a shared cache with spring boot". first find out the preferred shared cache solution for your organisation (e.g. Redis, memcached, hazelcast, ...). then google how to deploy it into openshift and how to connect to it from springboot. – simbo1905 Jan 24 '18 at 09:00
  • you might want to read https://12factor.net and particularly point IV as a shared cache is a "backing service". i would advise spending a lot of time researching every single one of those 12 points to understand the philosophy of technologies like openshift, cloudfoundry, and other leading devops technologies. – simbo1905 Jan 24 '18 at 09:07

0 Answers0