Best Practices for Using Aerospike C Client with a Separate UV Loop

Hello Aerospike community,

We have been using Aerospike in conjunction with our server’s main uv_loop for several years without issues. However, we are now exploring the option of assigning Aerospike its own thread and loop to reduce the load on our main loop. While attempting this, we encountered several challenges.

Initially, we tried using as_event_create_loops, and it seemed to work fine locally. However, when we deployed it to our development environment, we experienced significant issues. The loop appeared to become busy, consuming an entire CPU core, which effectively busted our online environment.

The documentation for as_event_create_loops mentions:

This method should only be called when async client commands will be used, and the calling program itself is not async.

We are trying to understand if this implies that our server, which is based on uv_loop, cannot use this method to create a separate loop for Aerospike. We also tried managing a separate thread and running a separate uv_loop ourselves with as_event_set_external_loop, but this led to issues with dangling objects and other hard-to-resolve problems.

Could anyone advise on the best practices for assigning Aerospike its own event loop, while allowing our main loop to focus on other tasks without overwhelming the CPU? We would greatly appreciate any guidance.

Thank you for your help!

Please provide your server and client versions. It will help whoever is able to provide some guidance on this issue.

Sure, the aerospike-client-c_version is “6.5.2” And the server version is: Aerospike Enterprise Edition (ver. 6.4.0.21)

This question was also asked in github: Best Practices for Using Aerospike C Client with a Separate UV Loop · Issue #155 · aerospike/aerospike-client-c · GitHub

I have answered there.