<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="199285" data-post-id="199285">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Exadra37" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Exadra37/120/9183_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Exadra37
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="vans163" data-post="11" data-topic="36531">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/vans163/48/13216_2.png" class="avatar"> vans163:</div>
<blockquote>
<aside class="quote no-group" data-username="Exadra37" data-post="10" data-topic="36531">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/exadra37/48/9183_2.png" class="avatar"> Exadra37:</div>
<blockquote>
<p>Event Sourcing</p>
</blockquote>
</aside>
<p>What does this even mean?</p>
</blockquote>
</aside>
<p>Maybe this article can help you understanding it better and how it fits with Event Sourcing:</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://www.confluent.io/blog/event-sourcing-cqrs-stream-processing-apache-kafka-whats-connection/">
  <header class="source">
      <img src="https://www.confluent.io/favicon.ico" class="site-icon" alt="" width="690" height="690">

      <a href="https://www.confluent.io/blog/event-sourcing-cqrs-stream-processing-apache-kafka-whats-connection/" target="_blank" rel="noopener nofollow ugc">Confluent</a>
  </header>

  <article class="onebox-body">
    <img width="690" height="690" src="https://cdn.confluent.io/wp-content/uploads/seo-logo-meadow.png" class="thumbnail onebox-avatar" alt="">

<h3><a href="https://www.confluent.io/blog/event-sourcing-cqrs-stream-processing-apache-kafka-whats-connection/" target="_blank" rel="noopener nofollow ugc">Event sourcing, CQRS, stream processing and Apache Kafka: What’s the...</a></h3>

  <p>Confluent is building the foundational platform for data in motion so any organization can innovate and win in a digital-first world.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<hr>
<aside class="quote no-group quote-modified" data-username="vans163" data-post="11" data-topic="36531">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/vans163/48/13216_2.png" class="avatar"> vans163:</div>
<blockquote>
<aside class="quote no-group" data-username="Exadra37" data-post="10" data-topic="36531">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/exadra37/48/9183_2.png" class="avatar"> Exadra37:</div>
<blockquote>
<p>The advantages of using a Kafka as a data lake that anyone in the organization can consume or produce data into is very powerful</p>
</blockquote>
</aside>
<p>As a datalake Kafka makes sense.</p>
</blockquote>
</aside>
<p>Kafka is not properly a database, but can almost be used like one.</p>
<p>See this articles to understand better what is a data lake:</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://www.confluent.io/resources/kafka-summit-2020/kafka-as-your-data-lake-is-it-feasible/">
  <header class="source">
      <img src="https://www.confluent.io/favicon.ico" class="site-icon" alt="" width="690" height="690">

      <a href="https://www.confluent.io/resources/kafka-summit-2020/kafka-as-your-data-lake-is-it-feasible/" target="_blank" rel="noopener nofollow ugc">Confluent</a>
  </header>

  <article class="onebox-body">
    <img width="690" height="690" src="https://cdn.confluent.io/wp-content/uploads/seo-logo-meadow.png" class="thumbnail onebox-avatar" alt="">

<h3><a href="https://www.confluent.io/resources/kafka-summit-2020/kafka-as-your-data-lake-is-it-feasible/" target="_blank" rel="noopener nofollow ugc">Kafka as your Data Lake - is it Feasible? - Confluent</a></h3>

  <p>"Kafka Streams, Apache Kafka’s stream processing library, allows developers to build sophisticated stateful stream processing applications which you can deploy in an environment of your choice.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<aside class="onebox allowlistedgeneric" data-onebox-src="https://cloud.google.com/blog/products/data-analytics/data-lakes-in-cloud-with-kafka-and-confluent">
  <header class="source">
      <img src="https://www.gstatic.com/cgc/supercloud_favicon.ico" class="site-icon" alt="" width="64" height="64">

      <a href="https://cloud.google.com/blog/products/data-analytics/data-lakes-in-cloud-with-kafka-and-confluent" target="_blank" rel="noopener nofollow ugc">Google Cloud Blog</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/339;"><img src="https://storage.googleapis.com/gweb-cloudblog-publish/images/09_-_Data_Analytics_tFH57V6.max-2600x2600.jpg" class="thumbnail" alt="" width="690" height="339"></div>

<h3><a href="https://cloud.google.com/blog/products/data-analytics/data-lakes-in-cloud-with-kafka-and-confluent" target="_blank" rel="noopener nofollow ugc">Data lakes in cloud with Kafka and Confluent | Google Cloud Blog</a></h3>

  <p>Make sure your data lake is working for your business and see how to use tools like Apache Kafka to migrate from on-prem.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="199285" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/best-way-to-start-mnesia-in-elixir-phoenix-application/36531/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-199285" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="199285"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="199340" data-post-id="199340">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="vans163" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/vans163/120/13216_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  vans163
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Exadra37" data-post="12" data-topic="36531">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/exadra37/48/9183_2.png" class="avatar"> Exadra37:</div>
<blockquote>
<p>Maybe this article can help you understanding it better and how it fits with Event Sourcing:</p>
</blockquote>
</aside>
<pre data-code-wrap="elixir"><code class="lang-elixir">Event sourcing involves modeling the state changes made by applications as an immutable sequence or “log” 
of events. Instead of modifying the state of the application in-place, event sourcing involves storing the event 
that triggers the state change in an immutable log and modeling the state changes as responses to the events 
in the log. 
</code></pre>
<p>Ah so we get this naturally as a property of using an immutable actor model language, example updating the state of a process (gen_server), that is basically an immutable log of events via the mailbox.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Consider a Facebook-like social networking app (albeit a completely hypothetical one) that updates the 
profiles database when a user updates their Facebook profile. There are several applications that need to be 
notified when a user updates their profile — the search application so the user’s profile can be reindexed to be 
searchable on the changed attribute; the newsfeed application so the user’s connections can find out about 
the profile update; the data warehouse ETL application to load the latest profile data into the central data 
warehouse that powers various analytical queries and so on.
</code></pre>
<p>This is a disaster waiting to happen riddled with inconsistencies if say one of the nodes goes down now a bunch of events are missed.</p>
<p>Okay I get the idea now.  Event Sourcing is basically a event subscription to all incoming data.  But why not just do an event subscription to a distributed database instead, example like Cloudflare KV or Firestore? A users profile got updated? Instead of listening for the “UPDATE” event, the database itself eventually consists across all nodes, once each node gets the update that the profile got updated, the database generates an event and fires off notifications to each subscriber (connected user). The difference is if something goes down, when it comes back up it eventually consists, there is no “event to miss”, also stuff doesn’t go haywire if events come out of order.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="199340" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/best-way-to-start-mnesia-in-elixir-phoenix-application/36531/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-199340" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="199340"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="199343" data-post-id="199343">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Exadra37" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Exadra37/120/9183_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Exadra37
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="vans163" data-post="13" data-topic="36531">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/vans163/48/13216_2.png" class="avatar"> vans163:</div>
<blockquote>
<pre data-code-wrap="elixir"><code class="lang-elixir">Consider a Facebook-like social networking app (albeit a completely hypothetical one) that updates the 
profiles database when a user updates their Facebook profile. There are several applications that need to be 
notified when a user updates their profile — the search application so the user’s profile can be reindexed to be 
searchable on the changed attribute; the newsfeed application so the user’s connections can find out about 
the profile update; the data warehouse ETL application to load the latest profile data into the central data 
warehouse that powers various analytical queries and so on.
</code></pre>
<p>This is a disaster waiting to happen riddled with inconsistencies if say one of the nodes goes down now a bunch of events are missed.</p>
</blockquote>
</aside>
<p>When using Event Sourcing you need to persist the events, and you can do it with whatever database technology of your preference. Kafka is an excellent way to do it in an intermediate stage, and once it uses the RAFT consensus algorithm you will not have a disaster waiting to happen. I used the term intermediate stage, because normally events are consumed from Kafka and persisted in other databases, like Postgres.</p>
<p>You can take a look to the Elixir library <strong>Commande</strong>d by <a class="mention" href="/u/slashdotdash" rel="nofollow">@slashdotdash</a> that does Event Sourcing/CQRS in Elixir, and by default uses Postegres:</p>
<p><a href="https://github.com/commanded/commanded" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/commanded/commanded</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="199343" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/best-way-to-start-mnesia-in-elixir-phoenix-application/36531/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-199343" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="199343"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="199344" data-post-id="199344">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="slashdotdash" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/slashdotdash/120/3090_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  slashdotdash
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><em>Event sourcing</em> is persisting application state changes as domain specific, intention revealing events (e.g. <code>UserRegistered</code>). Current state is built by reducing the list or stream of events, similar to <a href="https://hexdocs.pm/elixir/Enum.html#reduce/3" rel="noopener nofollow ugc"><code>Enum.reduce/3</code></a> in Elixir. For event sourcing you ideally want to use a proper event store, such as <a href="https://www.eventstore.com/" rel="noopener nofollow ugc">EventStoreDB</a> or the Elixir <a href="https://github.com/commanded/eventstore" rel="noopener nofollow ugc">EventStore</a> library I wrote which uses Postgres for persistence.</p>
<p><em>Event streaming</em> is where events are published to interested subscribers for loosely-coupled processing, service integration, etc. Kafka is designed exactly for this. It would be more similar to Elixir’s <a href="https://hexdocs.pm/elixir/Registry.html#module-using-as-a-pubsub" rel="noopener nofollow ugc"><code>Registry</code> module when used for pub-sub</a> or using <code>Stream.each/2</code> or the <a href="https://github.com/dashbitco/broadway" rel="noopener nofollow ugc">Broadway library</a>. Often consumers use ack/nack to guarantee at-least-once message delivery so that they cannot miss any events. They may store their current processing position to a durable store so they can stop and resume processing safely. It’s possible to use change data capture to publish updates from a data store, such as table <code>UPDATE</code>s but unlike event sourcing these changes are not domain specific, but instead are general insert/update/delete operations.</p>
<p>There are two varieties of events used with event streaming: <em>Event Notification</em> and <em>Event-Carried State Transfer</em> (ECST). Event notification is used to indicate when something in an application has occured, such as a user registration, but the event contains minimal information (“thin” events). ECST is where more information about the current state is included in the event (“fat” events). You can also combine both event sourcing and event streaming by publishing domain events used for event sourcing to consumers for event streaming.</p>
<p>See <a href="https://martinfowler.com/articles/201701-event-driven.html" rel="noopener nofollow ugc">What do you mean by “Event-Driven”?</a> by Martin Fowler.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="199344" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/best-way-to-start-mnesia-in-elixir-phoenix-application/36531/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-199344" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="199344"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>