0
0
Redisquery~20 mins

Pub/sub vs streams comparison in Redis - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Pub/Sub and Streams Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference in message delivery guarantees
Which statement correctly describes the message delivery guarantee difference between Redis Pub/Sub and Redis Streams?
APub/Sub guarantees message delivery to all subscribers even if they are offline; Streams do not.
BBoth Pub/Sub and Streams guarantee message delivery only if consumers are online.
CStreams guarantee message delivery to consumers even if they are offline; Pub/Sub does not.
DNeither Pub/Sub nor Streams guarantee message delivery under any circumstances.
Attempts:
2 left
💡 Hint
Think about what happens if a subscriber is offline when a message is published.
query_result
intermediate
2:00remaining
Output of a Pub/Sub message reception
Given a Redis Pub/Sub subscriber listening on channel 'news', what will be the output if a publisher sends the message 'Hello' to 'news' while the subscriber is connected?
Redis
SUBSCRIBE news
PUBLISH news Hello
AThe subscriber receives and prints: 'Hello'
BThe subscriber receives and prints: 'message news Hello'
CThe subscriber receives no message because Pub/Sub does not deliver messages
DThe subscriber receives an error message
Attempts:
2 left
💡 Hint
Consider the format Redis uses to notify subscribers.
📝 Syntax
advanced
2:00remaining
Correct command to add an entry to a Redis Stream
Which Redis command correctly adds a new entry with field 'user' and value 'alice' to a stream named 'mystream'?
AAPPEND mystream user alice
BADD mystream user alice
CXADD mystream user alice *
DXADD mystream * user alice
Attempts:
2 left
💡 Hint
The XADD command uses '*' to auto-generate the entry ID.
optimization
advanced
2:00remaining
Choosing between Pub/Sub and Streams for offline consumers
You want to build a chat application where users can receive messages sent while they were offline. Which Redis feature should you choose for message delivery and why?
AUse Streams because it allows consumers to read messages they missed while offline.
BUse Pub/Sub because it stores messages for offline users automatically.
CUse Pub/Sub because it supports message persistence by default.
DUse neither because Redis does not support offline message delivery.
Attempts:
2 left
💡 Hint
Think about which feature stores messages for later reading.
🔧 Debug
expert
2:00remaining
Why does a Redis Pub/Sub subscriber miss messages?
A Redis Pub/Sub subscriber sometimes misses messages published to a channel. What is the most likely reason?
AThe subscriber was disconnected or offline when the messages were published.
BRedis Pub/Sub queues messages for offline subscribers but the queue is full.
CThe subscriber did not acknowledge the messages, so Redis dropped them.
DRedis Pub/Sub requires explicit message commits to deliver messages.
Attempts:
2 left
💡 Hint
Consider how Pub/Sub handles offline subscribers.