cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Dejanovski <>
Subject Re: execute is faster than execute_async?
Date Wed, 11 Dec 2019 12:44:25 GMT

you can check this piece of documentation from Datastax:

The usual way of doing this is to send a bunch of execute_async() calls,
adding the returned futures in a list. Once the list reaches the chosen
threshold (usually we send around 100 queries and wait for them to finish
before moving on the the next ones), loop through the futures and call the
result() method to block until it completes.
Should look like this:

futures = []
for i in range(len(queries)):
    if len(futures) >= 100 or i == len(queries)-1:
        for future in futures:
            results = future.result() # will block until the query finishes
        futures = []  # empty the list

Haven't tested the code above but it should give you an idea on how this
can be implemented.
Sending hundreds/thousands of queries without waiting for a result will
DDoS the cluster, so you should always implement some throttling.


Alexander Dejanovski

Apache Cassandra Consulting

On Wed, Dec 11, 2019 at 10:42 AM Jordan West <> wrote:

> I’m not very familiar with the python client unfortunately. If it helps:
> In Java, async would return futures and at the end of submitting each batch
> you would block on them by calling get.
> Jordan
> On Wed, Dec 11, 2019 at 1:37 AM lampahome <> wrote:
>> Jordan West <> 於 2019年12月11日 週三 下午4:34寫道:
>>> Hi,
>>> Have you tried batching calls to execute_async with periodic blocking
>>> for the batch’s responses?
>> Can you give me some keywords about calling execute_async batch?
>> PS: I use python version.

View raw message