| CARVIEW |
twitter / flockdb
- Source
- Commits
- Network (11)
- Issues (1)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
click here to add a description
click here to add a homepage
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Thu May 13 16:55:44 -0700 2010 | ignore me! [robey] |
| |
LICENSE | Sun Apr 11 21:28:31 -0700 2010 | adding license and some sketch of basic client-... [Nick Kallen] |
| |
README.markdown | Tue May 18 13:52:28 -0700 2010 | mention that thrift 0.2.0 is required. [robey] |
| |
TODO | Sun Apr 11 20:54:00 -0700 2010 | initial source import [Nick Kallen] |
| |
ant/ | Sun Apr 11 20:54:00 -0700 2010 | initial source import [Nick Kallen] |
| |
build.xml | Tue Apr 27 13:41:44 -0700 2010 | unused build target. [robey] |
| |
config/ | Thu May 20 16:17:01 -0700 2010 | don't need so many threads in dev mode. :) [robey] |
| |
doc/ | Mon May 03 22:36:03 -0700 2010 | fix another typo. [robey] |
| |
ivy/ | Thu May 27 15:39:46 -0700 2010 | fix versions to match sbt. [robey] |
| |
libs/ | Mon Apr 12 12:43:02 -0700 2010 | use gizzard from nest instead of committing it ... [robey] |
| |
project/ | Thu May 27 15:39:35 -0700 2010 | don't need to list these explicitly. [robey] |
| |
src/ | Tue May 25 16:02:17 -0700 2010 | tweaked setup script [freels] |
FlockDB
FlockDB is a distributed graph database for storing adjancency lists, with goals of supporting:
- a high rate of add/update/remove operations
- potientially complex set arithmetic queries
- paging through query result sets containing millions of entries
- ability to "archive" and later restore archived edges
- horizontal scaling including replication
- online data migration
Non-goals include:
- multi-hop queries (or graph-walking queries)
- automatic shard migrations
FlockDB is much simpler than other graph databases such as neo4j because it tries to solve fewer problems. It scales horizontally and is designed for on-line, low-latency, high throughput environments such as web-sites.
Twitter uses FlockDB to store social graphs (who follows whom, who blocks whom) and secondary indices. As of April 2010, the Twitter FlockDB cluster stores 13+ billion edges and sustains peak traffic of 20k writes/second and 100k reads/second.
It does what?
If, for example, you're storing a social graph (user A follows user B), and it's not necessarily symmetrical (A can follow B without B following A), then FlockDB can store that relationship as an edge: node A points to node B. It stores this edge with a sort position, and in both directions, so that it can answer the question "Who follows A?" as well as "Whom is A following?"
This is called a directed graph. (Technically, FlockDB stores the adjacency lists of a directed graph.) Each edge has a 64-bit source ID, a 64-bit destination ID, a state (normal, removed, archived), and a 32-bit position used for sorting. The edges are stored in both a forward and backward direction, meaning that an edge can be queried based on either the source or destination ID.
For example, if node 134 points to node 90, and its sort position is 5, then there are two rows written into the backing store:
forward: 134 -> 90 at position 5
backward: 90 <- 134 at position 5
If you're storing a social graph, the graph might be called "following", and you might use the current time as the position, so that a listing of followers is in recency order. In that case, if user 134 is Nick, and user 90 is Robey, then FlockDB can store:
forward: Nick follows Robey at 9:54 today
backward: Robey is followed by Nick at 9:54 today
The (source, destination) must be unique: only one edge can point from node A to node B, but the position and state may be modified at any time. Position is used only for sorting the results of queries, and state is used to mark edges that have been removed or archived (placed into cold sleep).
Building
In theory, building is as simple as
$ ant
but there are some pre-requisites. You need:
- java 1.6
- ant 1.7
- thrift 0.2.0
In addition, the tests require a local mysql instance to be running, and for DB_USERNAME and
DB_PASSWORD env vars to contain login info for it. You can skip the tests if you want:
$ ant -Dskip.test=1
There should be support for building with sbt "soon".
Running
Check out the demo for instructions on how to start up a local development instance of FlockDB. It also shows how to add edges, query them, etc.
Community
- Twitter: #flockdb
- IRC: #twinfra on freenode (irc.freenode.net)
- Mailing list: flockdb@googlegroups.com subscribe
Contributors
- Nick Kallen @nk
- Robey Pointer @robey
- John Kalucki @jkalucki
- Ed Ceaser @asdf
