如何使用 "Non Atomic" Batch/Pipeline 在 Scylla 中 运行 多个查询
How to run multiple queries in Scylla using "Non Atomic" Batch/Pipeline
我知道 Scylla 允许像这样的批处理语句。
BEGIN BATCH
<insert-stmt>/ <update-stmt>/ <delete-stmt>
APPLY BATCH
这些语句具有性能影响,因为它确保了原子性。但是,我只是想在单个 IO 中从 node
客户端执行许多插入语句。不需要这些插入之间的原子性。知道我该怎么做吗?找不到任何东西。
在 Cassandra 世界中批处理多个插入通常是一种反模式(除非它们进入一个分区,请参阅 docs). When you're sending inserts into multiple partitions in one batch, the coordinator node will need to take care for taking data from this batch and sending them to nodes that are owning the data. And this puts an additional load onto the coordinating node that first needs to backup the content of the batch just not to lose it if it crashes in the middle of execution, and then need to execute all operations, and wait for results of execution before sending it back to caller (see this diagram 以了解所谓的记录批处理的工作原理)。
当你不需要原子性时,最好的性能是发送多个并行插入,并等待它们的执行——它会更快,它会给节点带来更少的负载,驱动程序可以使用令牌-知道负载平衡策略,因此请求将被发送到拥有数据的节点(如果您使用 prepared statements). In node.js you can achieve this by using Concurrent Execution API - 它的用法有多种变体,所以最好查看文档 select 是什么最适合您的用例。
我知道 Scylla 允许像这样的批处理语句。
BEGIN BATCH
<insert-stmt>/ <update-stmt>/ <delete-stmt>
APPLY BATCH
这些语句具有性能影响,因为它确保了原子性。但是,我只是想在单个 IO 中从 node
客户端执行许多插入语句。不需要这些插入之间的原子性。知道我该怎么做吗?找不到任何东西。
在 Cassandra 世界中批处理多个插入通常是一种反模式(除非它们进入一个分区,请参阅 docs). When you're sending inserts into multiple partitions in one batch, the coordinator node will need to take care for taking data from this batch and sending them to nodes that are owning the data. And this puts an additional load onto the coordinating node that first needs to backup the content of the batch just not to lose it if it crashes in the middle of execution, and then need to execute all operations, and wait for results of execution before sending it back to caller (see this diagram 以了解所谓的记录批处理的工作原理)。
当你不需要原子性时,最好的性能是发送多个并行插入,并等待它们的执行——它会更快,它会给节点带来更少的负载,驱动程序可以使用令牌-知道负载平衡策略,因此请求将被发送到拥有数据的节点(如果您使用 prepared statements). In node.js you can achieve this by using Concurrent Execution API - 它的用法有多种变体,所以最好查看文档 select 是什么最适合您的用例。