Redis RDB and Snapshotting Overview

Have a Database Problem? Speak with an Expert for Free
Get Started >>

Introduction

Redis RDB is a data structure used for capturing and storing snapshots of datasets. Specifically how it helps developers and DBAs with storage and retrieval efforts is worth knowing. On the flip side, there are also some disadvantages with Redis RDB. This article will review the basics of Redis RDB and snapshotting so that you can make an informed decision.

What is Redis RDB?

The RDB part of Redis RDB means “Redis Database File.” The default setting is in on position. The persistence mode form of this file is uncomplicated as it makes a point-in-time impression of a dataset by snapshotting it.

What are RDB pros?

There are several advantages of RDB. Here are the most common ones:

RDB’s density makes it great for archiving

Its compactness allows more data to be backed up. This is helpful for the restoration of a dataset from diverse versions. For example, if you used Redis RDB and snapshotting for your data on a daily basis for a month, and you had been regularly archiving your RDB files on the hour during that time, you’ll have many versions to select from in a restoration-needed situation.

Transferring is simple in disaster recovery circumstances

Since the RDB file is compact and in a single form, it’s easy to send to a data center that is distant. Redis RDB and snapshotting is more preferable than the alternative of using complicated file formats and multiple file configurations that may not be reliable in transport or retrieval.

Simple exertion of RDB raises performance

There’s very little effort required of RDB to automatically boost its performance. The only persist action of the Redis parent process is to make a fork system call for the child process.That’s it. No disk I/O by the parent.

The least bit of lag when large datasets are restarted

Between Append Only Files (AOF) Redis and Redis RDB, the latter starts a huge dataset faster. Writing is slower with AOF when compared to RDB. What’s more, with big write loads, the latency is more predictable with RDB.

What are RDB cons?

Here are a few disadvantages of Redis RDB.

Not recommended for emergency system failures

In Redis RDB and snapshotting, data loss might be substantial in situations where Redis immediately ceases to work. One example would be in the case of a power outage. There you’re likely going to lose the most recent few minutes of data. You can have many Save Points configurations to reduce the data loss though.

Typically, snapshotting in five-, ten-, or fifteen-minute increments is something you’ll want to do. The longer the time-space between snapshotting, the more data will be lost in case of a non-proper shutdown.

Slows the performance of the CPU

More fork() processes are necessary and this takes time. Meanwhile, as the child processes are being made, the system’s CPU tends to be bogged down.

What is Snapshotting?

Redis RDB snapshotting is described as saving the dataset on disk in a dump.rdb binary file. This consists of using snapshots to save the configuration, structure, and data for system failure restorations.

The condensed version of how snapshotting works is like this:

  • The parent process forks to start the child process.
  • A dataset is written by the child process, and now you have an RDB temporary file.
  • The old RDB file is superseded by the new RDB file.

The dataset can be saved in intervals based for the number of seconds you set along with the condition that it has a certain amount of changes before it’s saved. You also have the option to use the commands SAVE and BGSAVE, which are manual save methods. You’ll learn more about how to do this in the next section.

An advantage of using snapshots is that you don’t need to reboot the server to do snapshotting.

Redis RDB SAVE and BGSAVE command

Learn more about the functions of the SAVE and BGSAVE manual save commands.

What is RDB SAVE command?

When you want to make an RDB file of the Redis instance that contains the entire dataset all at the same time, use the SAVE command. A snapshot is taken creating a point-in-time data save.

NOTE: All other clients will be blocked; therefore, the SAVE command is not recommended for production environments. In special circumstances, you may want to use SAVE to create a dump.rdb file containing the most recent dataset.

What is RDB BGSAVE command.

The BGSAVE command is suited for production environments because, using the child process, it performs a background save of the dataset. When finished, there’s no need for the child process to continue, so it departs. All the while, client servicing isn’t blocked. Instead, it’s handled by the parent process.

Conclusion

This article explained the basics of Redis RDB and the snapshotting function it utilizes. RDB is effective for saving datasets in the event of a disaster so that recovery loss is minimal. Technical professionals have the option of configuring Redis for automatic saving or they can perform manual saves. RDB has many advantages; however, it’s also vital to be aware of any RDB limitations. That way, you can make provisions for them and use RDB in the most effective way.

Pilot the ObjectRocket Platform Free!

Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.

Get Started

Keep in the know!

Subscribe to our emails and we’ll let you know what’s going on at ObjectRocket. We hate spam and make it easy to unsubscribe.