在 Magento 中对会话和后端缓存使用单个 Redis 实例是个坏主意吗?
Is it a bad idea to use a single Redis instance for both session and backend caching in Magento?
对于 Magento(v1.9 或更低版本),可以将单个 Redis 实例用于会话和后端缓存吗?是否需要任何额外配置?
您可以使用单个实例,但您仍然需要为每个实例使用单独的数据存储,例如6379 和 6380 但在同一个 Redis 服务器上。
从 Magento 端拥有单独的实例不需要额外的配置。
经过进一步研究,似乎很容易为会话和后端缓存使用相同的实例,唯一的潜在问题是 space 中的 运行(如果您在 AWS 上使用 ElastiCache)。
也不需要不同的端口号。您只需要指定不同的 "database numbers"。以下是配置示例:
<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>$REDIS_CACHE</server>
<port>6379</port>
<persistent></persistent>
<database>1</database> <!-- DIFFERENT DB NUMBER -->
<password></password>
<force_standalone>0</force_standalone>
<connect_retries>1</connect_retries>
<read_timeout>10</read_timeout>
<automatic_cleaning_factor>0</automatic_cleaning_factor>
<compress_data>1</compress_data>
<compress_tags>1</compress_tags>
<compress_threshold>20480</compress_threshold>
<compression_lib>gzip</compression_lib>
<use_lua>0</use_lua>
</backend_options>
</cache>
<session_save>db</session_save>
<redis_session>
<host>$REDIS_CACHE</host>
<port>6379</port>
<password></password>
<timeout>2.5</timeout>
<persistent></persistent>
<db>2</db> <!-- DIFFERENT DB NUMBER -->
<compression_threshold>2048</compression_threshold>
<compression_lib>gzip</compression_lib>
<log_level>1</log_level>
<max_concurrency>6</max_concurrency>
<break_after_frontend>5</break_after_frontend>
<fail_after>10</fail_after>
<break_after_adminhtml>30</break_after_adminhtml>
<first_lifetime>600</first_lifetime>
<bot_first_lifetime>60</bot_first_lifetime>
<bot_lifetime>7200</bot_lifetime>
<disable_locking>0</disable_locking>
<min_lifetime>60</min_lifetime>
<max_lifetime>2592000</max_lifetime>
</redis_session>
我会推荐单独的实例。
与具有相同数据库甚至不同数据库的单个实例相比的优势
Space 和配置控制 :您不想注销用户,因为您的缓存占用了过多的 redis space .存储一些页面缓存的 Redis 对象可能会导致会话数据键被逐出,这不好。
Key name spacing control :您的密钥将根据关注点分开,您可以使用刷新之类的东西来清除所有缓存,或者在某些重大更改时注销您的用户。而不是必须按模式删除键。
对于 Magento(v1.9 或更低版本),可以将单个 Redis 实例用于会话和后端缓存吗?是否需要任何额外配置?
您可以使用单个实例,但您仍然需要为每个实例使用单独的数据存储,例如6379 和 6380 但在同一个 Redis 服务器上。
从 Magento 端拥有单独的实例不需要额外的配置。
经过进一步研究,似乎很容易为会话和后端缓存使用相同的实例,唯一的潜在问题是 space 中的 运行(如果您在 AWS 上使用 ElastiCache)。
也不需要不同的端口号。您只需要指定不同的 "database numbers"。以下是配置示例:
<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>$REDIS_CACHE</server>
<port>6379</port>
<persistent></persistent>
<database>1</database> <!-- DIFFERENT DB NUMBER -->
<password></password>
<force_standalone>0</force_standalone>
<connect_retries>1</connect_retries>
<read_timeout>10</read_timeout>
<automatic_cleaning_factor>0</automatic_cleaning_factor>
<compress_data>1</compress_data>
<compress_tags>1</compress_tags>
<compress_threshold>20480</compress_threshold>
<compression_lib>gzip</compression_lib>
<use_lua>0</use_lua>
</backend_options>
</cache>
<session_save>db</session_save>
<redis_session>
<host>$REDIS_CACHE</host>
<port>6379</port>
<password></password>
<timeout>2.5</timeout>
<persistent></persistent>
<db>2</db> <!-- DIFFERENT DB NUMBER -->
<compression_threshold>2048</compression_threshold>
<compression_lib>gzip</compression_lib>
<log_level>1</log_level>
<max_concurrency>6</max_concurrency>
<break_after_frontend>5</break_after_frontend>
<fail_after>10</fail_after>
<break_after_adminhtml>30</break_after_adminhtml>
<first_lifetime>600</first_lifetime>
<bot_first_lifetime>60</bot_first_lifetime>
<bot_lifetime>7200</bot_lifetime>
<disable_locking>0</disable_locking>
<min_lifetime>60</min_lifetime>
<max_lifetime>2592000</max_lifetime>
</redis_session>
我会推荐单独的实例。 与具有相同数据库甚至不同数据库的单个实例相比的优势
Space 和配置控制 :您不想注销用户,因为您的缓存占用了过多的 redis space .存储一些页面缓存的 Redis 对象可能会导致会话数据键被逐出,这不好。
Key name spacing control :您的密钥将根据关注点分开,您可以使用刷新之类的东西来清除所有缓存,或者在某些重大更改时注销您的用户。而不是必须按模式删除键。