You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: using-gatewayd/clients.md
+50Lines changed: 50 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -40,3 +40,53 @@ You have the option to set deadlines on send and receive calls to the database s
40
40
## Receive timeout
41
41
42
42
Since setting receive deadline kills the connection, the `receiveTimeout` property is introduced to stop the receive functionfrom blocking the connection and waiting forever. The current value is zero, which means that it behaves like before, but one can set it to a duration string value.
43
+
44
+
## Dial timeout
45
+
46
+
The dial timeout is the amount of time the client should wait before giving up on dialing the database. The default value is `60s`. Setting it to `0s` disables the dial timeout.
47
+
48
+
## Retries and backoff
49
+
50
+
The first attempt to connect to the database server is made when the client is created, which happens instantly when GatewayD starts. However, if the first attempt fails, the client will retry the connection. The default number of retries is `3`, which means that the client will retry the connection three times before giving up. Setting it to `0` disables the retry mechanism. The client can also backoff before retrying the connection. The backoff duration is set to `1s` by default and `0s` disables the backoff mechanism. The backoff multiplier is set to `2` by default and `0` disables the backoff. The backoff multiplier is applied to the backoff duration. The backoff duration is capped at `60s` by default and the max retry is capped at `10` by default. Setting `disableBackoffCaps` to `true` disables the backoff and retry caps.
51
+
52
+
{: .note }
53
+
> The first attempt to connect to the database server is counted as a retry, hence the three retries are actually four attempts (one instant attempt and three retry attempts), and the backoff duration is applied to the second attempt and so on.
54
+
55
+
The backoff duration is calculated by multiplying the backoff duration by the backoff multiplier raised to the power of the number of retries. For example, if the backoff duration is 1 second and the backoff multiplier is 2, the backoff duration will be 1 second, 2 seconds, 4 seconds, 8 seconds, etc. The backoff duration is capped at 1 minute and the backoff multiplier is capped at 10, so the backoff duration will be 1 minute after 6 retries. The backoff multiplier is capped at 10 to prevent the backoff duration from growing too quickly, unless the backoff caps are disabled. The following is the formula for calculating the backoff duration:
Considering the default values, the backoff duration will be calculated as follows:
62
+
63
+
```text
64
+
1 * 2 ^ 1 = 2 seconds
65
+
1 * 2 ^ 2 = 4 seconds
66
+
1 * 2 ^ 3 = 8 seconds
67
+
```
68
+
69
+
If the retries are set to `11`, the backoff duration from the fourth attempt will be calculated as follows, which is capped at 1 minute and 10 retries are made:
70
+
71
+
```text
72
+
1 * 2 ^ 4 = 16 seconds
73
+
1 * 2 ^ 5 = 32 seconds
74
+
1 * 2 ^ 6 = 1 minute
75
+
1 * 2 ^ 7 = 1 minute (capped)
76
+
1 * 2 ^ 8 = 1 minute (capped)
77
+
1 * 2 ^ 9 = 1 minute (capped)
78
+
1 * 2 ^ 10 = 1 minute (capped)
79
+
```
80
+
81
+
And if the backoff caps are disabled, the uncapped backoff duration for the fourth attempt will be calculated as follows:
Copy file name to clipboardExpand all lines: using-gatewayd/global-configuration/clients.md
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,10 @@ GatewayD supports multiple client configurations. Each client in each configurat
25
25
| receiveTimeout | duration (string) | 0s | Valid duration strings | The amount of time the client should wait before giving up on call to receive. `0s` disables receive timeout. |
26
26
| sendDeadline | duration (string) | 0s | Valid duration strings | The amount of time the client should wait before giving up on call to send. `0s` disables send deadline. |
27
27
| dialTimeout | duration (string) | 60s | Valid duration strings | The amount of time the client should wait before giving up on dialing the database. `0s` disables dial timeout. |
28
+
| retries | number | 3 | Positive integers | The amount of times to retry a failed connection. `0` means no retry. |
29
+
| backoff | duration (string) | 1s | Valid duration strings | The amount of time to wait before retrying a failed connection. `0s` means no backoff. |
30
+
| backoffMultiplier | number | 2 | Positive integers | The multiplier to apply to the backoff duration. `0` means no backoff. |
31
+
| disableBackoffCaps | boolean | False | True, False | Whether to disable the backoff caps for backoff multiplier and backoff duration. |
28
32
29
33
```yaml
30
34
clients:
@@ -38,4 +42,9 @@ clients:
38
42
receiveTimeout: 0s# duration, 0ms/0s means no timeout
39
43
sendDeadline: 0s# duration, 0ms/0s means no deadline
40
44
dialTimeout: 60s# duration, 0ms/0s means no timeout
0 commit comments