使用一致性缓存的开销
我考虑缓存存储在数据库中的键值列表。现在,为了呈现 JSF 页面,需要执行大量冗余查询来查找某些键要显示的名称(O/R-Mapper:Eclipselink)。 这些值是准静态的,但很少可以通过使用应用程序进行更改(除了相关应用程序之外,数据库中不会发生任何更改)。
当仅使用一台应用程序服务器时,一个简单的缓存就足够了。但是,应该可以实现多台服务器的负载平衡,从而避免在使用一台服务器更改数据并因此未被另一台服务器反映时返回过时的值。
一种想法是使用 Oracle Coherence 作为分布式缓存。我不确定这是否太过分了,因为数据很少更改,并且缓存本身不需要分布,只有失效应该分布。
内存、执行时间和网络通信方面的一致性开销是多少?有没有更适合我的用例的替代方案?
我谈论了 50.000 个键值对,主要是短字符串。
I consider caching key-value lists stored in database. Right now for rendering of JSF pages, a lot of redundant queries are executed to find the names to be displayed for some keys (O/R-Mapper: Eclipselink).
The values are quasi-static, but can change very seldom by using the application (no change in database except by the application in question).
A simple cache would suffice when only using one application server. However, load balancing with multiple servers should be possible, avoiding returning stale values if data is changed using one server and therefore not reflected by the other server.
One idea would be to use oracle coherence as distributed cache. I'm not sure whether this is overkill because of the fact that the data is only changed very seldomly and the cache itself does not need to be distributed, only the invalidation should be.
What is the overhead of coherence in terms of memory, execution times and network communication? Are there any alternatives that better suit my use case?
I talk about 50.000 key value pairs, mainly short strings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果失效非常罕见,那么您可以使用本地缓存和每个人都订阅的 JMS 主题之类的东西来处理失效。
还有像 EHCache 这样的东西作为替代方案,因为它是 OSS 并且可以免费使用,而不是 Coherence(如果这很重要的话)。我喜欢使用EHCaches的拉通能力。
If the invalidation is that rare, then you can use a local cache and something like a JMS Topic that everyone subscribes to in order to handle the invalidation.
There's also something like EHCache as an alternative, since it's OSS and free to use vs Coherence, if that's important. I like to use EHCaches pull through ability.
Coherence 的开销相对较低,可以轻松管理 50,000(或 50,000,000)个对象。但是,如果您的用例非常简单,并且您不介意自己进行失效工作,并且不需要 Coherence 提供的各种 QoS,那么它可能就有点矫枉过正了。
此外,这个简单的用例可以使用 Coherence 标准版轻松完成,它的价格要便宜得多(按服务器而不是按处理器进行许可,而且价格要低得多)。
为了充分披露,我在 Oracle 工作。这篇文章中表达的意见和观点是我自己的,并不一定反映我雇主的意见或看法。
Coherence has relatively low overhead, and can easily manage 50,000 (or 50,000,000) objects. However, if your use case is super simple, and you don't mind doing the invalidation work yourself, and don't need the various QoS that Coherence provides, then it probably is overkill.
Also, this simple use case can easily be done using the Coherence Standard Edition, which is far less expensive (licensed per server instead of per processor, and it's a much lower price).
For the sake of full disclosure, I work at Oracle. The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.