GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add explanation for exponential backoff strategy with intended … · linuxgg/RxJava-Android-Samples@4b2180f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+19Lines changed: 19 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,30 @@ Cases demonstrated here:
100100
3. run a task constantly every 1s (same as above but there's no delay before the first task fires off)
101101
4. run a task constantly every 3s, but after running it 5 times, terminate automatically
102102

103+
### Exponential backoff
104+
105+
[Exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) is a strategy where based on feedback from a certain output we alter the rate of a process (usually reduce the number of retries or increase the wait time before retrying or re-executing a cetain process).
106+
107+
It makes far more sense with examples, and RxJava makes it (relatively) simple to achieve such a strategy.
108+
109+
#### retry (if error) with exponential backoff
110+
111+
Say you have a network failure. A sensible strategy would be to NOT keep retrying your network call every 1 second. It would be smart instead (nay... elegant!) to retry with increasing delays. So you try at second 1 to execute the network call, no dice? try after 10 seconds... negatory? try after 20 seconds, no cookie? try after 1 minute. If this thing is still failing, you got to give up on the network yo!
112+
113+
We simulate this behaviour using RxJava with the `retryWhen`
114+
115+
#### "repeat" with exponential backoff
116+
117+
Another variant of the exponential backoff strategy is to execute an operation repeatedly for a given number of times, but with delayed intervals. So you execute a certain operation 1 second from now, then you execute it again 10 seconds from now, then you execute the operation 20 seconds from now. After a grand total of 3 times you stop executing.
118+
119+
Simulating this behavior is actually way more simpler than the retry mechanism. You can use a variant of the `delay` operator to achieve this.
120+
103121
## Work in Progress:
104122

105123
Examples that I would like to have here, but haven't found the time yet to flush out.
106124

107125

126+
108127
### Pagination
109128

110129
a. Simple pagination

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.