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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>All 3 ways are possible with ETS:</p>
<ul>
<li>read/write exclusively from the a single process</li>
<li>a single process handle all mutations, any processes can read</li>
<li>any processes can read and write</li>
</ul>
<p>I usually choose the middle ground so my ets table is always consistent and reads are parallel</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="212048" data-batch-url="/posts/batch_likers">
                        4
                      </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/genserver-performance-what-would-be-best-for-this-scenario/39237/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-212048" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="212048"
                     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="212535" data-post-id="212535">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="arpan" data-post="6" data-topic="39237">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arpan/48/17601_2.png" class="avatar"> arpan:</div>
<blockquote>
<p>Yea, currently the genserver crates the ETS table in its <code>init</code> callback like <code>:ets.new(@table_name, [:named_table, :set, :private])</code>.</p>
</blockquote>
</aside>
<aside class="quote no-group" data-username="arpan" data-post="6" data-topic="39237">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arpan/48/17601_2.png" class="avatar"> arpan:</div>
<blockquote>
<p>The below genserver is supervised by a <code>Pictionary.StoreSupervisor</code> so it will restart if it crashes for some reason.</p>
</blockquote>
</aside>
<p>I think you have a major problem waiting to bite you here. If your global GameStore process crashes, it’ll be restarted with a new pid that isn’t the owner of the private table. In fact the private table will automatically be deleted when the owner terminates, so your looking at dumping all your state in the event of a crash at the moment.</p>
<p>Personally I’d probably have the processes write to the ETS tables directly without a gatekeeper (making it public) or have a table per-game depending on what’s easiest for your application.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="212535" data-batch-url="/posts/batch_likers">
                        1
                      </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/genserver-performance-what-would-be-best-for-this-scenario/39237/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-212535" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="212535"
                     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="212539" data-post-id="212539">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="arpan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arpan/120/17601_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  arpan
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yea you are right, I haven’t thought about this.<br>
While it is unlikely for the game genserver to crash but it is not impossible.</p>
<p>I will reconsider my approach and maybe use public tables not tied to a genserver.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="212539" 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/genserver-performance-what-would-be-best-for-this-scenario/39237/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-212539" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="212539"
                     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="217779" data-post-id="217779">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="arpan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arpan/120/17601_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  arpan
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thank you guys, for all your suggestions I ended up spawning a new genserver for every game and store the individual game state in its own genserver, the genserver gets automatically shut down when the game ends.</p>
<p>This strategy ensures that a single genserver will not block processing updates to the games and</p>
<p>This has worked pretty well for me till now.</p>
<p>The game is complete check it out <a href="https://pictionary-game.netlify.app/" rel="noopener nofollow ugc">here</a>, I also wrote a detailed post about it <a href="https://forum.elixirforum.com/t/pictionary-a-multiplayer-drawing-and-guessing-game/40550" rel="nofollow">here</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="217779" data-batch-url="/posts/batch_likers">
                        3
                      </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/genserver-performance-what-would-be-best-for-this-scenario/39237/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-217779" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="217779"
                     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>