0

将数据保存到 cassandra 时,70% 的保存性能大约需要 4-8 毫秒。但是 30% 的请求大约需要 80-90 毫秒。所以试图弄清楚为什么有些请求需要很长时间。我怀疑这些请求可能会跨越数据中心,但无法确认。

此外,当使用 astyanax 时,我们将固定到 localhost,这将有助于连接到本地 cassandra 协调器。此处使用的主键是生成的 UUID。

如果有人可以帮助解决这个问题,我将不胜感激。

Write Consistency: CL_ONE
Read Consistency: CL_LOCAL_QUORUM

using Astyanax for java client: 1.56.37
Cassandra version: 1.2.5

这是键空间信息:

CREATE KEYSPACE grd WITH replication = {
  'class': 'NetworkTopologyStrategy',
  'HYWRCA02': '2',
  'CHRLNCUN': '2'
};

CREATE TABLE route (
  routeid uuid PRIMARY KEY,
  allowdynamicstickyness boolean,
  businesskey uuid,
  createdby text,
  createdtimestamp timestamp,
  datapartitionkeyselectorref text,
  deletedby text,
  deletedtimestamp timestamp,
  envcontext text,
  lockedbyuser text,
  partner text,
  routelocationlatitudeselector double,
  routelocationlongitudeselector double,
  routelocationmaxdistanceselector double,
  routename text,
  sequence int,
  serviceidentifier text,
  stalenessinmins int,
  status text,
  stickykeyselector text,
  tags set<text>,
  type text,
  updatedby text,
  updatedtimestamp timestamp,
  versionmapnameref text,
  versionselector text
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='ALL' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  compaction={'class': 'LeveledCompactionStrategy'} AND
  compression={'sstable_compression': 'SnappyCompressor'};

谢谢。

4

1 回答 1

0

尝试登录到集群的一个节点并执行 cqlsh 并使用 USE 选择您的密钥空间:

[root@yournode ~]# cqlsh
Connected to YourCluster at localhost:9160.
[cqlsh 3.1.2 | Cassandra 1.2.6 | CQL spec 3.0.0 | Thrift protocol 19.36.0]
Use HELP for help.
cqlsh> use yourkeyspacehere ;

在此之后在 cqlsh 上执行跟踪命令:

cqlsh:yourkeyspacehere> tracing on
Now tracing requests.

然后尝试使用不同的键在您的表上运行不同的查询,并检查查询中涉及的节点的时间和 IP,以检查是否存在数据中心间连接。示例输出可能如下所示:

select * from your_table_name_is_here limit 1;

Tracing session: 1ab19ff0-2fa3-11e3-a9aa-2face31554b7

 activity                                                                                        | timestamp    | source         | source_elapsed
-------------------------------------------------------------------------------------------------+--------------+----------------+----------------
                                                                              execute_cql3_query | 22:52:12,528 | XXX.XX.XXX.XXX |              0
                                          Parsing select * from your_table_name_is_here limit 1; | 22:52:12,529 | XXX.XX.XXX.XXX |           1108
                                                                              Peparing statement | 22:52:12,530 | XXX.XX.XXX.XXX |           1555
                                                                   Determining replicas to query | 22:52:12,530 | XXX.XX.XXX.XXX |           1643
                                                           Message received from /XXX.XX.XXX.XXX | 22:52:12,534 | YYY.YY.YYY.YYY |             34
                                                            Enqueuing request to /YYY.YY.YYY.YYY | 22:52:12,536 | XXX.XX.XXX.XXX |           7549
                                                              Sending message to /YYY.YY.YYY.YYY | 22:52:12,536 | XXX.XX.XXX.XXX |           7812
 Executing seq scan across 9 sstables for [min(-9223372036854775808), max(-8721075978151533877)] | 22:52:12,538 | YYY.YY.YYY.YYY |           3609
                                                                    Scanned 1 rows and matched 1 | 22:52:12,550 | YYY.YY.YYY.YYY |          15977
                                                           Enqueuing response to /XXX.XX.XXX.XXX | 22:52:12,550 | YYY.YY.YYY.YYY |          16035
                                                              Sending message to /XXX.XX.XXX.XXX | 22:52:12,550 | YYY.YY.YYY.YYY |          16202
                                                           Message received from /YYY.YY.YYY.YYY | 22:52:12,557 | XXX.XX.XXX.XXX |          28494
                                                        Processing response from /YYY.YY.YYY.YYY | 22:52:12,557 | XXX.XX.XXX.XXX |          28647
                                                                                Request complete | 22:52:12,556 | XXX.XX.XXX.XXX |          28884

希望能帮助到你!

于 2013-10-07T23:01:40.703 回答