3

什么是在web 服务器应用程序服务器之间应用缓存层的好工具。

基本要求:

  1. 应用程序服务器需要一种方法来从缓存中删除项目并将项目放入缓存中并具有到期日期。
  2. Web 服务器需要一种以非常轻量级、快速的方式从缓存中提取项目的方法,而无需在应用程序服务器上分配线程。
  3. 它不一定需要是分布式缓存(可从多台机器访问),但它不会受到伤害。

我考虑过的策略:

  1. 静态文件缓存。请求进来,被散列,如果文件存在我们提供它,如果不存在,我们将请求路由到应用服务器。高 I/O 是并发问题还是文件锁定问题?由于内存中的内核级缓存,文件系统实际上非常快,这是否准确。
  2. 使用像 mongodb 或 redis 这样的键值数据库。这会将完成的 HTML/JSON 片段存储在 db 中。如果需要,网络服务器将能够从数据库中读取数据并路由到应用服务器。应用服务器将配备从数据库中插入/删除。
  3. 像 memcached 或 Varnish 这样的内存缓存(对 Varnish 不太了解)。我对 memcached 的唯一担心是,我要在任何给定时间缓存 3 到 10 GB 的数据,这超出了我在内存中安全分配的能力。memcached 是否有溢出到文件系统的方法?

在尝试这种类型的缓存层时,对一些技术和陷阱有什么想法吗?

4

2 回答 2

3

您还可以在内存数据网格中使用 GigaSpaces XAP 来缓存甚至托管您的 Web 应用程序。您可以只选择缓存选项,也可以将两者结合起来,并通过其他方式对您的环境进行单一管理。

与您建议的键值对方法不同,使用 GigaSpaces XAP 您将能够进行复杂的查询,例如 SQL、基于对象的寺庙等等。在您的缓存方案中,您应该更具体地检查与本地缓存相关的功能。

本地缓存

网络容器

免责声明,我是 GigaSpaces 的开发人员。

艾坦

于 2012-11-11T09:12:36.143 回答
0

Just to answer this from the POV of using Coherence (http://coherence.oracle.com/):

1. The application server needs a way to remove items from the cache and put items in the cache with an expiration date.

// remove one item from cache
cache.remove(key);

// remove multiple items from cache
cache.keySet().removeAll(keylist);

2. The webserver needs a way to pull items out of the cache in a very light-weight, fast manner without requiring thread allocation on the application server.

// access one item from cache
Object value = cache.get(key);

// access multiple items from cache
Map mapKV = cache.getAll(keylist);

3. It does not neccessarily need to be a distributed cache (accessible from multiple machines), but it wouldn't hurt.

  • Elastic. Just add nodes. Auto-discovery. Auto-load-balancing. No data loss. No interruption. Every time you add a node, you get more data capacity and more throughput.
  • Automatic high availability (HA). Kill a process, no data loss. Kill a server, no data loss.

A memory cache like memcached or Varnish (don't know much about Varnish). My only concern with memcached is that I'm going to want to cache 3 - 10 gigabytes of data at any given time, which is more than I can safely allocate in memory. Does memcached have a method to spill to the filesystem?

  • Use both RAM and flash. Transparently. Easily handle 10s or even 100s of gigabytes per Coherence node (e.g. up to a TB or more per physical server).

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.

于 2013-08-13T04:09:12.807 回答