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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="quatermain" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/quatermain/120/21781_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  quatermain
                    <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>I added these values to telemetry and look on this dashboard. <img src="https://forum.elixirforum.com/images/emoji/apple/-1.png?v=15" title=":-1:" class="emoji" alt=":-1:" loading="lazy" width="20" height="20">  are our crashes, dots on timeline are releases.</p>
<p>All looks ok but:</p>
<ul>
<li>idle time is too big, not sure why or if it’s ok</li>
<li>total time - it’s too low, I expected it and sum of all other metrics</li>
</ul>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/3/8/38cd92b6b0a239e77b07c03545f1748d5807b445.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/38cd92b6b0a239e77b07c03545f1748d5807b445" title="CleanShot 2025-02-14 at 15.24.48@2x" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/3/8/38cd92b6b0a239e77b07c03545f1748d5807b445_2_188x600.jpeg" alt="CleanShot 2025-02-14 at 15.24.48@2x" data-base62-sha1="86vaXa0cZQPAVqGzI75Rgq4CZ8h" width="188" height="600" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/3/8/38cd92b6b0a239e77b07c03545f1748d5807b445_2_188x600.jpeg, https://forum.elixirforum.com/uploads/default/optimized/3X/3/8/38cd92b6b0a239e77b07c03545f1748d5807b445_2_282x900.jpeg 1.5x, https://forum.elixirforum.com/uploads/default/optimized/3X/3/8/38cd92b6b0a239e77b07c03545f1748d5807b445_2_376x1200.jpeg 2x" data-dominant-color="FCFCFC"><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 2025-02-14 at 15.24.48@2x</span><span class="informations">1200×3816 170 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="356351" 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/is-it-possible-to-debug-which-processes-and-code-places-are-using-the-db-pool-when-using-ecto/69373/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-356351" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="356351"
                     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="356352" data-post-id="356352">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="quatermain" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/quatermain/120/21781_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  quatermain
                    <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>I found nice explanation in other <a href="https://forum.elixirforum.com/t/what-causes-long-idle-time-in-ecto/31916/5" rel="nofollow">post</a></p>
<blockquote>
<p>tl;dr the <code>idle</code> time is how long a connection was ready and enqueued in the connection pool waiting to be checked out by a process. Therefore we can be happy to see it above <code>0</code>.</p>
</blockquote>
<blockquote>
<p><code>idle</code> time is recorded to show how busy or not busy the connection pool is. During connection pool IO overload the idle time will be as close to <code>0</code> as it can be, not counting message passing overhead, because then the connections are always in use by processes running transactions/queries. If a connection is not immediately available there is <code>queue</code> time that is the time between when the request for a connection was sent and when a connection becomes available. This time has latency impact for processes running transaction/queries as they need to wait for a connection before they can perform a query because the connection pool does not have enough capacity. <code>db</code> time is the time spent holding onto to the connection, i.e. time spent actually using the database. Therefore the latency for the calling process is <code>queue</code> time plus <code>db</code> time.</p>
</blockquote>
<blockquote>
<p>When the connection pool has extra capacity the <code>queue</code> time should always be as close <code>0</code> as it can be because a connection is available when requested. Only once the transaction rate is beyond what the connection pool can handle does the <code>queue</code> time increase. However that is a little late because latency is already impacted once it goes above ~0. <code>idle</code> allows us to see how close to having <code>queue</code> time, the higher the <code>idle</code> time the more capacity we have in the connection pool.</p>
</blockquote>
<blockquote>
<p>Perhaps a clearer way to think about it is if you see an <code>idle</code> timeout of 100ms, that means we could have run 100ms worth of <code>db</code> time on that connection since the last time that connection was used. So to be as efficient as possible on resource we would want <code>queue</code> and <code>idle</code> to both be near <code>0</code>. However because of the latency impact of <code>queue</code>, we should be happy to sacrifice some <code>idle</code> time to keep <code>queue</code> at <code>0</code> when possible.</p>
</blockquote>
<blockquote>
<p>Of course we can make <code>queue</code> time move to <code>0</code> by increasing the pool size. However if the pool is too large <code>db</code> time will suffer as the database becomes the bottleneck instead of the connection pool.</p>
</blockquote>
<blockquote>
<p>If the application is not sending any queries for a prologued interval and then sends a query why is the <code>idle</code> time capped? This occurs because idle connections periodically send a ping message to the database to try to ensure connectivity so that the connections are ready and live when needed, and we don’t need to attempt to connect when a query comes in. If we needed to reconnect then the database handshake time would add latency to the transaction/query being processed. The ping message resets the idle timer because an individual connection is unavailable from the pool during a ping. If it was left in the pool the connection would be blocked waiting for a pong response and incur a wait on the connection like just like a handshake. Pings are randomized to prevent all connection becoming busy at the same time.</p>
</blockquote>
<p>So basically it can means that we have too big pool size and we fire too much pressure on DB and our connection pool basically do not handle pressure correctly.<br>
That can explain peaks where we have more queries. Like here</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/e/8/e8cc4a440920057c8ea192c685768653d6e347d0.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/e8cc4a440920057c8ea192c685768653d6e347d0" title="CleanShot 2025-02-14 at 15.42.43@2x" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/e/8/e8cc4a440920057c8ea192c685768653d6e347d0_2_387x600.jpeg" alt="CleanShot 2025-02-14 at 15.42.43@2x" data-base62-sha1="xdqsGujgfVtpdBRf8CY1uOD8s1O" width="387" height="600" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/e/8/e8cc4a440920057c8ea192c685768653d6e347d0_2_387x600.jpeg, https://forum.elixirforum.com/uploads/default/optimized/3X/e/8/e8cc4a440920057c8ea192c685768653d6e347d0_2_580x900.jpeg 1.5x, https://forum.elixirforum.com/uploads/default/optimized/3X/e/8/e8cc4a440920057c8ea192c685768653d6e347d0_2_774x1200.jpeg 2x" data-dominant-color="F7F8F9"><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 2025-02-14 at 15.42.43@2x</span><span class="informations">1164×1802 76.8 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>
<p>When we had 444k ecto queries and 651 DBConnection.ConnectionError timeouts.  And idle time was 1sec for 95P or 305ms mean. Queue time was 6ms.</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/5/3/5387065c3ac76908aef447ad1f7fc4d141a00926.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/5387065c3ac76908aef447ad1f7fc4d141a00926" title="CleanShot 2025-02-14 at 15.43.13@2x" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/5/3/5387065c3ac76908aef447ad1f7fc4d141a00926_2_551x600.jpeg" alt="CleanShot 2025-02-14 at 15.43.13@2x" data-base62-sha1="bUUV0l24zT1zs0LjPTMosakUvyK" width="551" height="600" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/5/3/5387065c3ac76908aef447ad1f7fc4d141a00926_2_551x600.jpeg, https://forum.elixirforum.com/uploads/default/optimized/3X/5/3/5387065c3ac76908aef447ad1f7fc4d141a00926_2_826x900.jpeg 1.5x, https://forum.elixirforum.com/uploads/default/original/3X/5/3/5387065c3ac76908aef447ad1f7fc4d141a00926.jpeg 2x" data-dominant-color="F7F7F8"><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 2025-02-14 at 15.43.13@2x</span><span class="informations">1032×1122 47.1 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>
<p>So if i’m not wrong, reducing pool size we should move pressure from DB to our DBConnection Pool (“Ecto”) which should handle pressure more effective. Right?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="356352" 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/is-it-possible-to-debug-which-processes-and-code-places-are-using-the-db-pool-when-using-ecto/69373/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-356352" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="356352"
                     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>