【发布时间】:2013-05-06 07:08:28
【问题描述】:
我们正在使用Cassandra database in production environment。我们有一个single cross colo cluster of 24 nodes,意思是12 nodes in PHX 和12 nodes in SLC colo。我们有一个replication factor of 4,这意味着2 copies will be there in each datacenter。
以下是我们的Production DBA's 创建keyspace 和column families 的方式。
使用placement_strategy = 创建键空间配置文件 'org.apache.cassandra.locator.NetworkTopologyStrategy' 和 strategy_options = {slc:2,phx:2};
create column family PROFILE_USER with key_validation_class = 'UTF8Type' and comparator = 'UTF8Type' and default_validation_class = 'UTF8Type' and gc_grace = 86400;
我们正在运行Cassandra 1.2.2,它有org.apache.cassandra.dht.Murmur3Partitioner,同时启用了KeyCaching、SizeTieredCompactionStrategy 和Virtual Nodes。 Cassandra 节点部署在HDD instead ofSSD 上。
我正在使用Astyanax client 使用consistency level as ONE 从Cassandra database 读取数据。我使用Astyanax client在生产集群中插入了50 Millions records(24个节点总共大约285GB的数据),压缩完成后,我开始做read against the Cassandra production database。
下面是我使用Astyanax client创建连接配置的代码-
/**
* Creating Cassandra connection using Astyanax client
*
*/
private CassandraAstyanaxConnection() {
context = new AstyanaxContext.Builder()
.forCluster(ModelConstants.CLUSTER)
.forKeyspace(ModelConstants.KEYSPACE)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
.setPort(9160)
.setMaxConnsPerHost(100)
.setSeeds("cdb03.vip.phx.host.com:9160,cdb04.vip.phx.host.com:9160")
.setLocalDatacenter("phx") //filtering out the nodes basis on data center
)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setCqlVersion("3.0.0")
.setTargetCassandraVersion("1.2")
.setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN)
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
keyspace = context.getEntity();
emp_cf = ColumnFamily.newColumnFamily(
ModelConstants.COLUMN_FAMILY,
StringSerializer.get(),
StringSerializer.get());
}
大多数时候,我在8/9/10 ms 附近得到95th percentile read performance。
我想看看有什么方法可以让read performance 和Cassandra database 变得更好。 我的印象是我将在1 or 2 ms 获得第 95 个百分位,但之后在生产集群上做一些测试,我的所有假设都错了。我正在运行我的客户端程序的 Cassandra 生产节点的 Ping 时间是 0.3ms average。
下面是我得到的结果。
Read Latency(95th Percentile) Number of Threads Duration the program was running(in minutes) Throughput(requests/seconds) Total number of id's requested Total number of columns requested
8 milliseconds 10 30 1584 2851481 52764072
谁能说明我可以尝试哪些其他方法来实现良好的读取延迟性能?我知道在我同样的情况下可能会有类似的人在生产中使用 Cassandra。任何帮助将不胜感激。
感谢您的帮助。
【问题讨论】:
标签: java nosql cassandra astyanax netflix