Kumar Kavish
Kumar Kavish

Reputation: 157

Async cassandra queries

I've been trying to update an app to enhance performance, it uses Datastax Cassandra Java Driver for DAL services.

Now, I need to convert sync queries to async queries, I didn't find satisfactory answers to my doubts (at least not on the web pages I visited).

Could anybody please answer the below queries or refer to a link where I could get an answer.

1> What are the possible problematic scenarios I need to worry about before changing synced executes to ansync execs?

2> How will reads and writes behave, can I change one of them without worrying about any issues?

Thanks in advance!

Upvotes: 2

Views: 1632

Answers (1)

Alex Ott
Alex Ott

Reputation: 87279

There are several things that you need to think about:

  • You need to rate limit your code - by default it's only 1024 request per connection, so you may need to increase this number. But even with increased number of request per connection it's easy to overload Cassandra, so you still need to control it, with something like this;
  • You need correctly handle errors - you may need to add error handler to promise that is returned, and react correspondingly;
  • You need correctly create statements - for example, don't reuse the same BoundStatement as it's not thread safe;
  • don't re-use same List/Set/Map instances that you pass as parameters, etc.

Upvotes: 2

Related Questions