scylladb / java-driver

ScyllaDB Java Driver for ScyllaDB and Apache Cassandra, based on the DataStax Java Driver
Apache License 2.0
61 stars 37 forks source link

Optimize NettyChannel usage #345

Open dkropachev opened 1 week ago

dkropachev commented 1 week ago

From https://scylladb-users.slack.com/archives/C2NLNBXLN/p1725297082189579?thread_ts=1725284973.161149&cid=C2NLNBXLN

It seems I found the reason. Scylla driver will create connection per shard. It means if you have 3 nodes with 8 CPU it will create 24 connections https://github.com/scylladb/java-driver/blob/scylla-4.x/core/src/main/java/com/datastax/oss/driver/internal/core/pool/ChannelPool.java#L489 The problem here that's scylla driver creating DriverChannels that's are backed to the NettyChannel and every NettyChannel actually a selector loop. So you'll have 24 while true loops that are constantly working if you always writing data to the scylla.

  1. It leads to very poor client performance, since you have dedicated Selector loop only for one TCP socket. For example, 150k rps using cassandra driver consumes 1 CPU on client side, but using scylla driver consumes 6 CPU.
  2. It's better to specify that "advanced.connection.pool.local.size" configuration behaves different