Tomcat Web 应用程序之间共享缓存

发布于 2024-11-02 08:04:48 字数 554 浏览 0 评论 0原文

我正在寻找一种解决方案来在不同主机上运行的两个 tomcat Web 应用程序之间共享缓存。缓存用于数据同步,因此必须保证两个tomcat实例之间的缓存始终是最新的。 (抱歉,我不能 100% 确定此要求的正确术语是“一致性”还是更具体的术语,例如具有 ACID 属性)。当然,另一个要求是访问缓存的速度应该很快,写入次数与读取次数大致相同。我确实可以访问共享文件系统,因此这是一个考虑因素。

我研究过类似 ehcache 的东西,但为了在 web 应用程序之间获得共享缓存,我要么需要在 Terracotta 环境之上实现,要么使用新的 ehcache 缓存服务器。前者(Terracotta)似乎对此有些矫枉过正,而缓存网络服务器似乎无法提供我想要的快速性能。

我研究过的另一个解决方案是在 Redis 或 memcachedb 等快速键值存储之上构建一些简单的解决方案。 Redis 位于内存中,但可以轻松配置为集中式缓存,而 memcachedb 是基于磁盘的持久缓存,它可以工作,因为我有一个共享文件系统。

我正在寻找有关如何最好地解决此问题的建议。该解决方案需要是相对成熟的技术,因为它将在生产环境中使用。

提前致谢!

I'm looking for a solution to share a cache between two tomcat web apps running on different hosts. The cache is being used for data synchronization, so the cache must be guaranteed to be up-to-date at all times between the two tomcat instances. (Sorry, I'm not 100% sure if the correct terminology for this requirement is "consistency" or something more specific like having ACID property). Another requirement is of course is that it should be fast to access the cache, with about equal numbers of writes as reads. I do have access to a shared filesystem so that is a consideration.

I've looked at something like ehcache but in order to get a shared cache between the webapps I would either need to implement on top of a Terracotta environment or using the new ehcache cache server. The former (Terracotta) seems like overkill for this, while the cache web server seems like it wouldn't provide the fast performance that I want.

Another solution I've looked at is building something simple on top of a fast key-value store like Redis or memcachedb. Redis is in-memory but can easily be configured to be a centralized cache, while memcachedb is a disk-based persistent cache which could work because I have a shared filesystem.

I'm looking for suggestions on how to best solve this problem. The solution needs to be a relatively mature technology as it will be used in a production environment.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

记忆で 2024-11-09 08:04:48

我很确定如果您需要分布式缓存,您不需要 terracotta 或 ehcache 服务器。使用四种复制机制之一的 Ehcache 就可以了。

但是,根据您所写的内容,我猜您正在寻找的不仅仅是缓存。 Memcached/Ehcache 是您可以将其称为应用程序的缓存层的示例 - 仅此而已。

如果您发现自己使用“保证”“最新”“ACID”等词语,那么最好使用内存数据库,例如 Oracle Times Ten/MySQL Cluster/Redis 以及基于磁盘的持久存储。

I'm quite sure that you don't require terracotta or ehcache server if you need a distributed cache. Ehcache with one of the four replication mechanisms would do.

However, based on what you've written I guess that you're looking for more than just a cache. Memcached/Ehcache are examples of what you might call a caching layer for your application - nothing more.

If you find yourself using words like 'guaranteed' 'up-to-date' 'ACID' you're better off using an in-memory DB like Oracle Times Ten/MySQL Cluster/Redis with a disk-based persistent storage.

总以为 2024-11-09 08:04:48

您可以使用 memcached (不是 memcachedb)进行快速高效的缓存。 Redis 或 memcachedb 可能有点过分了,除非您想要持久缓存。 Memcached 可以非常轻松地进行集群,您可以使用 spymemcached java 客户端来访问它。 Memcacached 非常成熟,正在数十万甚至数百万台生产服务器中运行。生产时可以通过Nagios和Munin系统进行监控。

You can use memcached (not memcachedb) for fast and efficient caching. Redis or memcachedb could be an overkill unless you want persistent caching. Memcached can be clustered very easily and you can use spymemcached java client to access it. Memcacached is very mature and is running in several hundred thousands, if not millions of production servers. It can be monitored through Nagios and Munin systems when in production.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文