Advanced

Bash script to Redis SCAN e.g. for pruning, migration and archiving

Posted by evan_summers on · Post a comment
https://github.com/evanx/bashbin; By Evan Summers
Mail this story
Print this story

We document a bash script for Redis SCAN, which tries not to overwhelm our production system. This is useful for pruning, migrating keys, archiving content to disk e.g. into a pre-cache to be served directly by Nginx try_files

We should not use "redis-cli keys" - especially not on large Redis keyspaces on production machines - as this can block Redis for a number of seconds.

We document a template bash script for Redis SCAN on production machines. It ensures we don't overwhelm the system, by sleeping, especially while the load is too high.

This is useful for pruning (e.g. deleting keys according to their TTL or other logic); migrating keys to another Redis instance; archiving Redis content to a disk-based database; or extracting content to a disk pre-cache to be served directly by Nginx try_files, e.g. in perpetuity after keys have expired, or to improve resilience e.g. when our service is down or being restarted.

See https://github.com/evanx/bashbin/blob/master/redis-scan/read...

Full Story

  Nav
» Read more about:

» Get new stories by e-mail: nightly or as they are published

« Return to the newswire homepage

  Related stories
» More like this

Comments

No comments yet. Be the first.

Post a comment

A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.

Your message:
|||||
10
Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help

Sign up and post (it is free)  or  Log in and post