Skip to content
    Architecton

    MESSAGING & QUEUES · 8 MIN

    Message Queues

    A queue lets one service hand work to another without waiting for it to finish.

    ARCH explains

    • Producers push messages; consumers pull and process them at their own pace.
    • Queues absorb traffic spikes and keep working if a consumer crashes and restarts.
    • Pub/sub sends one event to many subscribers (email, analytics, notifications).

    Real world: A restaurant order ticket rail: waiters keep taking orders while the kitchen cooks.

    Code

    from collections import deque
    q = deque()
    for order in ["dosa", "tea", "idli"]:
        q.append(order)
    while q:
        print("cooking", q.popleft())
    Output ›
    cooking dosa
    cooking tea
    cooking idli
    Try it in the online compiler →

    Checkpoint quiz

    Main benefit of putting a queue between services?