Cassandra Java驱动程序500毫秒内从冷到热?

Cassandra Java驱动程序500毫秒内从冷到热?,java,cassandra,Java,Cassandra,我经历了从冷到热(首次使用)的集群和到本地数据源(Cassandra)的会话,需要640ms。任何额外的连接都需要80到100毫秒,所以第一次连接的开销大约是500毫秒以上。这正常吗?我能做些什么来降低这个数字吗?我使用T410(i5 2.5GHz) [更新] 23:27:11.453 [main] DEBUG c.d.driver.core.SystemProperties - com.datastax.driver.NEW_NODE_DELAY_SECONDS is undefined, u

我经历了从冷到热(首次使用)的集群和到本地数据源(Cassandra)的会话,需要640ms。任何额外的连接都需要80到100毫秒,所以第一次连接的开销大约是500毫秒以上。这正常吗?我能做些什么来降低这个数字吗?我使用T410(i5 2.5GHz)

[更新]

23:27:11.453 [main] DEBUG c.d.driver.core.SystemProperties - com.datastax.driver.NEW_NODE_DELAY_SECONDS is undefined, using default value 1
23:27:11.460 [main] DEBUG c.d.driver.core.SystemProperties - com.datastax.driver.NON_BLOCKING_EXECUTOR_SIZE is undefined, using default value 4
23:27:11.463 [main] DEBUG c.d.driver.core.SystemProperties - com.datastax.driver.NOTIF_LOCK_TIMEOUT_SECONDS is undefined, using default value 60
23:27:11.607 [main] DEBUG com.datastax.driver.core.Cluster - Starting new cluster with contact points [localhost/127.0.0.1:9042]
23:27:11.905 [main] DEBUG com.datastax.driver.core.Connection - Connection[localhost/127.0.0.1:9042-1, inFlight=0, closed=false] Transport initialized and ready
23:27:11.906 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Refreshing node list and token map
23:27:11.969 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Refreshing schema
23:27:12.016 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Refreshing node list and token map
23:27:12.051 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Successfully connected to localhost/127.0.0.1:9042
23:27:12.052 [main] INFO  c.d.d.c.p.DCAwareRoundRobinPolicy - Using data-center name 'datacenter1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)
23:27:12.053 [main] INFO  com.datastax.driver.core.Cluster - New Cassandra host localhost/127.0.0.1:9042 added
23:27:12.076 [Cassandra Java Driver worker-0] DEBUG com.datastax.driver.core.Connection - Connection[localhost/127.0.0.1:9042-2, inFlight=0, closed=false] Transport initialized and ready
23:27:12.077 [Cassandra Java Driver worker-0] DEBUG com.datastax.driver.core.Session - Added connection pool for localhost/127.0.0.1:9042
23:27:12.097 [main] DEBUG com.datastax.driver.core.Connection - Connection[localhost/127.0.0.1:9042-2, inFlight=0, closed=true] closing connection
23:27:12.103 [main] DEBUG com.datastax.driver.core.Cluster - Shutting down
23:27:12.105 [main] DEBUG com.datastax.driver.core.Connection - Connection[localhost/127.0.0.1:9042-1, inFlight=0, closed=true] closing connection
23:27:12.123 [main] DEBUG com.datastax.driver.core.Cluster - Starting new cluster with contact points [/127.0.0.1:9042]
23:27:12.132 [main] DEBUG com.datastax.driver.core.Connection - Connection[/127.0.0.1:9042-1, inFlight=0, closed=false] Transport initialized and ready
23:27:12.132 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Refreshing node list and token map
23:27:12.138 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Refreshing schema
23:27:12.168 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Refreshing node list and token map
23:27:12.192 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Successfully connected to /127.0.0.1:9042
23:27:12.192 [main] INFO  c.d.d.c.p.DCAwareRoundRobinPolicy - Using data-center name 'datacenter1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)
23:27:12.192 [main] INFO  com.datastax.driver.core.Cluster - New Cassandra host /127.0.0.1:9042 added
23:27:12.201 [Cassandra Java Driver worker-0] DEBUG com.datastax.driver.core.Connection - Connection[/127.0.0.1:9042-2, inFlight=0, closed=false] Transport initialized and ready
23:27:12.202 [Cassandra Java Driver worker-0] DEBUG com.datastax.driver.core.Session - Added connection pool for /127.0.0.1:9042

正如人们可以看到的,第一次连接尝试使用高达600ms的数据,这取决于人们如何读取这些数据。

我猜这与连接初始化有关。在所有当前发布的java驱动程序版本中,一个接一个地同步初始化连接。幸运的是,单个主机池是并行初始化的,但连接不是。如果您使用的是2.0.9,它的默认核心连接数为8,这可以解释为什么您会发现初始化时间很慢。另外,如果您使用的是密码身份验证,那么速度也会降低很多(从每次连接~0-10ms降低到~60-120ms)


在即将发布的java驱动程序2.0.10中,所有连接都是并行初始化的,这大大改进了会话初始化。有关信息,请参阅。

我使用java驱动程序2.1.5和Cassandra 2.1.4。有什么设置我可以调整吗?人力资源管理,可能是你可以做的。您要连接到多少个cassandra节点?您正在使用身份验证吗?你有多少个CPU核?(核心影响初始化连接的线程池大小)无压缩无加密无身份验证。这是一个用于测试目的的本地实例,每次运行某些测试时等待600ms是我希望减少的,因为测试至少每两分钟运行一次。您能提高com.datastax.driver.core的日志记录级别以进行调试吗?这可能会让我们更清楚地知道为什么要花这么长时间。我添加了日志条目。Cassandra实例已经预热,因此时间安排实际上与故事的客户端有关。