Queues Flashcards

(9 cards)

1
Q

Exactly once delivery

A

Trade off:
- lower throughput
- higher latency
- requires tracking message identifiers to ensure the message has not already been handled

Pros:
- you can still do retries when the message is delivered but the consumer fails for some reason
- consuming system probably needs to work in an idempotent manner (if message is retried and succeeds it will have same effect as it would have if it succeeded on first try)
- message is only delivered once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

At least once delivery

A

Pros:
- fast
- cheap

Cons:
- message can be delivered more than once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Latency and throughput limits of different queues

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Kafka vs SQS

A

Kafka:
- Faster: ~1ms
- 1:1 and broadcast
- Guarantees ordering within a partition. A partition could get bogged down with load though, so cross partition ordering not maintained.
- Can not guarantee ordering across partitions under any circumstances, unless you only have 1 partition (which has performance limitations)
- Consumers poll the queue for messages, no persistent connections.

SQS:
- Slower: ~10 ms
- Just 1:1
- Standard queue (order NOT guaranteed)
- millions of TPS
- FIFO queue (order guaranteed):
- up to 300 TPS when using just 1 message group (ensures global ordering of messages)
- up to 3k TPS when using batching and multiple message groups

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Redis Pubsub

A

< 1 ms latency

fully in memory

push based

typically used for online status notification feature

Doesn’t guarantee ordering for multiple consumers. Does guarantee it if only 1 consumer.

Use when:
- Extremely fast latency needed (<1 ms)
- Persistence not required
- Usecases:
- notifications to apps
- status update of users
- When you want easy impl (no infra set up)

Bad for:
- Durability
- Ordering required for multiple consumers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Redis Streams

A

Does consumer poll based message delivery

Allows multiple consumers to consume from stream. Each message only goes to 1 consumer though.

Always guarantees message order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

SNS vs Kafka

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Kafka topics, partitions, consumer groups, and ordering.

A

Can have multiple partitions per topic. Each message goes to exactly 1 partition (usually based on hash). Each partition guarantees ordering.

If multiple consumer groups reading from the same partition, order is not guaranteed across consumer groups though. The messages will just come out of the partition in order, but consumer groups may process at different rates.

The only way to ensure ordering in Kafka is to only have a topic with 1 partition, so therefore it usually would only make sense to have and 1 consumer group with 1 consumer in it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly