[英]Spring boot Cassandra read timeout
我有Spring Boot + cassandra Web應用程序的問題。 它開始隨着數據的增長而出現,現在它是超常見的場景。
所有查詢有時都不起作用, CassandraRepository
返回null
。 幾秒鍾之后它再次起作用,接下來的幾秒鍾它再次無法工作。 因此,Web應用程序不斷返回200
或404
響應。 相同的查詢cqlsh
在cqlsh
工作。
我正在使用:
數據結構:
CREATE KEYSPACE data WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': '2'} AND durable_writes = true;
CREATE TABLE data.image (
hash text PRIMARY KEY,
image blob
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
要配置Cassandra連接,我使用:
@Configuration
@EnableCassandraRepositories(basePackages = "...path...")
public class CassandraConfig extends AbstractCassandraConfiguration {
@Bean
public CassandraClusterFactoryBean cluster() {
CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean();
cluster.setContactPoints("127.0.0.1");
cluster.setPort(91234);
return cluster;
}
要檢索數據我正在使用帶有@Query(("select * from image where id = ?0"))
CassandraRepository
@Query(("select * from image where id = ?0"))
QueryAnnotation。 檢索到的數據包含圖像blob。
我認為讀取超時是一個問題,服務器具有較慢的HDD磁盤而不是那么強大的CPU。 但是如何使用spring boot starter覆蓋此設置?
我試過用
SocketOptions so = new SocketOptions();
so.setConnectTimeoutMillis(10000);
so.setReadTimeoutMillis(20000);
cluster.setSocketOptions(so);
沒有成功。
我還能做些什么來獲得穩定的工作解決方案?
nodetool repair
幫助 - >幾天后一切都開始按預期工作。 結論:寫數據庫太多了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.