How Scalaris stores your data
Dave Bryson - daveb - July 27, 2008After installing Scalaris, running a few nodes, and playing with the API, I wanted to figure out how it actually stores the data. Using this diagram: supervisor.pdf I tracked down the source in the file cs_db_otp.erl ( the db was the obvious clue).
The database is a gen_server that wraps calls to the underlying storage - an Erlang gb_tree. What this means is the data is not actually saved to disk, but rather lives in memory. It appears the each chordnode has its own database.
When you store a Key - Value pair, the database actually records a structure like this in the gb_tree:
Key,{Value,WriteLock,ReadLock,Version}
On a write, “WriteLock” is set to true and the Version is incremented. On a read, “ReadLock” is set to true. Most of this logic appears to be controlled through the transaction layer.
Other stuff
- Search? There appears to be the ability to search for keys within a given range via a “get_range”. But I haven’t yet found how to call that from the transaction_api
- No delete. As I mentioned in my earlier write up on using the API, there is no way to actually “delete” a key once it’s set. But hey, the code is open-source and since gb_tree has a delete method, it should be possible to add.
One other thing of note, if you’ve implemented any distributed Erlang you know it’s not recommended to run a cluster of Erlang nodes around the Internet using the built in code. Scalaris implements its own TCP layer (the authors mention this in their Videos) for the nodes to communicate. Check out the comm_layer in the source for some ideas if you need to write your own.
Categories: Blogs Dave Bryson
Comments
No comments so far, you could be the first.Add comment
Erlang on Twitter
» quercialwji2 (Quercia Quinn): @RolArens http://t.co/pPiIpTCx
» quercialwji2 (Quercia Quinn): @kreese555 http://t.co/pPiIpTCx
» erlang (Andreas Åkre Solberg): RT @SaraJChipps: Node.js is like taking a bubble bath in JavaScript.
» trabajosit (Empleos en IT): argentina Desarrolladores - iOS, Ruby, Erlang: Estamos buscando un líder de desarrollo que quiera hacer una gran… http://t.co/zhTLpGI1
» erlang (Andreas Åkre Solberg): jQuery Scroll Path Plugin http://t.co/DHZ0W36c via @JoelBesada
» martyns (martynas): fighting with load bursts. probably its time to deploy https://t.co/xJxKcRmQ. #erlang
» Louellaoqk (Louella Delaroca): Informationsmanagement in Hochschulen (German Edition): Die Informations- und Kommunikationstechnik (IuK) erlang… http://t.co/95UJGZS3
» fgtrjhyu (アスパラガー): 多分「どうでもいい」だと思うんだ。 Smalltalk→Obj…C erlang→node.jsと同じで。
» zbyszek (Zbyszek Żółkiewski): RT @michalptaszek: Going to give #ejabberd tutorial on @erlangfactory in SF this March :) Anyone?
http://t.co/0bnFtIKf #xmpp #erlang
» jeedee (jeedee): Erlang, y u so fast?
Statistics
Number of aggregated posts: 10456
Number of comments: 1445
Most recent article: February 06, 2012
Latest comments
» simple smile on Scale means Skills: Very informative article. Pretty sure people would love to go to that place for shopping. Specially to those who are…
» simplesmile on 27 January 2012: Erlang Solutions embarks on an Erlang Embedded KTP: Your article will make the world better. Thanks again and good luck to you in your life. See you next time.simplesmile
» tandblekning easewhite on 08 February 2012: Erlang Express 3-day Course in San Francisco on 8 February: ncomprehensible to me now, but in general, the usefulness and significance is overwhelmingtandblekning easewhite