Skip to content

Commit b218e25

Browse files
committed
gutter example
1 parent 550ad38 commit b218e25

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

content/features/proxy/examples.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,94 @@ routes{
283283
default = route_direct{ child = "main" }
284284
}
285285
```
286+
287+
## Gutter failover for downed backends
288+
289+
This is an example for reducing the impact of a downed cache server.
290+
291+
For example, we have a list of three cache servers in a pool: a, b, c
292+
If cache node 'b' fails, clients will receive errors until the 'b' server
293+
is replaced.
294+
295+
With this example, we use the failover and ttl adjusting routes to allow
296+
temporarily rerouting cache requests while a server is failed. We do this first by "failing over" the request from the bad server to another server, with several optional approaches.
297+
298+
Next, if a request has failed over, we adjust the TTL of any 'set' commands
299+
to be lower. In this example we use five minutes. This prevents cache
300+
entires that have "failed over" from staying around for a long period of
301+
time, which can cause issues if server 'b' repeatedly fails.
302+
303+
The short cache time should allow a good hit rate for objects which are
304+
immediately being reused (ie; a user browsing around a website, or rate
305+
limit counters).
306+
307+
Q&A:
308+
- Do we need to copy all deletes to the gutter pool?
309+
- If a sufficiently low TTL is used and servers do not typically flap,
310+
no. Depending on your setup you might have to.
311+
- What about touch/gat commands?
312+
- This will depend on your needs. Please contact us if you have questions
313+
here.
314+
- How do we handle backends that are flapping (ie; sometimes timing out but
315+
not competely dead?
316+
- You can adjust "anti flap" settings, which will force a backend to
317+
stay down with a backoff algorithm:
318+
```lua
319+
settings{
320+
backend_flap_time = 30, -- stable for 30 seconds means not flapping
321+
backend_flap_backoff_ramp = 1.2, -- multipler for backoff wait time
322+
backend_flap_backoff_max = 3600, -- try at least once an hour
323+
}
324+
```
325+
326+
Gutter example config:
327+
328+
```lua
329+
local be_list = {
330+
"127.0.0.1:11214",
331+
"127.0.0.1:11215",
332+
"127.0.0.1:11216",
333+
}
334+
335+
pools{
336+
main = {
337+
backends = be_list,
338+
},
339+
-- for one example, we use a dedicated gutter pool. This server will be
340+
-- idle unless another server has failed or is being serviced.
341+
gutter = {
342+
backends = { "127.1.0.0.1:11311" }
343+
},
344+
-- in this example, we reuse the main set of backends, but change the key
345+
-- hashing seed so keys will map to the list of backends differently. This
346+
-- can minimize server maintenance while avoiding having idle "gutter"
347+
-- servers.
348+
-- The downside is keys may map to the same place, especially if you have
349+
-- a small list of backends. This can be partly mitigated by having
350+
-- multiple gutters with different seeds and failing several times.
351+
-- There may still be keys that fail but they will hopefully be few and
352+
-- the service can survive until the cache node is restored.
353+
--
354+
-- To use this, replace "gutter" below with "gutter_same"
355+
gutter_same = {
356+
options = { seed = "failover" },
357+
backends = be_list,
358+
},
359+
}
360+
361+
routes{
362+
cmap = {
363+
set = route_failover{
364+
children = { "main", route_ttl{ ttl = 300, child = "gutter" } },
365+
stats = true,
366+
miss = false, -- do not fail over on miss, only errors!
367+
-- do not shuffle the pool list, either!
368+
},
369+
-- repeat this for add, cas, ms, as necessary
370+
},
371+
-- we handle the rest of the commands with a default failover to gutter.
372+
default = route_failover{
373+
children = { "main", "gutter" },
374+
},
375+
}
376+
```

0 commit comments

Comments
 (0)