Real-time notifications, chat apps, background jobs Quiz

Explore core principles behind real-time notifications, messaging in chat applications, and handling background jobs efficiently. This quiz helps you assess understanding of event-driven systems, message delivery, and asynchronous workflow management essential for modern software solutions.

  1. Push vs Polling in Real-Time Apps

    In a real-time chat application, which approach is best for minimizing latency when delivering messages instantly as soon as they are sent?

    1. Batch processing
    2. Long polling
    3. Push notifications
    4. Sync communication

    Explanation: Push notifications provide near-instant message delivery by allowing the server to proactively send updates to connected clients, which minimizes latency. Long polling is less efficient as it requires repeated requests and waiting periods, causing higher latency. Batch processing groups multiple messages to send at a later time, which is unsuitable for real-time needs. Sync communication typically entails waiting for each request to complete before handling others, leading to delays.

  2. Background Job Queues

    Which primary benefit does using a background job queue provide when processing resource-intensive tasks in a notification system?

    1. Increases CPU usage immediately
    2. Ensures tasks run synchronously
    3. Improves scalability and responsiveness
    4. Delivers messages only during business hours

    Explanation: Background job queues handle heavy or slow tasks asynchronously, freeing up the main thread and improving system scalability and responsiveness. They do not increase CPU usage instantly—instead, they manage load over time. Synchronous execution is avoided in this model to prevent blocking. Finally, job queues are flexible regarding timing but do not inherently limit delivery to business hours.

  3. Message Delivery Guarantees

    Which message delivery guarantee ensures that every chat message in a real-time system is delivered exactly one time to the recipient, avoiding both loss and duplicates?

    1. Often once
    2. At most once
    3. Exactly once
    4. At least once

    Explanation: Exactly once delivery ensures each message is processed a single time—crucial for avoiding data loss and duplicates in chat systems. At most once may result in lost messages if delivery fails, while at least once might deliver duplicates. ‘Often once’ is not a standard delivery guarantee and offers no service-level assurance.

  4. Presence Indicators in Chats

    In a real-time chat app, what mechanism most efficiently communicates a user's online or offline status to all their contacts?

    1. Read receipt tags
    2. Client-side polling
    3. Status broadcasting via subscription
    4. Scheduled database backups

    Explanation: Status broadcasting uses subscriptions to deliver presence updates swiftly and efficiently to all interested users. Client-side polling increases server load and may not reflect timely changes. Scheduled database backups are unrelated to user presence, and read receipt tags only indicate message reads, not online status.

  5. Retry Logic in Background Processing

    When a background job fails due to a temporary error, which strategy is recommended to avoid overwhelming the system with repeated retries?

    1. Exponential backoff
    2. Immediate infinite retries
    3. No retries
    4. Concurrent duplication

    Explanation: Exponential backoff increases the wait time between retry attempts, reducing system overload and allowing transient issues time to resolve. Immediate infinite retries can overload resources and should be avoided. Never retrying means some tasks may fail permanently. Concurrent duplication would spawn unnecessary extra jobs, compounding the problem.