2012-01-04 131 views
1

我正在單個節點Cassandra設置上工作。我正在使用的系統具有8GB RAM的4核CPU。 這我使用的柱族的特性是:我該如何提高Cassandra的讀/寫性能?

Keyspace: keyspace1: 
    Replication Strategy: org.apache.cassandra.locator.NetworkTopologyStrategy 
    Durable Writes: true 
    Options: [datacenter1:1] 
    Column Families: 
    ColumnFamily: colfamily (Super) 
     Key Validation Class: org.apache.cassandra.db.marshal.UTF8Type 
     Default column value validator: org.apache.cassandra.db.marshal.UTF8Type 
     Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type/org.apache.cassandra.db.marshal.BytesType 
     Row cache size/save period in seconds/keys to save : 100000.0/0/all 
     Row Cache Provider: org.apache.cassandra.cache.ConcurrentLinkedHashCacheProvider 
     Key cache size/save period in seconds: 200000.0/14400 
     GC grace seconds: 864000 
     Compaction min/max thresholds: 4/32 
     Read repair chance: 1.0 
     Replicate on write: true 
     Built indexes: [] 
     Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy 

我試圖插入100萬行一列族。寫入吞吐量約爲每秒2500,讀取速度約爲每秒380。

如何提高讀寫吞吐量?

+0

您使用多少個線程來運行您的示例? – zznate 2012-01-05 09:09:04

+0

@zznate:這個例子只有一個線程正在運行.. – 2012-01-05 10:47:43

+1

那麼這對於一個線程是正確的。您可以使用apache源代碼分發中的壓力工具進行一些簡單的性能驗證:https://github.com/apache/cassandra/tree/trunk/tools/stress – zznate 2012-01-05 19:03:54

回答

1

每秒380意味着您正在從低速緩存命中率或OS正在交換的硬盤中讀取數據。檢查卡桑德拉統計數據以找出緩存使用情況:

./nodetool -host <IP> cfstats 

您已啓用行和鍵緩存。行緩存將整行讀入RAM - 意味着由行鍵給出的所有列。在這種情況下,您可以禁用密鑰緩存。但請確保您有足夠的可用RAM來處理行緩存。

如果您的Cassandra具有off-heap-cache(默認值爲1.x),則行緩存可能非常大並且OS開始交換 - 檢查交換大小 - 這可能會降低性能。

+0

謝謝您的回答。列族中的行只有一列,大小爲4KB。這會影響吞吐量嗎? – 2012-01-05 10:58:44

+0

否 - 在這種情況下使用行緩存並禁用密鑰緩存 – 2012-01-10 14:30:43