aerospike / aerospike-client-go

Aerospike Client Go
Apache License 2.0
429 stars 199 forks source link

Understanding client.BatchGet(...) design #357

Closed xqzhang2015 closed 2 years ago

xqzhang2015 commented 2 years ago

If there are multiple keys in a batch-get and the keys exist on different aerospike cluster nodes, client.BatchGet(...) will put the keys on the same node into a batch request and execute batch one by one or sequentially, instead of concurrently.

And if one of the batch request is timeout, the total BatchGet() is timeout err.

Is my understanding right?

If yes, why not do the batch requests concurrently?

https://github.com/aerospike/aerospike-client-go/blob/2a68420665951da79f541f4cdeba70ff38209ac3/batch_command.go#L70

khaf commented 2 years ago

@xqzhang2015 That's only for the retry logic, which only runs on a single go routine to prevent the exponential proliferation of goroutines. The original batch call runs in parallel. Look here for the code:

https://github.com/aerospike/aerospike-client-go/blob/v5/batch_executer.go

xqzhang2015 commented 2 years ago

@khaf that's really helpful.