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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="scottmessinger" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/scottmessinger/120/34246_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  scottmessinger
                    <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>Here’s a graph showing the memory reported by AWS. You can see when we switched back to Bandit around 8:30pm.</p>
<p>For our use case (predominantly WS messages served over http behind an AWS ALB inside AWS ECS), it appears we’re seeing 1/2 the memory usage with cowboy.</p>
<p>We look forward to returning to Bandit when the memory is more comparable!</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/0/5/05e7d1066e409658b6cffbdd95f769b14786b29c.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/05e7d1066e409658b6cffbdd95f769b14786b29c" title="CleanShot 2024-02-23 at 10.20.19" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/0/5/05e7d1066e409658b6cffbdd95f769b14786b29c_2_493x600.jpeg" alt="CleanShot 2024-02-23 at 10.20.19" data-base62-sha1="Qf3dAwYBVnTGC4haaRoT4xp0NS" width="493" height="600" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/0/5/05e7d1066e409658b6cffbdd95f769b14786b29c_2_493x600.jpeg, https://forum.elixirforum.com/uploads/default/optimized/3X/0/5/05e7d1066e409658b6cffbdd95f769b14786b29c_2_739x900.jpeg 1.5x, https://forum.elixirforum.com/uploads/default/optimized/3X/0/5/05e7d1066e409658b6cffbdd95f769b14786b29c_2_986x1200.jpeg 2x" data-dominant-color="F3F5F6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">CleanShot 2024-02-23 at 10.20.19</span><span class="informations">1200×1460 69.2 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318860" 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/how-to-troubleshoot-increased-memory-usage-in-bandit/61825/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-318860" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318860"
                     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="318865" data-post-id="318865">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tj0" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tj0
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>ok, I’m going to have to ask a really dumb question because I don’t know what tool you’re using.</p>
<p>Is the memory utilization:</p>
<ul>
<li>RSS  =&gt; resident memory is definitely used.</li>
<li>RSS + shared  =&gt; this would be really close to total memory used</li>
<li>RSS + shared + buffs/cache =&gt; now we’re getting into a bit of weird territory</li>
</ul>
<p>If bandit is increasing the buff/cache memory, then it is not a real memory increase. This is some weird artifact of hibernate or something. There is probably a tool to find out the actual used memory, but I’ve forgotten what it is.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">$ free
               total        used        free      shared  buff/cache   available
Mem:        16162188     7218888     4205420     1177868     6264756     8943300
Swap:       16777212      260952    16516260

</code></pre>
<p>I compared the memory based on the processes in BEAM via live_dashboard and they looked comparable between cowboy and bandit. Perhaps it’s due to the server being idle, etc. not doing the thing that increases the memory, etc.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318865" 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/how-to-troubleshoot-increased-memory-usage-in-bandit/61825/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-318865" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318865"
                     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="318870" data-post-id="318870">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mtrudel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mtrudel/120/28190_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mtrudel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Bandit</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="scottmessinger" data-post="12" data-topic="61825">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/scottmessinger/48/34246_2.png" class="avatar"> scottmessinger:</div>
<blockquote>
<p>ou can see when we switched back to Bandit around 8:30pm.</p>
</blockquote>
</aside>
<p>I assume you mean ‘switched back to Cowboy’, since your memory usage decreased there?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318870" 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/how-to-troubleshoot-increased-memory-usage-in-bandit/61825/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-318870" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318870"
                     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="318871" data-post-id="318871">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mtrudel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mtrudel/120/28190_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mtrudel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Bandit</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>A couple of things that would greatly help:</p>
<ul>
<li>Would you be able to disable websocket compression in Bandit and see if that helps? The relevant option is</li>
</ul>
<pre data-code-wrap="elixir"><code class="lang-elixir">config MyAppWeb,
   http: [
     ...
     websocket_options: [compress: false]
   ]
</code></pre>
<ul>
<li>If you have console access to your server, running the following would provide a snapshot of a random process’ state; helpful in seeing where you may be using all that memory:</li>
</ul>
<pre data-code-wrap="elixir"><code class="lang-elixir">{:ok, pid} = Bandit.PhoenixAdapter.bandit_pid(YourAppWeb.Endpoint)
{:ok, connection_pids} = ThousandIsland.connection_pids(pid)
# You may need to turn the following a few times until you get one back that has `handler_module: Bandit.WebSocket.Handler` listed in its state
:sys.get_state(Enum.random(connection_pids)) 
</code></pre>
<p>This will be a raw dump of everything your socket process has in state; feel free to redact as needed (you’ll probably want to elide the whole <code>elem(1).connection.websock_state</code>; that’s all of your Phoenix state and should be identical between Bandit and Cowboy). Also, if you want to DM me here to further limit any exposure, that’s fine too.</p>
<p>Looking forward to hunting this down!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318871" data-batch-url="/posts/batch_likers">
                        5
                      </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/how-to-troubleshoot-increased-memory-usage-in-bandit/61825/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-318871" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318871"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="318899" data-post-id="318899">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>At Supabase we have experienced <code>:long_schedule</code> warnings of over 30s at our production load for our logging service that would then result in a subsequent crash. I have not yet had the time to open up an issue in the Bandit repo yet and put together a case for it, but the changes that made the warnings go away was the cowboy revert <a href="https://github.com/Logflare/logflare/compare/v1.5.22...v1.5.32" rel="noopener nofollow ugc">here</a>, which makes me feel that Bandit still has some way to go in terms of performance at scale…</p>
<p>Unsure if my particular case is related to the memory issues others have also experienced as per this thread, but just putting it out there in case anyone else has a similar experience.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318899" 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/how-to-troubleshoot-increased-memory-usage-in-bandit/61825/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-318899" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318899"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="318913" data-post-id="318913">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mtrudel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mtrudel/120/28190_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mtrudel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Bandit</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="ziinc" data-post="16" data-topic="61825">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ziinc/48/40228_2.png" class="avatar"> ziinc:</div>
<blockquote>
<p>Unsure if my particular case is related to the memory issues others have also experienced as per this thread, but just putting it out there in case anyone else has a similar experience.</p>
</blockquote>
</aside>
<p>I’d suspect it’s the same issue that <a class="mention" href="/u/jjcarstens" rel="nofollow">@jjcarstens</a> et al saw last week, and which is fixed in Thousand Island 1.3.3+. If you’re able, give Bandit a spin with Thousand Island bumped appropriately and see if it fixes your issue; I’d love to get as many data points as possible for perf issues like this!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318913" data-batch-url="/posts/batch_likers">
                        5
                      </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/how-to-troubleshoot-increased-memory-usage-in-bandit/61825/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-318913" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318913"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="319269" data-post-id="319269">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="scottmessinger" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/scottmessinger/120/34246_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  scottmessinger
                    <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><img src="https://forum.elixirforum.com/images/emoji/apple/man_facepalming.png?v=15" title=":man_facepalming:" class="emoji" alt=":man_facepalming:" loading="lazy" width="20" height="20"> Yup – I had meant cowboy.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="319269" 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/how-to-troubleshoot-increased-memory-usage-in-bandit/61825/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-319269" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="319269"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="320222" data-post-id="320222">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mtrudel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mtrudel/120/28190_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mtrudel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Bandit</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I think we’ve got a fix.</p>
<p>Anyone able to try the branch referenced <a href="https://github.com/mtrudel/bandit/issues/313#issuecomment-1979693055" rel="noopener nofollow ugc">here</a>, I’d love to see more evidence that this resolves the issue. The main wrinkle in this solution is that GCing every request is using a sledgehammer on a nail; I’m hoping that I’ll be able to pull the mitigation back to something more reasonable</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="320222" 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/how-to-troubleshoot-increased-memory-usage-in-bandit/61825/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-320222" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="320222"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="320507" data-post-id="320507">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mtrudel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mtrudel/120/28190_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mtrudel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Bandit</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/scottmessinger" rel="nofollow">@scottmessinger</a> and others; 1.3.0 just went out with a fix for the long-standing issue of increasing memory use (which wasn’t really a memory issue so much as it was an issue with how memory use is reported, but anyway), along with a few other fixes. See <a href="https://github.com/mtrudel/bandit/blob/main/CHANGELOG.md" rel="noopener nofollow ugc">CHANGELOG</a> as always. Hopefully this fixes your issue; please report back if so as I’d love to have more evidence that we’ve finally licked this.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="320507" data-batch-url="/posts/batch_likers">
                        9
                      </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/how-to-troubleshoot-increased-memory-usage-in-bandit/61825/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-320507" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="320507"
                     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>