0
0
Djangoframework~20 mins

Redis as message broker in Django - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Message Broker Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when a Django app publishes a message to Redis?

Consider a Django app configured to use Redis as a message broker. When the app publishes a message to a Redis channel, what is the expected behavior?

AThe message is sent to all clients subscribed to that Redis channel immediately.
BThe message is stored in Redis and delivered only when the subscriber requests it.
CThe message is saved in a Redis list and requires manual polling to retrieve.
DThe message is lost if no subscriber is connected at the time of publishing.
Attempts:
2 left
💡 Hint

Think about how Redis Pub/Sub works with subscribers.

📝 Syntax
intermediate
2:00remaining
Identify the correct Redis publish command in Django using redis-py

Which of the following code snippets correctly publishes a message to a Redis channel named 'notifications' using the redis-py client in Django?

Aredis_client.publish_message('notifications', 'New user signed up')
Bredis_client.send('notifications', 'New user signed up')
Credis_client.push('notifications', 'New user signed up')
Dredis_client.publish('notifications', 'New user signed up')
Attempts:
2 left
💡 Hint

Check the redis-py documentation for the method to send messages to a channel.

🔧 Debug
advanced
2:00remaining
Why does the Redis subscriber in Django not receive messages?

A Django app subscribes to a Redis channel but never receives messages published to that channel. Which of the following is the most likely cause?

AThe subscriber is using a blocking call that prevents message processing.
BThe subscriber did not call the <code>subscribe</code> method before listening.
CThe Redis server is configured to reject all Pub/Sub messages.
DThe published messages are too large and get dropped silently.
Attempts:
2 left
💡 Hint

Check the subscriber setup steps carefully.

state_output
advanced
2:00remaining
What is the state of Redis after publishing messages with no subscribers?

If a Django app publishes messages to a Redis channel but no clients are subscribed at that moment, what happens to those messages in Redis?

AMessages are discarded immediately and not stored anywhere.
BMessages are stored in a Redis list for later retrieval.
CMessages are saved in Redis memory until a subscriber connects.
DMessages cause Redis to throw an error due to no subscribers.
Attempts:
2 left
💡 Hint

Think about Redis Pub/Sub message persistence.

🧠 Conceptual
expert
3:00remaining
Why choose Redis as a message broker in Django over other brokers?

Which of the following reasons best explains why a developer might choose Redis as a message broker for a Django app?

ARedis guarantees message delivery persistence and complex routing like RabbitMQ.
BRedis automatically scales horizontally without any configuration.
CRedis offers fast in-memory message delivery with simple Pub/Sub and supports lightweight task queues.
DRedis supports only synchronous message processing, which simplifies debugging.
Attempts:
2 left
💡 Hint

Consider Redis strengths and limitations compared to other brokers.