Skip to content

Scatter Gather Operations

opuneet edited this page Aug 27, 2014 · 7 revisions

Dyno is capable of performing scatter gather style operations against it's connection pool. This is particularly useful when a client wants to get the union / intersection etc of results from all nodes.

One concrete use case is the KEYS command in Redis. This does a pattern match on the Redis Server. e.g

redis> MSET foo1 1 foo2 2 foo3 3 foo4 4
OK
redis> KEYS foo*
1) "1"
2) "2"
3) "3"
4) "4"

Now in distributed Redis your individual keys foo1, foo2, foo3 and foo4 can be on 3 different Redis instances. Using Dyno's scatter gather approach, a client can execute the same operation KEYS foo* on every dynomite node and then return the union of all the results. The picture below illustrates how this works.

Here is the method in DynoJedisClient.java for the keys api

@Override
public Set<String> keys(String pattern) {
	...
}

And here is the component that scatter gather is implemented upon for any ConnectionPool.java in Dyno.

 <R> public Collection<OperationResult<R>> executeWithRing(Operation<CL, R> op) 
throws DynoException;