How does SQS pricing actually work?

SQS bills per API request, not per message. Every message passes through at least three billable calls: SendMessage, ReceiveMessage, and DeleteMessage. A "10 million messages a month" estimate therefore starts at 30 million requests, not 10 million.

Two other factors raise the count. Requests are metered in 64 KB chunks, so a 200 KB payload counts as four requests. The chunking applies to the whole batch payload, which means a batch of ten 10 KB messages counts as two. FIFO queues also charge a higher per-request rate than standard queues.

The largest avoidable cost is short polling. With short polling, consumers call ReceiveMessage in a loop and get empty responses, and each empty response is billed. Setting ReceiveMessageWaitTimeSeconds (up to 20 seconds) on the queue or on the receive call enables long polling. The call then waits for messages to arrive instead of returning empty. Batching up to 10 messages per send, receive, and delete call cuts the remaining requests by up to 10x.

Illustrative estimate. Assumed inputs: 10M small messages per month, and 20M empty receives from short-polling consumers.

Setup Sends Receives Deletes Empty receives Total requests
Naive estimate 10M — — — 10M
Unbatched, short polling 10M 10M 10M 20M 50M
Batched (10), long polling 1M 1M 1M ~0 ~3M

In the batched row, the receives figure assumes full batches. Long polling also leaves some empty receives during idle periods. Multiply the request totals by the current per-million rate on the AWS SQS pricing page. Rates differ by region and queue type.

import boto3

sqs = boto3.client("sqs", region_name="us-east-1")
QUEUE_URL = ""

# Enable long polling queue-wide: empty receives wait up to 20s for messages
# instead of returning immediately as billed empty responses.
sqs.set_queue_attributes(
    QueueUrl=QUEUE_URL,
    Attributes={"ReceiveMessageWaitTimeSeconds": "20"},
)

def send_all(bodies):
    # Up to 10 messages per SendMessageBatch call; billed per 64 KB of total batch payload.
    for i in range(0, len(bodies), 10):
        entries = [{"Id": str(n), "MessageBody": b} for n, b in enumerate(bodies[i:i + 10])]
        resp = sqs.send_message_batch(QueueUrl=QUEUE_URL, Entries=entries)
        # Partial failures do not raise an exception; inspect and retry them.
        for f in resp.get("Failed", []):
            print("send failed:", f["Id"], f["Code"])

def consume_once(handle):
    # Receive up to 10 messages per call; WaitTimeSeconds sets long polling on this call.
    resp = sqs.receive_message(
        QueueUrl=QUEUE_URL, MaxNumberOfMessages=10, WaitTimeSeconds=20
    )
    messages = resp.get("Messages", [])
    if not messages:
        return
    for m in messages:
        handle(m["Body"])
    # One DeleteMessageBatch request replaces up to 10 DeleteMessage requests.
    sqs.delete_message_batch(
        QueueUrl=QUEUE_URL,
        Entries=[{"Id": str(n), "ReceiptHandle": m["ReceiptHandle"]}
                 for n, m in enumerate(messages)],
    )

Using boto3, this example enables long polling on the queue and batches sends, receives and deletes in groups of up to 10 to cut the number of billed SQS requests.

How is Kafka and MSK cost structured?

Kafka is billed for the capacity you reserve, not the messages you send. A cluster costs the same at 3 a.m. with no traffic as it does at peak, because you pay for brokers and disks whether or not anything arrives. The bill has three parts:

  • Broker instance-hours. You size brokers for peak throughput plus headroom for partition rebalancing, broker failure and growth. A quiet cluster still runs every broker.
  • Provisioned storage multiplied by replication factor. With the common replication factor of 3, each retained byte is stored three times. Storage cost scales with retention, not with throughput alone.
  • Network. Producers and consumers in a different Availability Zone from the partition leader generate cross-AZ transfer. On self-managed Kafka you also pay for broker-to-broker replication across AZs. On MSK, AWS does not charge for transfer between brokers inside the cluster, but client traffic is still billed normally.
        AZ-a               AZ-b               AZ-c
   +-----------+      +-----------+      +-----------+
   | Broker 1  |----->| Broker 2  |----->| Broker 3  |
   | (leader)  |  (1) | (follower)|  (1) | (follower)|
   +-----------+      +-----------+      +-----------+
        ^                                      |
        | (2) produce                          | (3) fetch
   Producer (AZ-b)                       Consumer (AZ-c)

(1) cross-AZ replication   (2)/(3) cross-AZ client traffic

Rack-aware clients and follower fetching reduce traffic (3). They do not remove the cost.

The monthly cost works out as:

Monthly cost ≈ (brokers × hourly rate × hours) + (retained GB × replication factor × storage rate) + (cross-AZ GB × transfer rate)

Managed MSK takes over patching, broker replacement and some monitoring. It does not remove the capacity floor. You still choose broker count and size, and you pay for them around the clock.

AZ-a                     AZ-b                     AZ-c
+---------------------+  +---------------------+  +---------------------+
| Broker 1            |  | Broker 2            |  | Broker 3            |
| leader, P0          |  | follower, P0        |  | follower, P0        |
| disk: copy 1 of 3   |  | disk: copy 2 of 3   |  | disk: copy 3 of 3   |
+---------------------+  +---------------------+  +---------------------+
   |  ^   |                         ^                        ^
   |  |   +-(1) replication---------+                        |
   |  |   +-(1) replication----------------------------------+
   |  |
   |  +---(2) produce------- Producer (AZ-b)
   |
   +------(3) fetch--------- Consumer (AZ-c)

(1)    Broker-to-broker replication across AZs: billed on self-managed
       Kafka; AWS does not charge for it inside an MSK cluster.
(2)(3) Client traffic to a leader in another AZ: billed on both.
       Rack-aware clients and follower fetching reduce (3).

Fixed floor, idle or busy:
  3 brokers x hourly rate x hours  +  retained GB x 3 copies x storage rate

A three-AZ Kafka cluster with replication factor 3, where every byte is stored three times, broker-to-broker replication crosses AZs, and produce and fetch traffic crosses AZs whenever a client runs in a different zone from the partition leader.

What hidden costs do Kafka estimates usually miss?

Start with the network. With replication factor 3 spread across three availability zones, every byte a producer writes is copied to two brokers in other zones. Consumers also read from the partition leader by default, which often sits in a different zone. On self-hosted EC2, all of that traffic is billed as inter-AZ transfer. On MSK, broker-to-broker replication is not billed separately, but client traffic that crosses zones still is, so check how your provider bills it.

Illustrative estimate (assumed numbers, not a benchmark)

  • Formula: monthly cross-AZ cost = (ingest GB × replicas in other AZs + consumed GB × fraction read cross-AZ) × per-GB rate.
  • Assumed inputs: 3 TB ingested per month, 2 remote replicas, 1 consumer group reading 3 TB, 2/3 of reads cross-AZ, and a combined rate of $0.02/GB.
  • Calculation: (3,000 × 2 + 3,000 × 0.67) × 0.02 ≈ $160/month.

At moderate volumes, that figure can approach the cost of the brokers themselves.

Follower fetching reduces the consumer side of this traffic. It requires three settings:

  • broker.rack set on every broker
  • replica.selector.class set to the rack-aware selector
  • client.rack set on each consumer

Each one is another setting that can drift out of sync with the others.

Self-hosted clusters also need controller capacity, whether ZooKeeper or KRaft, along with metrics, alerting and disk monitoring.

Engineer time is usually the largest cost left out. Partition planning, rolling upgrades, rebalancing and on-call rotations take hours that would otherwise go to product work. If you count that time as zero, self-managed Kafka looks cheaper than it is.

Under-provisioning carries its own risk. Kafka cannot reduce a topic's partition count. Adding partitions later changes which partition each key maps to, which breaks per-key ordering during the transition. A small cluster sized too tightly can force a migration later.

# --- broker: server.properties (repeat on every broker, rack = that broker's AZ) ---
# The rack ID must match the AZ the broker actually runs in.
broker.rack=use1-az1

# Let the leader point consumers at a replica in the consumer's own rack
# (KIP-392, Kafka 2.4+). Without this, client.rack has no effect.
replica.selector.class=org.apache.kafka.common.replica.RackAwareReplicaSelector

# --- consumer: consumer.properties (one per deployment, per AZ) ---
bootstrap.servers=broker-1.internal.example:9092,broker-2.internal.example:9092,broker-3.internal.example:9092
group.id=orders-billing

# Must use the same naming scheme as broker.rack. A typo or a different
# scheme (zone name vs zone ID) silently falls back to fetching from
# the leader, and cross-AZ consumer traffic comes back.
client.rack=use1-az1

# Producers still write to the leader, and replication still crosses AZs.
# Follower fetching only reduces the consumer side of the transfer bill.

Follower fetching needs matching settings on both sides: broker.rack and the rack-aware replica selector on every broker, and a client.rack on each consumer that uses the same AZ identifiers.

How do you calculate the SQS vs Kafka break-even point?

That sizing floor is what makes the comparison tractable. SQS cost scales linearly with requests, while a Kafka cluster is a fixed broker bill plus storage that grows with throughput. The crossover is the message rate where those two lines meet.

Illustrative estimate: assumed inputs

All prices below are placeholders, not current rates.

Input Assumed value Side Dominant?
Message rate (R) 500 msg/s Both Yes
Average size 2 KB (one billable request chunk) Both Kafka storage only
Batch size (B) 10 SQS Yes
Requests per message 3 (send, receive, delete) SQS Yes
Retention 3 days Kafka Moderate
Replication factor 3 Kafka Moderate
Broker count (N) 3 Kafka Yes
SQS request price $0.40 per million SQS Yes
Broker price $0.20 per hour Kafka Yes
Storage price $0.10 per GB-month Kafka Moderate

Over a 30-day month, SQS costs about $156. That is 1.296 billion messages × 3 requests ÷ 10 per batch × $0.40 per million.

Kafka costs about $510:

  • Brokers: 3 brokers × $0.20 × 720 hours = $432.
  • Storage: 1 MB/s × 3 days × 3 replicas ≈ 778 GB, which comes to about $78.

Break-even formula

Express each variable cost per unit of sustained msg/s per month:

  • SQS: 3 ÷ B × request price × seconds per month ≈ $0.311.
  • Kafka storage: size × retention seconds × replication factor × storage price ≈ $0.156.

The break-even rate is:

R* = fixed broker cost ÷ (SQS variable cost − Kafka variable cost)

With these inputs, R* = 432 ÷ 0.155 ≈ 2,800 msg/s.

There are two caveats:

  • If Kafka's per-message storage cost exceeds SQS's per-message cost, the two lines never cross, and SQS stays cheaper at every rate.
  • N is held constant in this formula. If the break-even rate exceeds what three brokers can handle, add brokers and recompute.

The script that follows takes these inputs as arguments. Run it with your current regional prices. The result applies only to these assumptions, and you need to recalculate it whenever prices, regions or traffic shape change.

# Illustrative estimate: SQS vs Kafka break-even. All prices are PLACEHOLDERS.
# Replace them with current prices for your region before using the result.
SECONDS_PER_MONTH = 30 * 86400
HOURS_PER_MONTH = 30 * 24

# Assumed inputs (edit these)
rate = 500                 # sustained msg/s
msg_bytes = 2000           # average message size (decimal KB)
batch = 10                 # messages per SQS API call
reqs_per_msg = 3           # send + receive + delete
retention_days = 3
replication = 3
brokers = 3
sqs_price_per_million = 0.40   # placeholder
broker_price_per_hour = 0.20   # placeholder
storage_price_gb_month = 0.10  # placeholder

# Variable cost of 1 msg/s sustained for a month, on each side
sqs_var = reqs_per_msg / batch * sqs_price_per_million / 1e6 * SECONDS_PER_MONTH
# Steady-state retained bytes for 1 msg/s, priced per GB-month
retained_gb = msg_bytes * retention_days * 86400 * replication / 1e9
kafka_var = retained_gb * storage_price_gb_month
kafka_fixed = brokers * broker_price_per_hour * HOURS_PER_MONTH

sqs_cost = rate * sqs_var
kafka_cost = kafka_fixed + rate * kafka_var
print(f"SQS   at {rate} msg/s: ${sqs_cost:,.2f}/month")
print(f"Kafka at {rate} msg/s: ${kafka_cost:,.2f}/month")

# R* = fixed broker cost / (SQS variable - Kafka variable)
if sqs_var <= kafka_var:
    print("No crossover: Kafka's per-message cost >= SQS's, so SQS stays cheaper.")
else:
    r_star = kafka_fixed / (sqs_var - kafka_var)
    print(f"Break-even R* ~ {r_star:,.0f} msg/s (valid only while broker count = {brokers})")

A self-contained Python script that reproduces the illustrative crossover model. It prints the monthly cost on each side and the break-even rate R, which comes to about 2,800 msg/s with the placeholder inputs. Swap in your own regional prices and workload values and rerun it whenever prices change.*

How do retention, replay and fan-out change the cost comparison?

SQS deletes a message once a consumer acknowledges it, and unconsumed messages expire after a capped retention period: a few days by default, two weeks at most. You cannot replay last month's events, rebuild a projection, or add a new consumer that starts from history. Each of those needs a separate storage layer, such as an archive in object storage, plus code to re-drive it.

Independent consumers are also expensive. The usual pattern is SNS fan-out to one queue per consumer, so every consumer pays for its own delivery, receive and delete requests. Kafka stores the log once. An extra consumer group adds read throughput and network egress, and that cost stays small until you approach broker disk, network or partition limits.

Concern SQS Kafka / MSK
Replay Not supported; needs an external archive Seek offsets within retention
New consumer New queue plus subscription; request cost scales with N New group; mostly read bandwidth
Large payloads Billed in 64 KB chunks; hard size limit Broker and client config limits; large messages strain brokers

Illustrative estimate (assumed numbers, not a benchmark). Billable requests = messages × consumers × requests per message × ceil(payload ÷ 64 KB) Assume 50M messages per month, 4 consumers, 3 requests each (delivery, receive, delete), no batching, and a 100 KB payload: 50M × 4 × 3 × 2 = 1.2B requests. Multiply that by your regional per-million price.

The usual fix for large payloads is to store the body in object storage and enqueue a pointer. This adds a PUT and a GET per message for each consumer. It also adds failure modes: an object can be deleted before a slow consumer reads it, a write can fail after the pointer was sent, and object lifecycle rules must outlast queue retention and redrive windows.

When should you avoid SQS or Kafka?

SQS: when the bill has no ceiling

SQS charges per request, so cost follows behaviour rather than capacity. That hurts you whenever your system misbehaves. A retry storm against a failing downstream multiplies receive, delete and visibility-change calls. A poison message with no dead-letter queue (DLQ) is received again every time its visibility timeout expires, and each receive is billed until the retention period ends. Short polling bills for empty responses. Setting ReceiveMessageWaitTimeSeconds to its maximum of 20 seconds enables long polling and removes most of those empty receives.

A redrive policy is the cheapest guardrail. Set maxReceiveCount to a small value, such as 5, and point deadLetterTargetArn at a DLQ. A bad message then costs at most five receive cycles and stops looping. Alarm on DLQ depth so the failures still get attention.

FIFO queues weaken the cost argument for strictly ordered work. They cost more per request and have lower throughput ceilings than standard queues. Ordering is enforced per message group, so a hot group serialises its own traffic.

The larger risk is choosing SQS and later needing replay or long-lived ordered streams. A migration usually means running both systems in parallel while consumers move over, so you pay for two platforms during the transition.

Kafka: when the floor is the problem

Kafka gets cheaper per message as volume rises, but you pay for brokers, storage and on-call time from the first day. If your volume never grows into that capacity, you have paid a fixed floor and taken on operational overhead without getting the benefit.

What are the alternatives, and which queue should your team choose?

Serverless and on-demand Kafka offerings, including MSK Serverless, shrink that fixed floor because you no longer size brokers. They do not make Kafka behave like SQS. These offerings usually bill on several dimensions: an hourly charge per cluster or partition, plus data written, read and retained. That means a topic with many partitions still costs money while idle. They also impose per-cluster or per-partition throughput and retention limits that self-managed clusters do not. Put these line items into the same break-even model you used for provisioned MSK. In particular, count partition-hours, because over-partitioning for future growth is a common source of surprise bills.

Decision checklist

Factor Favours SQS Favours Kafka (MSK or serverless)
Traffic shape Bursty, spiky, or long idle periods Sustained, predictable throughput
Replay and ordering Work queue, no replay, ordering per group only Replay from offsets, high-throughput ordered partitions
Consumer groups One or two consumers per message Many independent consumer groups reading the same data
Message size Small messages that fit request-based billing Larger or highly variable payloads, batched writes
Operational capacity No one owns broker tuning or upgrades A team already runs and monitors Kafka
Existing infrastructure No cluster today A cluster already absorbs fixed costs with spare capacity

The last row often decides the outcome. Adding a topic to an underused cluster costs very little, while standing up a cluster for a single workload does not.

Choosing the right option saves engineering time in a direct way. A team that picks SQS for a fan-out-heavy replay workload ends up building replay itself. A team that picks Kafka for a bursty job queue ends up tuning partitions and consumer lag for traffic that a managed queue would have handled with no tuning.

How OneEnv can help

Disclosure: OneEnv is the product behind this blog.

OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.

Applied to sqs vs kafka cost, this is where it helps:

Saves time

  • Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
  • One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
  • Changing a shared variable is one edit and one review instead of editing every service's .env by hand.

Saves cost

  • Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
  • Less duplicated configuration to maintain: one shared definition inherited by many services.
  • A wrong or stale value is caught at review time by the services it affects, not by a failed deploy.
  • OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.

These are qualitative benefits, not measured results — how much you save depends on how many services share the value.

Want to try it? Start at oneenv.io.