gpt4 book ai didi

redis - 如果我的脚本运行时Elasticache决定重新分片怎么办?

转载 作者:行者123 更新时间:2023-12-03 06:42:44 24 4
gpt4 key购买 nike

我有一些触及少数几个按键的脚本。如果我的脚本运行时Elasticache决定重新分片怎么办?在移动基础键之前,它会等待脚本完成吗?还是我应该假设情况并非如此,并在设计这种边缘情况时设计我的应用程序?

一个示例是一个脚本,它可以一次增加2个键。我可能会收到“集群错误”,这意味着出了点问题,我不得不再次执行我的脚本(并可能最终将一个键增加两次,而另一个键增加一次)

最佳答案

假设您在谈论Lua脚本,只要您在参数中传递键(而不是在脚本中进行硬编码),就应该很好。这将是全有或全无。如果您不使用Lua脚本-请考虑这样做

EVAL command:

All Redis commands must be analyzed before execution to determine which keys the command will operate on. In order for this to be true for EVAL, keys must be passed explicitly. This is useful in many ways, but especially to make sure Redis Cluster can forward your request to the appropriate cluster node.



AWS ElastiCache - Best Practices: Online Cluster Resizing:

During resharding, we recommend the following:

  • Avoid expensive commands – Avoid running any computationally and I/O intensive operations, such as the KEYS and SMEMBERS commands. We suggest this approach because these operations increase the load on the cluster and have an impact on the performance of the cluster. Instead, use the SCAN and SSCAN commands.

  • Follow Lua best practices – Avoid long running Lua scripts, and always declare keys used in Lua scripts up front. We recommend this approach to determine that the Lua script is not using cross slot commands. Ensure that the keys used in Lua scripts belong to the same slot.

关于redis - 如果我的脚本运行时Elasticache决定重新分片怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59674459/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com