You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/11/22 02:09:19 UTC

[shardingsphere] branch master updated: Add documents for sharding cache (#22317)

This is an automated email from the ASF dual-hosted git repository.

sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 25e078ad726 Add documents for sharding cache (#22317)
25e078ad726 is described below

commit 25e078ad726570c45e9745c6cc197272f804cf73
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Tue Nov 22 10:09:11 2022 +0800

    Add documents for sharding cache (#22317)
---
 .../yaml-config/rules/sharding-cache.cn.md         | 33 ++++++++++++++++++++++
 .../yaml-config/rules/sharding-cache.en.md         | 33 ++++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding-cache.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding-cache.cn.md
new file mode 100644
index 00000000000..34c61620283
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding-cache.cn.md
@@ -0,0 +1,33 @@
++++
+title = "数据分片路由缓存"
+weight = 10
++++
+
+## 背景信息
+
+该项功能为**实验性功能**,需要与数据分片功能同时使用。
+数据分片路由缓存会将逻辑 SQL、分片键实际参数值、路由结果放入缓存中,以空间换时间,减少路由逻辑对 CPU 的使用。
+
+建议仅在满足以下条件的情况下启用:
+- 纯 OLTP 场景
+- ShardingSphere 进程所在机器 CPU 已达到瓶颈
+- CPU 开销主要在于 ShardingSphere 路由逻辑
+- 所有 SQL 已经最优且每次 SQL 执行都能命中单一分片
+
+在不满足以上条件的情况下使用,可能对 SQL 的执行延时不会有明显改善,同时会增加内存的压力。
+
+## 参数解释
+
+```yaml
+rules:
+  - !SHARDING_CACHE
+    allowedMaxSqlLength: 512 # 允许缓存的 SQL 长度限制
+    routeCache:
+      initialCapacity: 65536 # 缓存初始容量
+      maximumSize: 262144 # 缓存最大容量
+      softValues: true # 是否软引用缓存值
+```
+
+## 相关参考
+
+- [核心特性:数据分片](/cn/features/sharding/)
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding-cache.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding-cache.en.md
new file mode 100644
index 00000000000..32e99faaa7b
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding-cache.en.md
@@ -0,0 +1,33 @@
++++
+title = "Cache for Sharding Route"
+weight = 10
++++
+
+## Background
+
+This feature is **experimental** and needs to be used with data sharding rule.
+The cache for sharding route will put the logical SQL, the actual parameter value of the shard key, and the routing result into the cache, exchange space for time, and reduce the CPU usage of routing logic.
+
+It is recommended to enable only if the following conditions are met:
+- Pure OLTP scenarios
+- The CPU of the machine which deployed the ShardingSphere process has reached the bottleneck
+- Most of the CPUs are used by ShardingSphere routing logic
+- All SQLs are optimized and each SQL execution could be routed to a single data node
+
+If the above conditions are not met, the execution delay of SQL may not be significantly improved, and the memory pressure will be increased.
+
+## Parameters
+
+```yaml
+rules:
+  - !SHARDING_CACHE
+    allowedMaxSqlLength: 512 # Allow cached SQL length limit
+    routeCache:
+      initialCapacity: 65536 # Initial capacity
+      maximumSize: 262144 # Maximum capacity
+      softValues: true # Whether to use soft references
+```
+
+## Related References
+
+- [Core Feature: Data Sharding](/en/features/sharding/)