<div dir="ltr"><div>Can you shard your event log by aggregate type and thus avoid the deletion/compaction issue altogether? I've read some people suggest sharding by aggregate ID if the aggregate type shard is not small enough [1].</div><div><br></div><div>If you haven't already, you may want to write a simple benchmark that append gobs of data to a file. I found a 2013 thread [2] on Erlang Questions with a similar sequential append use case where the OP was not happy with Erlang's speed. But I can't follow his math: writing 5 Gigabits in 104 seconds seems like a lot more that 504Hz. I also found people complaining that get_line was slow. I guess parallel reads would be possible inside an aggregate boundary ...</div><div><br></div><div>CQRS is a topic I am very interested in, I hope you post again!</div><div><br></div><div>[1] <a href="http://cqrs.nu/Faq/event-sourcing">http://cqrs.nu/Faq/event-sourcing</a></div><div>[2] <a href="http://erlang.org/pipermail/erlang-questions/2013-June/074190.html">http://erlang.org/pipermail/erlang-questions/2013-June/074190.html</a><br></div><div><br></div><div>P.S. I've wondered why people don't treat a snapshot (or "compaction") as a command. One that emits a "special" event with the current state of that aggregate. Write this event to a fast durable key/value store (again, one per aggregate type) where the key is aggregate id and the value is the aggregate state and an offset into the main log where you should pick up reading from.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 18, 2016 at 6:54 AM, John Smith <span dir="ltr"><<a href="mailto:4crzen62cwqszy68g7al@gmail.com" target="_blank">4crzen62cwqszy68g7al@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>For one of my systems in the financial area, I am in need of a disk-backed log that I could use as a backend for an Event Sourcing/CQRS store. Recently, I have read a bit about Kafka [1] and it seems like a good fit but, unfortunately, it is on JVM (written in Scala, to be exact) and depends heavily on ZooKeeper [2] for distribution, while I would prefer something similar for an Erlang ecosystem. Thus, ideally, I would like to have something that is:</div><div><br></div><div> * small,</div><div> * durable (checksummed, with a clear recovery procedure),</div><div> * pure Erlang/Elixir (maybe with some native code, but tightly integrated),</div><div> * (almost) not distributed - data fits on the single node (at least now; with replication for durability, though).</div><div><br></div><div>Before jumping right into implementation, I have some questions:</div><div><br></div><div> 1. Is there anything already available that fulfils above requirements?</div><div> 2. Kafka uses different approach to persistence - instead of using in-process buffers and transferring data to disk, it writes straight to the filesystem which, actually, uses pagecache [3]. Can I achieve the same thing using Erlang or does it buffers writes in some other way?</div><div> 3. ...also, Kafka has a log compaction [4] which can work not only in time but also in a key dimension - I need this, as I need to persist the last state for every key seen (user, transfer, etc.). As in Redis, Kafka uses the UNIX copy-on-write semantics (process fork) to avoid needless memory usage for log fragments (segments, in Kafka nomenclature) that have not changed. Can I mimick a similar behaviour in Erlang? Or if not, how can I deal with biggish (say, a couple of GB) logs that needs to be compacted?</div><div><br></div><div>In other words, I would like to create something like a *Minimum Viable Log* (in Kafka style), only in Erlang/Elixir. I would be grateful for any kind of design/implementation hints. </div><div><br></div><div>[1] <a href="http://kafka.apache.org/" target="_blank">http://kafka.apache.org/</a></div><div>[2] <a href="https://zookeeper.apache.org/" target="_blank">https://zookeeper.apache.org/</a></div><div>[3] <a href="http://kafka.apache.org/documentation.html#persistence" target="_blank">http://kafka.apache.org/documentation.html#persistence</a></div><div>[4] <a href="https://cwiki.apache.org/confluence/display/KAFKA/Log+Compaction" target="_blank">https://cwiki.apache.org/confluence/display/KAFKA/Log+Compaction</a></div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>