Home > other >  Spring boot rest endpoint result inconsistent because of in memory caching?
Spring boot rest endpoint result inconsistent because of in memory caching?

Time:01-08

I have Spring boot app deployed on 4 instances of ECS on AWS FARGATE. (I'm new to it.)

In my app, we have pure java in memory cache.

Assuming I put data using /putdata and get data using /getdata

When i hit /getdata, it sometimes returns results and sometime it doesn't.

  1. is there a possibility that my /putdata went to one of the 4 instances and only that In memory cache has that data, other 3 instance don't have it?

  2. OR my spring boot object states are managed to stay in sync on all 4 instances?

in summary, does rest requests land on different ECS container and may behave different if it lands on other ECS instance next time?

CodePudding user response:

to achieve this, you need a centralize cache server and point all your ECS instance/spring boot application to that cache server.

either you could go with AWS's managed cache server(ElsticCache) which is totally managed by AWS OR you need to spin some EC2 instance and install some distributed cache server in it. These are few you can give a try Hazelcast, Redis, Apache Ignite,etc

i would suggest go with AWS ElasticCache(Redis),so you don't have to manage anything. best of luck.

  •  Tags:  
  • Related