Distributed OLTP and Dynamic Query Routing with Akka

68 views
Skip to first unread message

Marko Rodriguez

unread,
Dec 7, 2016, 7:13:18 AM12/7/16
to gremli...@googlegroups.com
Hello,

I have been studying Akka lately as a way to implement distributed OLTP/dynamic query routing. I have a working implementation.

This is a “toy implementation” currently in the TINKERPOP-1564 test/ of tinkergraph-gremlin.

There are 3 classes: 

TinkerActorSystem
This class creates an Akka ActorSystem for a submitted traversal. It then spawns a MasterTraversalActor given the traversal and a partitioner. The partitioner is currently hardcoded.

MasterTraversalActor
This class spawns a WorkerTraversalActor for each partition in the partitioner. It then “starts” each worker and awaits halted traversers (results).

WorkerTraversalActor
This class streams out its partition's start step traversers. If the traverser references elements local to its partition, it process it. Else, it messages the traverser to the respective worker partition. It also receives traversers from remote workers and processes them accordingly. If it yields a halted traverser, the worker sends the halted traverser to the master traversal.

Here is the System.out data when using:

g.V().match(
  as("a").out("created").as("b"),
  as("b").in("created").as("c"),
  as("b").has("name", eq("lop"))).
    where("a", neq("c")).
    select("a", "b", "c").by("name")

master[result]: {a=marko, b=lop, c=peter}
master[result]: {a=josh, b=lop, c=marko}
master[result]: {a=marko, b=lop, c=josh}
master[result]: {a=peter, b=lop, c=josh}
master[result]: {a=peter, b=lop, c=marko}
master[result]: {a=josh, b=lop, c=peter}


This implementation currently does not support traversals with barriers or side-effects. Moreover, it does not “stall the workers” to build up traverser bulks. In other words, it currently messages one traverser at a time.

I hope you can appreciate the simplicity of implementation. Using akka-remote, the code stays the same, save the URIs of the Akka actors changes. Its all pretty basic in fact.

Enjoy,
Marko.

Marko Rodriguez

unread,
Dec 7, 2016, 3:55:38 PM12/7/16
to d...@tinkerpop.apache.org, gremli...@googlegroups.com
Hello,

So Distributed OLTP is done. I was able to get barriers, side-effects, auto-halting, stalling traversers for bulking, etc. implemented since this morning and well, tada.

There are more classes now, so here is a link to the package root. Again, this is just a test/ package in TinkerGraph for now to make it easy for me to play.


In TinkerActorSystem, you will see 3 traversals that executed in the public static main(). Here is the output.

EXECUTING: [[withStrategies(VertexProgramStrategy)], [V(), match([[], [as(a), out(created), as(b)]], [[], [as(b), in(created), as(c)]], [[], [as(b), has(name, eq(lop))]]), where(a, neq(c)), select(a, b, c), by(name)]]
master[result]: {a=peter, b=lop, c=josh}
master[result]: {a=marko, b=lop, c=peter}
master[result]: {a=josh, b=lop, c=marko}
master[result]: {a=josh, b=lop, c=peter}
master[result]: {a=peter, b=lop, c=marko}
master[result]: {a=marko, b=lop, c=josh}
//////////////////////////////////

EXECUTING: [[withStrategies(VertexProgramStrategy)], [V(), repeat([[], [both()]]), times(2), groupCount(a), by(name), cap(a), select(keys), unfold(), limit(3)]]
master[result]: ripple
master[result]: peter
master[result]: vadas
//////////////////////////////////

EXECUTING: [[withStrategies(VertexProgramStrategy)], [V(), repeat([[], [both()]]), times(2), hasLabel(person), group(), by(name), by([[], [out(created), values(name), dedup(), fold()]])]]
master[result]: {peter=[lop], vadas=[], josh=[ripple, lop], marko=[lop]}
//////////////////////////////////

Why are these traversals cool?

1. match() works.
2. side-effects work.
3. reducing barriers work and check it, you can traverser beyond the local star graph!

What really opened everything up was realizing I could implement my own Mailbox.


This allows me to order how certain types of messages are read by the actors and most importantly, allows me to back Traverser messages by a TraverserSet and thus, we now have the bulking optimization.

So freakin’ cool.

Enjoy!,
Marko.



Reply all
Reply to author
Forward
0 new messages