lua-resty-cassandra icon indicating copy to clipboard operation
lua-resty-cassandra copied to clipboard

Support Token Aware Routing

Open lordnynex opened this issue 10 years ago • 3 comments

I'm currently experiencing a serious performance issue with the coordinator node becoming unresponsive due to a huge influx of WHERE IN() queries.

My current approach is to break the WHERE IN query into multiple selects, however, I'd be able to

  • Direct the queries at the appropriate node
  • Leverage WHERE IN as long as it was directed at the appropriate node.

As an additional question, do you have any strategies for dealing with async queries within openresty? It seems like there is a pretty serious performance cliff without the ability to fire multiple async queries.

lordnynex avatar Apr 24 '15 22:04 lordnynex

Unfortunately there is no way to specify a load balancing policy (issue #21). I think this is the main drawback of this driver.

Regarding async queries, the driver uses the openresty's cosocket api, so the calls do not block nginx, although they are synchronous. Async queries would be an advantage if you want to fire multiple queries in parallel for a single request. There is another open issue for supporting that: #3.

It would be nice if the driver could automatically split one WHERE IN query into multiple selects (one query for each node), but I would go for that only if there is an available implementation of this feature in one of datastax's official drivers. Do you know if any other driver does that?

jbochi avatar Apr 25 '15 13:04 jbochi

What about doing something like Batch where the select queries are done within coroutine.wrap? At this point I think there may be some socket problems but I think it may be possible? Also, I know there is a patch coming to use cosockets across lightthreads but I don't know when it will be merged.

lordnynex avatar Apr 25 '15 20:04 lordnynex

Running queries inside coroutines would not help because the driver reads the query results synchronously. Nginx is not blocked because of cosocket api's magic. The easiest solution is to fix issue #3, allowing several queries / streams on the same connection. If you are doing a single query for each request, you don't need to worry about that.

jbochi avatar Apr 26 '15 19:04 jbochi