英文:
Share cache between microservices with Kubernetes and sping boot
问题
如何在Kubernetes中的复制微服务之间共享Spring缓存?
应该使用哪种技术?
解决方案应能支持高可用配置(例如:主/从;主动-主动灾难恢复等)。
如果可能,请同时提供Spring Boot配置。
英文:
How can I share the Spring cache between replicated microservices in kubernetes?
Which technology should I use?
The solution should be able to support an high available configuration (e.g.: master/slave; active-active DR and so on).
Please provide the spring boot configuration as well if possible.
答案1
得分: 3
Spring缓存具有缓存提供程序的概念 - 即在缓存实现背后支持缓存的技术。
默认情况下,缓存在内存中实现,因此不以任何方式复制。但是,您可以将其配置为与Redis一起运行,请参阅此教程以获取技术实现方面的详细信息。
在这种情况下,同一个Redis实例应该可以从运行应用程序Pod的所有Kubernetes节点访问,从而实现分布式缓存。
根据您的实际需求,您还可以查看与EHcache或Hazelcast的集成。我相信还存在其他选项,但这应该指引了方向。
英文:
Spring cache has a concept of cache providers - technologies standing behind the caching implementation.
By default the cache is implemented in-memory, so its not replicated in any manner. However you can configure it to run, say, with Redis. See this tutorial for technical implementation aspects
In this case the same redis instance should be accessible from all kubernetes nodes running the pod of your application and you will have distributed cache.
Depending on your actual needs you can also check the integration with EHcache or Hazelcast. I'm sure other options also exist but this should give a direction.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论