CodeCommitsIssuesPull requestsActionsInsightsSecurity
master

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS
SSH

Download ZIP

README

48lines · modecode

15 years ago
1SortaSQL
2
3An extension to PostgreSQL allowing Kyoto Cabinets to be used as a backing data store.
4Currently very customized for CloudFlare's usage pattern of online log analysis.
5
6Install
7
8Update the paths in common.h
9
10protoc-c --c_out=c entry.proto
11protoc --cpp_out=cpp entry.proto
12make
13sudo make install
14
15About
16
17Google has BigTable and GFS.
18Facebook has HBase and Cassandra.
19And then there's the up and coming set of Membase, CouchDB, MongoDB, and so on and so forth.
20
21These all scale by eliminating flexibility, presenting a user with a key-value interface where keys are ordered to allow efficient iteration.
22But by throwing out the relational part of a relational database, you lose a lot of value and flexibility in looking at data, not to
23mention all of the nice language bindings that old school RDBMs have.
24Compounding this, NoSQL DBs are also all new, all have bugs, and no one has that much experience managing them.
25Its a brave new world out there.
26
27At CloudFlare, we spent quite a while evaluating different NoSQL solutions.
28We were looking for a reliable and cheap way to store Big Data down the road, while storing Medium Data right now.
29We need to be able to scale with one technology, going from a single machine to two machines, to four and so on to full on a cluster.
30The catch is we don't want to buy that cluster right now.
31
32We messed with HBase and Hive in particular, but weren't able to get reliable performance from these while running on a scaled down infrastructure.
33For a while then we fell back on Postgres, but pretty soon this was showing signs of creaking under the load.
34But we still weren't ready to make the jump to a big rack full of servers.
35
36Needing a middle ground, we created a hybrid model using both SQL and noSQL technologies.
37In our existing Postgres DB, we created a custom data type which acts as a pointer into an embedded Kyoto Cabinet DB.
38Kyoto Cabinet is a collection of C functions which allow lookup and sets into a simple data file containing records, each of these consisting of a key/value pair.
39Adding a few functions and operators to Postgres allows searching of these KC files both using Postgres's explicit indexes and KC's implicit indexes (keys are ordered and can be stored via a B-Tree).
40Storing values serialized using Google's Protocol Buffers allows complex structures to be added as values, while not needing much diskspace.
41
42See also:
43
44http://www.postgresql.org/
45http://fallabs.com/kyotocabinet/
46
47Copyright 2011 CloudFlare, Inc.