Configuring kafka consumer (v)

fetch.min.bytes. # bytes of data to obtain a minimum 
when the broker Consumer data is to be returned by size, if the data does not reach the specified MB, consumer will be in a wait state until the broker where to obtain from the producer to the specified size Until data. Obtaining a minimum data fetch size refers to the data on each partition. 
fetch.max.wait.ms 
When the consumer has reached the minimum number of bytes in the data broker is waiting, if has not been reached, block consumer is not always in a state, will be taken according to the set time fetch.max.wait.ms the end of the block status. If you say that setting fetch.min.bytes size is 1m, but has not reached 1m, but will end off the current block state to the maximum waiting time fetch.max.wait.ms set how much data, how much data acquisition. The default value is 500ms. 
To control the number of client and server communicate via these two parameters, but also for batch jobs. 
max.partition.fetch.bytes 
controlling each partition a maximum number of bytes. The default is 1mb 
if there are 20 partitions 1 th topic, there are five read data on the consumer Partition, each consumer can read the concumer records 4M. 
Session.timeout.ms 
session between the broker and the consumer timeout time
If the consumer for a long time there is no information to initiate poll, took no metadata, and within session.timeout.ms the specified time, it can be considered a client timeout, if the broker believes consumer timed out rebalance will cause consumer, leading to other consmer At this time, not receive messages, a timeout will partition assigned to another consumer consumer 
heartbeat.interval.ms 
control how long the consumer transmits a heartbeat. 
So these two parameters are often used together, heartbeat.interval.ms certainly shorter than the time session.timeout.ms. Generally set heartbeat timeout time is 1 /3 is relatively good. 
auto.offset.reset #earliest 
automatically reads data from the beginning of the place 
when a topic has data, will be assigned to groups by group.id the read data, when a new packet is created, you can set which reads the data from the place of beginning. If you did not create a new packet is not read data 
enable.auto.commit 
automatic submission # default is true  
when reading how much consumer data offset, in fact, is maintained by the client-side, client-side offset will be submitted to the broker, then automatically processed by the dedicated thread for us.
if the data is read, the program accidental death (power outages, downtime), it does not have enough time to submit to the broker, will resulting in duplicate data will read next read data again, because there is no record kafka you to read the latest data position, than you apparently do not read much better data. So we need is no matter how many times I send, you can only receive one, which involves the power and other issues, will be introduced later. 
auto.commit.interval.ms 1000 # Set Auto Commit Time
partition.assignment.strategy 
Partition allocation strategy 
when one or several tipic the partition data read topic of consumer, consumer will in the end to which partition. There are two allocation policy in the broker. 1.range section 2 .roundRobin 
 1 .Range interval 
   when the partition appear odd situation uneven distribution of data will appear. 
   If there are two topic t1 t2, respectively, three partition, when there are two consumer, c1 are assigned to t1 and t2 in p1 p2 and c2 at t1, c2 are assigned to p3 next t1 and t2 p3 in. this distribution strategy will not be assigned to a patition of the consumer. this is the default configuration kafka
 2 .roundRobin 
           it will provide a better range than the allocation policy. 
         It will be assigned to partition the average partition each topic following manner in accordance with the message modulo
   For these two allocation strategies you can implement your own custom allocation strategy through implementation of the interface. But normally we will not rewrite the distribution of consumer policy 
cliend.id # client id 
    any legal string can be viewed through this broker id which the client sends information 
max.poll.records # maximum data acquisition size 
    if we set the minimum to get data in feach.min.bytes 10M, and here set the maximum acquisition 5M, then the consumer will
The remaining 5M cached data in the cache will be called again to return 
receive.buffer.bytes 
    
send.buffer.bytes

 

Guess you like

Origin www.cnblogs.com/MrRightZhao/p/11306091.html