5 ms·
Damn Cool Algorithms: Log structured storage (2009)
- no_protocol 9y agoI am impressed by the writing style. Very clear and delivers a solid explanation. What relation, if any, would this type of system have with "persistent data structures", a term I have seen used in some browsing of functional programming topics. Is this somewhat like a persistent data structure until old parts are overwritten ("garbage collected"?)? Is there a flavor of persistent data structure similar to this?
- jeffffff 9y agowith the exception of the log itself (and its in memory representation) it is a persistent data structure
- noahdesu 9y agoWe were looking for ways to implement a key-value store on a distributed log, and we actually started from a very basic persistent red-black tree, adapting it along the way for log-structured storage. The technique worked really well: http://noahdesu.github.io/2016/08/02/zlog-kvstore-intro.html http://noahdesu.github.io/2016/08/02/zlog-kvstore-intro.html
- noahdesu 9y agoThere is also a really cool paper on concurrency control for databases implemented as log-structured storage: http://www.vldb.org/pvldb/vol4/p944-bernstein.pdf http://www.vldb.org/pvldb/vol4/p944-bernstein.pdf
- timClicks 9y agoSlightly related perhaps and something I have been curious about for a while... event sourcing seems like a very powerful pattern that I haven't seen wide adoption. The best documentation seems to be some MS dev library notes and a discussion from M Fowler. Are there any open source implementations of a database that uses event sourcing?
- sprucely 9y agoDoes GetEventStore[1] fit the bill? [1] https://geteventstore.com/ https://geteventstore.com/
- zshift 9y agoCheck out the videos and articles by Greg Young on the topic. This one's a good start https://www.youtube.com/watch?v=8JKjvY4etTY https://www.youtube.com/watch?v=8JKjvY4etTY
- marknadal 9y agoI built https://github.com/amark/gun https://github.com/amark/gun after I was using MongoDB to event source data. The key piece for me was wanting to have Firebase-like realtime sync for my event sourcing. It is MIT/ZLIB/Apache2 licensed.
- lgas 9y agoIn addition to the other solutions mentioned, Apache Samza[0] lands somewhere in that neighborhood. [0]: https://www.confluent.io/blog/turning-the-database-inside-out-with-apache-samza/ https://www.confluent.io/blog/turning-the-database-inside-ou...
- elcritch 9y agoI've become a bit of a CouchDB zealot of late for this exact reason... Native support for incrementally updating map-reduce combined with change-feeds makes implementing event sourcing straightforward. Oh, and it works with PouchDB or Couchbase Lite on web and mobile platforms! A sibling poster wrote Gun(DB?) which would be the next DB I'd try if CouchDB couldn't fit the bill. If you wanted to reimplement event sourcing in couch, it can be implemented as a versioned merge in a map-reduce view that takes a sequential ordered events (e.g. `ui-event:0000025`) and maps those changes into a "versioned" JSON. This versioned JSON changes leaf values into versioned objects like `"fieldValue": { "_val": 34.00, "_ver": 25 }` which I call property fields. This is necessary because CouchDB is a B+Tree implementation and reduce operations are sequential but not contiguous. The reduce phase merges all events sequentially by choosing property fields with the latest event – making it a CRDT type – and resulting in a single JSON document with the latest fields with "_ver" info for each. This scheme has a drawback that each event needs to have a unique serially ordered ID to work. Not sure how time stamps would work. I chose the ID based scheme to allow the UI be able to know when a user interaction conflicts (a vector clock between) and let it display the conflict to the user or decide how to merge the knew state. It's not the most efficient but for most moderate sized UI's with a single state tree, it performs fine. Enough to run on a raspberry pi. :) The only thing I haven't implemented in this is user permissions, but I suspsect using something like JWT tokens could provide a way to "verify" a user event on the CouchDB server. I'd be curious to know if this scheme would perform much better with an log merge database, but there doesn't seem to be any obvious benefits to me, imho. Alternatively, does anyone else know of other DB's with incremental map-reduce? Postgres materialized views (pre v10) and Mongo map reduce views both seem to require explicit calls to update them after new events. [edit: mobile phone grammar fixes]
- nostrademons 9y agoIn the 8 years since this was written, Log-Structured Merge Trees (the concrete realization of this idea) have basically "won". BigTable, AppEngine, LevelDB, Cassandra, HBase, MongoDB, and several others are all built around them. There's a powerful hardware trend driving this, namely that disk capacities and write bandwidth are still increasing rapidly, but seek times have basically plateaued. That means that data structures that rely on append-only operations can continue to scale to take advantage of bigger disks, but data structures that rely on disk seeks (eg. B-trees) have hit a bottleneck. Also, as number of cores continues to increase, playback & processing from a sequential log can often be parallelized, but updating your on-disk indexes blocks on I/O.
- gregw134 9y agoI suppose the follow up question is, what will replace this once enterprise SSDs start replacing spinning disks?
- simcop2387 9y agoMy layman's guess is something that combines the two. larger immutable storage using B-Tree's (or similar), and more live data using log structured stuff. With semi-regular promotion of data from log to b-tree and eventual clean-up of data no longer referencable in the b-tree.
- nostrademons 9y agoSSDs have even more unique access patterns - they give you (relatively) fast seek times, there's no particular penalty for random-access vs. sequential usage, but you really want to avoid writes, both to preserve the lifetime of the drive and because mixing reads & writes with a SSD lowers performance. In practice (and I haven't worked in a big corp for a couple years now), I don't see SSDs replacing mechanical disks. Rather, they're being used for different functions. Disks are becoming a data warehouse; they're the new tape, but one that systems can write directly to, without needing scheduled backups. Operational serving is moving toward SSDs and RAM, with a periodic processing step that pulls data off disks and builds a pre-made shard that gets written all at once to the SSD. LSM trees are well-adapted to the data-warehousing part of this, which is why you continue to see big uptake of BigTable/Cassandra/Mongo. On the SSD end...most people are using custom algorithms & data structures, AFAIK, but you're seeing a resurgence of data structures like perfect hashes, bloom filters, and plain old sorted arrays, all of which have great read performance but can't be incrementally updated without rebuilding the whole data structure.
- d_t_w 9y agoFor further/similar content by Ben Stopford that I personally found a very high quality: http://www.benstopford.com/2015/02/14/log-structured-merge-trees/ http://www.benstopford.com/2015/02/14/log-structured-merge-t...
- mwcampbell 9y agoAnother notable product based on log-structured storage is ObjectiveFS (https://objectivefs.com/ https://objectivefs.com/), which implements a POSIX filesystem on top of Amazon S3 and other object stores. It's proprietary, so I don't know much about how it works. But it claims to be a log-structured filesystem.