Skip to main content

Posts

Showing posts from August, 2012

enable special character support in Graphite metric name

Problem Graphite doesn’t support special characters like “ “ (empty space), “/” slash etc. Because it expect everything to be just ASCII to split/processing them, and then make directories based on metric name. For example:   Metric:     datacenter1.server1.app1.metric1.abc Will create datacenter1/server1/app1/metric1/abc.wsp But Metric: datacentter1.this is a test/with/path.app.test will fail when create directory So any special name not allow to appear in directory/file name is not supported by Graphite.   What we can do?   We can urlEncode the metric name which has special characters. So like “/var/opt” (not valid file name) will become “%2Fvar%2Fopt”(now valid), using urlEncode instead of others (like BASE64) is because this will keep most of data readable.   So what to change? 1. urlEncode metric name before send to Graphite (if you always sending metrics using text/line mode instead of pickle/batch mode, then you may consider modify Carbon-cache.py), like     metricname=

dynamic snitch and replicationStrategy in Cassandra

What is EndPointSnitch :    Cassandra is a distribute database, and data can be on any of the node or nodes (depends on replication factor).  But one single request from one client can hit only one Cassandra node at a time, so Cassandra needs to locate where is the data (on local node or on remote), then proxy the request to the node, wait for result and then return result to client. EndPointSnitch is used here to determine the sorted list of node Cassandra internally should proxy request to (best node is the first one in list). Coming with Cassandra, there’re 5 EndPointSnitch implementations.   EndPointSnitch also needs to provide “datacenter” and “rack” info for ReplicationStrategy to determine where to put replicas SimpleSnitch:   First get host list from ReplicationStrategy (defined for each keyspace, see below), exclude dead node and then return the node list. This snitch will always return "datacenter1" as datacenter and "rack1" as rack.  

What is node repair doing in Cassandra

here's what will happen when node repair is request (nodetool repair) definition:    neighbors, the node(s) has replica of the data other node(s) has.  For example, you have a 7 node cluster, and token is evenly distributed (that is, each node holds 1/7 range). Assume you set replication factor to 3. That means any data you write should have 3 replicas, under default strategy (SimpleStrategy)  , the next two replicas will be put on the next node along the ring. So if the data you write is on node 4, then node 5 and 6 each will also have one replica. And node 4 should also hold one replica for node 3 and one replica for node 2.  Then the neighbors for node 4 will be node 2,3,4,5 and 6.  Using same logic, node 6’s neighbors will be 4,5,6,7 and 1 (remember it’s a ring, when you reaches end, the next will be the first node) you can do the same calculation for other node or for other replication factor. Steps: for each keyspace in Cassandra DB do below:         skip if it's sys

How Cassandra Hector client load balancing work

Concept: hector connection pool contains other connection pools. The "other connection pool" here is the connection pool to each Cassandra host. Let's call the master hector pool as hector pool and other pools as host pool. So, for example, your cluster has 3 hosts, then the hector pool will contain 3 host connection pools, each host pool has several connections to one of the 3 hosts. Details: come with hector client library, there are 3 load balancing policies (will call them LBP). 1. RoundRobinBalancingPolicy         this LBP always return next host pool in hector pool. So if you have 3 hosts as A, B and C. Then when you request new connection pool, this LBP will give you A, B, C, A, B, C, A …. 2. LeastActiveBalancingPolicy         This LBP keeps track of how many active connections within each host pool. And when you request a new one, it will return then host pool with least active connections . If multiple host pools have same active connections, randomly return on