Java 对象缓存,从文件读取还是从远程机器读取哪个更快?
我现在需要决定当对象缓存达到配置的阈值时要做什么。
我应该将对象存储在索引文件中(如 JCS 提供的)并在需要时从文件(文件 IO)中读取它们,还是将对象存储在分布式缓存中(网络、序列化、反序列化)
我们使用 Solaris 作为操作系统。
============================
添加更多信息。
我有这个问题是为了确定是否可以切换到分布式缓存。 具有缓存的远程服务器将拥有更多的内存和更好的磁盘,并且该远程服务器将仅用于缓存。
我们无法增加本地缓存对象的问题之一是,它将缓存对象存储在内存有限的JVM堆中(使用32位JVM)。
=================================================== ======================
谢谢,我们最终选择了 Coherence 作为我们的缓存产品。 这提供了许多缓存配置拓扑,进程中、远程、磁盘等。
I am at a point where I need to take the decision on what to do when caching of objects reaches the configured threshold.
Should I store the objects in a indexed file (like provided by JCS) and read them from the file (file IO) when required or have the object stored in a distributed cache (network, serialization, deserialization)
We are using Solaris as OS.
============================
Adding some more information.
I have this question so as to determine if I can switch to distributed caching. The remote server which will have cache will have more memory and better disk and this remote server will only be used for caching.
One of the problems we cannot increase the locally cached objects is , it stores the cached objects in JVM heap which has limited memory(using 32bit JVM).
========================================================================
Thanks, we finally ended up choosing Coherence as our Cache product. This provides many cache configuration topologies, in process vs remote vs disk ..etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
它取决于许多因素,例如磁盘速度、网络延迟和数据量,因此一些实验可能是获得想法的最佳方法。 我建议你看看http://ehcache.org/,它可能会派上用场。
It's going to depend on many things such as disk speed, network latency and the amount of data, so some experimentation might be the best way to get an idea. I recommend you have a look at http://ehcache.org/, it might come in handy.
真正了解的唯一方法是测试它,但是如果缓存具有良好的网络延迟,它很可能比本地磁盘访问更快。
一旦处理足够大速率的缓存请求,对本地磁盘的序列化随机访问可能会成为问题。
The only way to really know is to test it, but with good network latency from your cache, it could well be faster than local disk access.
Once you are dealing with a large enough rate of cache requests, serialised random access to the local disk is likely to become a problem.
您是否期望分布式节点将您的数据保存在内存中? 我不会。
如果您不能确定分布式节点是否会将数据保存在内存中,那么在网络上保存数据将花费时间从磁盘读取数据,并通过网络发送数据。 将数据保存在本地只会花费从磁盘读取数据的时间。
本地速度更快。
Do you expect that the distributed nodes will keep your data in memory? I wouldn't.
If you can't be sure that the distributed nodes will keep your data in memory, then holding data on the network will take the time to read data from the disk, plus send the data over the network. Holding data locally will only take the time to read data from the disk.
Local is faster.
几乎可以肯定,您可以更快地将数据缓存在文件中,而不是通过网络缓存。
You're almost certainly guaranteed to be faster cacheing the data in a file as opposed to across the network.
这些选项并不相互排斥,有些产品将两者结合起来。 例如,Oracle Coherence 可以提供复杂的分布式缓存服务,并提供在超过阈值时溢出到磁盘的选项。
The options are not mutually exclusive, there are products out there that combine both. Oracle Coherence for example can provide sophisticated distributed cache services with an option to overflow to disk when thresholds are exceeded.
查看 memcached,一种分布式内存缓存。 您需要针对自己的特定用途进行性能比较,但分布式内存缓存通常优于本地磁盘缓存。
Check out memcached, a distributed in-memory cache. You'll need to run performance comparisons for your own particular usages, but a distributed memory cache can often outperform a local disk cache.
我不明白这个问题。 您是否需要分布式缓存? 只需回答这个问题即可了解您需要什么。
I don't get the question. Do you need a distributed cache, or not? Just answer this question to find out what you need.