123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <meta name="generator" content="Doxygen 1.8.17"/>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <title>GRPC C++: GRPC Connection Backoff Protocol</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="dynsections.js"></script>
- <link href="search/search.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="search/searchdata.js"></script>
- <script type="text/javascript" src="search/search.js"></script>
- <link href="doxygen.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
- <div id="titlearea">
- <table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 56px;">
- <td id="projectalign" style="padding-left: 0.5em;">
- <div id="projectname">GRPC C++
-  <span id="projectnumber">1.36.1</span>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.17 -->
- <script type="text/javascript">
- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
- var searchBox = new SearchBox("searchBox", "search",false,'Search');
- /* @license-end */
- </script>
- <script type="text/javascript" src="menudata.js"></script>
- <script type="text/javascript" src="menu.js"></script>
- <script type="text/javascript">
- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
- $(function() {
- initMenu('',true,false,'search.php','Search');
- $(document).ready(function() { init_search(); });
- });
- /* @license-end */</script>
- <div id="main-nav"></div>
- <!-- window showing the filter options -->
- <div id="MSearchSelectWindow"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- onkeydown="return searchBox.OnSearchSelectKey(event)">
- </div>
- <!-- iframe showing the search results (closed by default) -->
- <div id="MSearchResultsWindow">
- <iframe src="javascript:void(0)" frameborder="0"
- name="MSearchResults" id="MSearchResults">
- </iframe>
- </div>
- </div><!-- top -->
- <div class="PageDoc"><div class="header">
- <div class="headertitle">
- <div class="title">GRPC Connection Backoff Protocol </div> </div>
- </div><!--header-->
- <div class="contents">
- <div class="textblock"><p>When we do a connection to a backend which fails, it is typically desirable to not retry immediately (to avoid flooding the network or the server with requests) and instead do some form of exponential backoff.</p>
- <p>We have several parameters:</p><ol type="1">
- <li>INITIAL_BACKOFF (how long to wait after the first failure before retrying)</li>
- </ol>
- <ol type="1">
- <li>MULTIPLIER (factor with which to multiply backoff after a failed retry)</li>
- </ol>
- <ol type="1">
- <li>JITTER (by how much to randomize backoffs).</li>
- </ol>
- <ol type="1">
- <li>MAX_BACKOFF (upper bound on backoff)</li>
- </ol>
- <ol type="1">
- <li>MIN_CONNECT_TIMEOUT (minimum time we're willing to give a connection to complete)</li>
- </ol>
- <h1><a class="anchor" id="autotoc_md77"></a>
- Proposed Backoff Algorithm</h1>
- <p>Exponentially back off the start time of connection attempts up to a limit of MAX_BACKOFF, with jitter.</p>
- <div class="fragment"><div class="line">ConnectWithBackoff()</div>
- <div class="line"> current_backoff = INITIAL_BACKOFF</div>
- <div class="line"> current_deadline = now() + INITIAL_BACKOFF</div>
- <div class="line"> while (TryConnect(Max(current_deadline, now() + MIN_CONNECT_TIMEOUT))</div>
- <div class="line"> != SUCCESS)</div>
- <div class="line"> SleepUntil(current_deadline)</div>
- <div class="line"> current_backoff = Min(current_backoff * MULTIPLIER, MAX_BACKOFF)</div>
- <div class="line"> current_deadline = now() + current_backoff +</div>
- <div class="line"> UniformRandom(-JITTER * current_backoff, JITTER * current_backoff)</div>
- </div><!-- fragment --><p>With specific parameters of MIN_CONNECT_TIMEOUT = 20 seconds INITIAL_BACKOFF = 1 second MULTIPLIER = 1.6 MAX_BACKOFF = 120 seconds JITTER = 0.2</p>
- <p>Implementations with pressing concerns (such as minimizing the number of wakeups on a mobile phone) may wish to use a different algorithm, and in particular different jitter logic.</p>
- <p>Alternate implementations must ensure that connection backoffs started at the same time disperse, and must not attempt connections substantially more often than the above algorithm.</p>
- <h1><a class="anchor" id="autotoc_md78"></a>
- Reset Backoff</h1>
- <p>The back off should be reset to INITIAL_BACKOFF at some time point, so that the reconnecting behavior is consistent no matter the connection is a newly started one or a previously disconnected one.</p>
- <p>We choose to reset the Backoff when the SETTINGS frame is received, at that time point, we know for sure that this connection was accepted by the server. </p>
- </div></div><!-- contents -->
- </div><!-- PageDoc -->
- <!-- start footer part -->
- <hr class="footer"/><address class="footer"><small>
- Generated on Wed Mar 3 2021 19:17:22 for GRPC C++ by  <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/>
- </a> 1.8.17
- </small></address>
- </body>
- </html>
|