Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende RDB Persistence | Advanced Features and Security
Introduction to Redis
course content

Contenido del Curso

Introduction to Redis

Introduction to Redis

1. Redis Fundamentals
2. The Essential Redis Commands
3. Data Types in Redis
4. Advanced Features and Security
5. Caching with Redis and Spring Boot

book
RDB Persistence

Although Redis is known as an in-memory data store, persistence allows data to be saved to disk to protect it from loss in case of server crashes. We'll explore the main persistence methods in Redis, their configurations, and practical applications.

RDB Persistence

RDB (Redis Database) creates a full snapshot of Redis data at specific points in time. This method is suitable for scenarios where speed is important and occasional data loss is acceptable.

As shown in the diagram, Redis periodically creates snapshots of data and saves them to disk. This helps minimize data loss and simplifies restoring the database state during a restart.

The frequency of snapshot creation can be configured in the redis.conf file.

To view and modify the redis.conf file on macOS:

To view the redis.conf file on Windows, you can open the directory where Redis is installed and access the redis.windows.conf file.

After opening the file, you'll see default snapshot settings like:

In the example above, Redis will save data based on the following criteria:

  • Every 900 seconds (15 minutes) if at least one key was modified;
  • Every 300 seconds (5 minutes) if at least 10 keys were modified;
  • Every 60 seconds if at least 10,000 keys were modified.

The frequency of saving data to disk determines the level of durability. For example, if data is saved every 5 minutes, and a failure occurs a few minutes after the last save, the data changes made during that period will be lost. Therefore, it's essential to carefully choose the save interval.

How it Works

Redis saves the database state to an .rdb file at the specified intervals. When the server is restarted, the data is restored from the last saved file.

Pros and Cons

RDB provides minimal impact on performance and uses a compact storage format. However, there is a risk of losing data added between snapshot intervals.

Manual Snapshot Creation

Users can also trigger an RDB snapshot using the SAVE command. This command blocks the Redis server, so it should be avoided. Instead, the BGSAVE command should be used, as it creates a child process to take a snapshot in the background.

1. What does the RDB method in Redis do?

2. What is an advantage of the RDB method?

What does the RDB method in Redis do?

What does the RDB method in Redis do?

Selecciona la respuesta correcta

What is an advantage of the RDB method?

What is an advantage of the RDB method?

Selecciona la respuesta correcta

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 5
We're sorry to hear that something went wrong. What happened?
some-alt