incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruslan usifov <ruslan.usi...@gmail.com>
Subject Re: Slow network writes
Date Thu, 03 Feb 2011 07:58:17 GMT
2011/2/3 Oleg Proudnikov <olegp@cloudorange.com>

> ruslan usifov <ruslan.usifov <at> gmail.com> writes:
>
> >
> >
> > 2011/2/3 Oleg Proudnikov <olegp <at> cloudorange.com>
> > Is it possible that the key "1212" maps to the first node? I am assuming
> RF=1.
> > You could try random keys to test this theory...
> >
> >
> > Yes you right "1212" goes to first node. I distribute tokens like
> described in
> "Operations":
>
> http://wiki.apache.org/cassandra/Operations:085070591730234615865843651857942052864So
> delay in my second experiment(where i got big delay in insert), appear as
> result
> of delay communications between nodes?
> >
>
> That was the theory, assuming you are using replication factor of 1.
>
> It is difficult to say where the key falls just by looking at the ring -
> random
> partitioner could through this key on either node. After writing 1 million
> rows
>

Hm this is very simple to calculate for random, partitioner, this script on
python do that:

from hashlib import md5;

def tokens(nodes):
  l_retval = [];

  for x in xrange(nodes):
    l_retval.append(2 ** 127 / nodes * x);

  return l_retval;

def wherekey(key, orderednodetokens):
  l_m = md5();
  l_m.update(key);
  l_keytoken = long(l_m.hexdigest(), 16);

  l_found = False;
  l_i = 0;

  for l_nodetoken in orderednodetokens:
    if l_keytoken <= l_nodetoken:
      l_found = True;
      break;

    l_i += 1;

  if l_found:
    return l_i;

  return 0;

ring = tokens(2);
print wherekey("1212", ring);


So for key "1212" will by chosen 0 node. 10.24.84.4 in my case

Mime
View raw message