This example shows how execute multiple concurrent requests asynchronously with Apache Cassandra™ using the Node.js DataStax Driver.
Contributor(s): Jorge Bay Gondra - derived from here
- How to limit async concurrent requests using the Node.js DataStax Driver
- execute-concurrent-builtin-way.js: Inserts multiple rows in a table from an Array using the driver's built-in method
executeConcurrent() - execute-concurrent-promise-way.js: Inserts multiple rows in a table from an Array using Promises
The Node.js programs write rows to the database asynchronously while limiting the amount of concurrent requests in flight.
Make sure Cassandra Node.js Driver is installed
npm install cassandra-driver
- execute-concurrent-builtin-way.js
node execute-concurrent-builtin-way.js <database-ip> <datacenter-name> <concurrency-level>
- execute-concurrent-promise-way.js
node execute-concurrent-promise-way.js <database-ip> <datacenter-name> <concurrency-level>