2016-11-21 7 views
1

私はCassandraのDataSax phpドライバを使用してタイムアウトに問題があります。 私は特定のコマンドを実行するたびに、それは常に10秒後に、この例外がスローされます。Cassandra - DataSax PHPドライバ - タイムアウト

PHP Fatal error: Uncaught exception 'Cassandra\Exception\TimeoutException' with message 'Request timed out' 

私のPHPコードは次のようである:cassandra.yaml

$cluster = Cassandra::cluster()->build(); 
$session = $cluster->connect("my_base"); 
$statement = new Cassandra\SimpleStatement("SELECT COUNT(*) as c FROM my_table WHERE my_colunm = 1 AND my_colunm2 >= '2015-01-01' ALLOW FILTERING") 
$result = $session->execute($statement); 
$row = $result->first(); 

私の設定です:

# How long the coordinator should wait for read operations to complete 
read_request_timeout_in_ms: 500000 
# How long the coordinator should wait for seq or index scans to complete 
range_request_timeout_in_ms: 1000000 
# How long the coordinator should wait for writes to complete 
write_request_timeout_in_ms: 2000 
# How long the coordinator should wait for counter writes to complete 
counter_write_request_timeout_in_ms: 50000 
# How long a coordinator should continue to retry a CAS operation 
# that contends with other proposals for the same row 
cas_contention_timeout_in_ms: 50000 
# How long the coordinator should wait for truncates to complete 
# (This can be much longer, because unless auto_snapshot is disabled 
# we need to flush first so we can snapshot before removing the data.) 
truncate_request_timeout_in_ms: 60000 
# The default timeout for other, miscellaneous operations 
request_timeout_in_ms: 1000000 

私はすでにこれを試しました:

$result = $session->execute($statement,new Cassandra\ExecutionOptions([ 
     'timeout' => 120 
    ]) 
); 

と、この:

$cluster = Cassandra::cluster()->withDefaultTimeout(120)->build(); 

をし、この:

set_time_limit(0) 

そして、それは常に10秒後にTimeoutExceptionがスローされます。.. 私はカサンドラ3.6 任意のアイデアを使用していますか?

答えて

0

あなたが間違っている2つのこと。

  1. 許容フィルタリング:注意してください。許可フィルタリングでこのクエリを実行することは、多くのコンピューティングリソースを使用できるため、良い考えではありません。また、この数()を使用するにはひどいアイデア:生産のフィルタリングフィルタリング https://docs.datastax.com/en/cql/3.3/cql/cql_reference/select_r.html?hl=allow,filter
  2. 数()を許可使用について datastaxドキュメントを読むことができ、使用しないでください。 count()は実際にすべてのデータをページングします。したがって、制限のないuserdetailsからの選択カウント()は、その多くの行でタイムアウトすることが予想されます。ここにいくつかの詳細:http://planetcassandra.org/blog/counting-key-in-cassandra/

どのように修正するには?

  • パーティション化キーなしでクエリが必要な場合は、クラスタ化列 のインデックステーブルを作成する必要があります。
  • count(*)を使用する代わりに、カウンタテーブルを作成する必要があります。
関連する問題