Kafka Learning
Kafka Learning
- Atleast Once: producer can send the message more than once. If message fails or
is not ack, the produceer can send the message again. **Consumer may have to
eliminate duplicate messages**
- Atmost Once: A producer may send a message once and never retry. If the message
fails or is not ack, the producer will never send the message again. => Good to
display the traffic to webpage
- Exactly Once: Even if a producer send a message more than once, the consumer will
only recieve the message once => transaction cordination on each topic which
ensures single delivery
Multiple consumers may/can access the same message which allows to scale infinitely
Schema:
Allowing to what content and format of the data is in.
Stream processing is not ideal it data is not flowing real time 24x7
https://www.beyondthelines.net/computing/kafka-patterns/
# Broker Configs:
- auto.leader.rebalance.enable (leader.imbalance.check.interval.seconds,
leader.imbalance.per.broker.percentage)
- background.threads
- compression.type
- delete.topic.enable
- message.max.bytes
- min.insync.replicas
- replica.fetch.min.bytes
- replica.fetch.wait.max.ms
- unclean.leader.election.enable
- zookeeper.max.in.flight.requests
- broker.rack
# Topic Configs:
# We can enable replica reading from 2.4 but would require things related to racks
- KAFKA_CFG_BACKGROUND_THREADS=40
./kafka-topics.sh --bootstrap-server localhost:9090 --create --topic
Test.BackgroundThread --partitions 3 --replication-factor 1
./kafka-run-class.sh org.apache.kafka.tools.ProducerPerformance --topic
Test.BackgroundThread --num-records 5000000 --record-size 1024 --throughput -1 --
producer-props acks=-1
bootstrap.servers=localhost:9090,localhost:9094,localhost:9096 batch.size=8196
5000000 records sent, 156118.275205 records/sec (152.46 MB/sec), 88.40 ms avg
latency, 2214.00 ms max latency, 19 ms 50th, 420 ms 95th, 938 ms 99th, 1969 ms
99.9th.
6000000 records sent, 9834.517846 records/sec (57.62 MB/sec), 12.34 ms avg latency,
2899.00 ms max latency, 1 ms 50th, 2 ms 95th, 11 ms 99th, 2617 ms 99.9th. Size =
70.2GB