<div dir="ltr">Hello<div><br></div><div>I want some opinions on how to implement a blob store.</div><div><br></div><div>I want a simple key-value store. </div><div><br></div><div><br></div><div>To fix our ideas </div><div>
<br></div><div> - The values are variable size binaries (max 56 KB) </div><div> - The keys are SHA1 hashes of the values</div><div> - I want to store max 1M blobs</div><div> - Efficiency is not a concern (though it would be a deciding factor given two</div>
<div> equally beautiful solutions)</div><div><br></div><div>The *simplest* way I can think of is to use the file store</div><div>a blob with (hex) hash "a2e34a32..." gets stored in 2-level directory structure</div>
<div>in a file called a2/e3/a2e34a32</div><div><br></div><div>Even this might have problems - for example is file:write_file/2 atomic?</div><div>What happens if two process try to write the same file at the same time with the same</div>
<div>content? (and I know "at the same time" is meaningless, but it's shorter to say than</div><div>' if one processes has made a write_file request and a second process makes a write_file</div><div>request before the first request issued by the first process has completed ...)</div>
<div><br></div><div>The next simplest way I can think of is to make a single huge blob store file</div><div>(max 56GB) and use an ets table to map hashes to addresses in the file -</div><div>if this is a good idea or not would depend upon how well the host OS handles sparse files</div>
<div>and so on.</div><div><br></div><div>The third alternative would be to use a raw disk partition(very non portable etc.)</div><div><br></div><div>The fourth alternative would be to use a library like bitcask</div><div>
<br></div><div>The fifth alternative would be use use some other library.</div><div><br></div><div><br></div><div>My instinct points me to the *simplest* way (above) or bitcask.</div><div><br></div><div>Now I know that Richard will reply "do them all and measure" - but possibly somebody somebody has done this before - so I can benefit from their wisdom.</div>
<div><br></div><div>All ideas are welcome</div><div><br></div><div>Cheers</div><div><br></div><div>/Joe</div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div></div>