Bird
Raised Fist0
Redisquery~20 mins

AOF (Append Only File) in Redis - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Redis AOF Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary purpose of Redis AOF?

Redis uses AOF (Append Only File) for a specific reason related to data persistence. What is the main goal of using AOF in Redis?

ATo compress the database files to save disk space
BTo log every write operation received by the server for data recovery
CTo replicate data to other Redis servers in real-time
DTo store only the latest snapshot of the database
Attempts:
2 left
💡 Hint

Think about how Redis can recover data after a restart.

❓ query_result
intermediate
2:00remaining
What happens if Redis AOF file is corrupted?

Consider Redis configured to use AOF persistence. If the AOF file becomes corrupted, what will Redis do when it tries to load the data on startup?

ARedis will refuse to start and show an error about AOF corruption
BRedis will automatically fix the corrupted AOF file and start normally
CRedis will ignore the AOF file and start with an empty dataset
DRedis will load the last RDB snapshot instead of the AOF file
Attempts:
2 left
💡 Hint

Think about Redis's safety checks when loading persistence files.

📝 Syntax
advanced
2:00remaining
Which Redis configuration line correctly enables AOF with fsync every second?

Choose the correct Redis configuration line to enable AOF persistence and set fsync policy to sync every second.

Aappendonly yes\naof-fsync everysec
Bappendonly yes\naof-fsync no
Cappendonly no\naof-fsync everysec
Dappendonly yes\naof-fsync always
Attempts:
2 left
💡 Hint

Check the exact spelling and values for enabling AOF and fsync policy.

❓ optimization
advanced
2:00remaining
How to reduce AOF file size without losing data?

You notice your Redis AOF file is growing very large. Which method safely reduces the AOF file size while preserving all data?

ADisable AOF and rely only on RDB snapshots
BDelete the AOF file and restart Redis to create a new one
CRun the BGREWRITEAOF command to rewrite the AOF file compactly
DManually edit the AOF file to remove old commands
Attempts:
2 left
💡 Hint

Think about a Redis command designed to optimize AOF files safely.

🔧 Debug
expert
2:00remaining
Why does Redis AOF rewrite sometimes fail to reduce file size?

After running BGREWRITEAOF, you notice the AOF file size did not decrease as expected. What is the most likely reason?

AThe AOF file was corrupted before rewriting
BRedis was not restarted after the rewrite command
CBGREWRITEAOF only works if appendonly is set to no
DThe dataset has many keys with large values that cannot be further compressed
Attempts:
2 left
💡 Hint

Consider what affects the size of the rewritten AOF file.

Practice

(1/5)
1.

What is the main purpose of Redis AOF (Append Only File)?

easy
A. To save every write operation for data recovery
B. To compress data for faster network transfer
C. To create backups only once a day
D. To store data in a binary format

Solution

  1. Step 1: Understand AOF functionality

    AOF logs every write command to a file to ensure data can be recovered after a crash.
  2. Step 2: Compare options with AOF purpose

    Only To save every write operation for data recovery correctly describes saving every write operation for recovery.
  3. Final Answer:

    To save every write operation for data recovery -> Option A
  4. Quick Check:

    AOF saves writes = B [OK]
Hint: AOF logs all writes to recover data after crashes [OK]
Common Mistakes:
  • Thinking AOF compresses data
  • Confusing AOF with snapshot backups
  • Believing AOF stores data in binary
2.

Which of the following is the correct Redis configuration directive to enable AOF persistence?

?
easy
A. enable_aof on
B. appendonly yes
C. persistence append
D. aof_enable true

Solution

  1. Step 1: Recall Redis config syntax for AOF

    The correct directive to enable AOF is appendonly yes.
  2. Step 2: Check other options for correctness

    Options A, B, and C are not valid Redis config directives.
  3. Final Answer:

    appendonly yes -> Option B
  4. Quick Check:

    Enable AOF with appendonly yes [OK]
Hint: Remember: 'appendonly yes' enables AOF in redis.conf [OK]
Common Mistakes:
  • Using incorrect directive names
  • Confusing AOF with RDB snapshot settings
  • Using boolean words like true/on instead of yes
3.

Given the Redis AOF configuration appendfsync everysec, what is the expected behavior?

medium
A. Redis writes AOF data to disk every second
B. Redis never writes AOF data to disk
C. Redis writes every command to disk immediately
D. Redis writes AOF data only on shutdown

Solution

  1. Step 1: Understand appendfsync everysec meaning

    This setting tells Redis to sync AOF data to disk once every second.
  2. Step 2: Compare with other options

    Redis writes every command to disk immediately means immediate write (appendfsync always), B and D are incorrect behaviors.
  3. Final Answer:

    Redis writes AOF data to disk every second -> Option A
  4. Quick Check:

    everysec means sync once per second [OK]
Hint: everysec means disk sync once per second, not instantly [OK]
Common Mistakes:
  • Confusing everysec with always
  • Thinking it never writes to disk
  • Assuming writes happen only on shutdown
4.

Identify the error in this Redis AOF configuration snippet:

appendonly yes
appendfsync everyminute
medium
A. appendonly should be no
B. appendfsync must be set to 'never'
C. appendfsync value 'everyminute' is invalid
D. No error, configuration is valid

Solution

  1. Step 1: Check valid appendfsync values

    Valid values are 'always', 'everysec', or 'no'. 'everyminute' is not valid.
  2. Step 2: Verify appendonly setting

    appendonly yes is correct to enable AOF.
  3. Final Answer:

    appendfsync value 'everyminute' is invalid -> Option C
  4. Quick Check:

    appendfsync accepts only always, everysec, or no [OK]
Hint: appendfsync only accepts always, everysec, or no [OK]
Common Mistakes:
  • Assuming 'everyminute' is valid
  • Thinking appendonly yes is wrong
  • Believing appendfsync must be 'never'
5.

You want to ensure Redis AOF persistence is safe but also fast. Which configuration balances durability and performance best?

appendonly yes
appendfsync everysec
hard
A. appendonly no and appendfsync no
B. appendonly no and appendfsync always
C. appendonly yes and appendfsync no
D. appendonly yes and appendfsync everysec

Solution

  1. Step 1: Understand durability vs performance

    appendonly yes enables AOF persistence; appendfsync everysec syncs data every second, balancing safety and speed.
  2. Step 2: Evaluate other options

    Options B and D disable AOF, losing durability; appendonly yes and appendfsync no disables syncing, risking data loss.
  3. Final Answer:

    appendonly yes and appendfsync everysec -> Option D
  4. Quick Check:

    Enable AOF with everysec sync for balance [OK]
Hint: Use appendonly yes with everysec for good speed and safety [OK]
Common Mistakes:
  • Disabling AOF for speed
  • Using appendfsync no risking data loss
  • Choosing appendfsync always causing slow writes
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard