title: How does kafka consumer auto commit work?
body: <p>I am reading <a href="https://www.safaribooksonline.com/library/view/kafka-the-definitive/9781491936153/ch04.html#callout_kafka_consumers__reading_data_from_kafka_CO2-1" rel="noreferrer">this one</a>:</p>
  
  <blockquote>
    <p>Automatic Commit The easiest way to commit offsets is to allow the
    consumer to do it for you. If you configure enable.auto.commit=true,
    then every five seconds the consumer will commit the largest offset
    your client received from poll(). The five-second interval is the
    default and is controlled by setting auto.commit.interval.ms. Just
    like everything else in the consumer, the automatic commits are driven
    by the poll loop. Whenever you poll, the consumer checks if it is time
    to commit, and if it is, it will commit the offsets it returned in the
    last poll.</p>
  </blockquote>
  
  <p>Maybe issue that my English is not good but I do not fully understood this description.</p>
  
  <p>Let's say I use auto-commit with default interval - 5 sec and poll happens every 7 sec. At this case, a commit will happen every 5 sec or every 7 sec?  </p>
  
  <p>Can you clarify behaviour if poll will happen every 3 sec? Will commit happen every 5 sec or every 6 sec?<br>
  I have read <a href="https://www.javaworld.com/article/3066873/big-data/big-data-messaging-with-kafka-part-2.html?page=2" rel="noreferrer">this one</a>:</p>
  
  <blockquote>
    <p>Auto commits: You can set auto.commit to true and set the
    auto.commit.interval.ms property with a value in milliseconds. Once
    you've enabled this, the Kafka consumer will commit the offset of the
    last message received in response to its poll() call. The poll() call
    is issued in the background at the set auto.commit.interval.ms.</p>
  </blockquote>
  
  <p>And it contradict the answer. </p>
  
  <p>Can you explain this stuff in details.</p>
  
  <p>let say I have diagramm like this:  </p>
  
  <blockquote>
    <p>0 sec - poll<br>
    4 sec - poll<br>
    8 sec - poll    </p>
  </blockquote>
  
  <p>When does offset will be committed and when which one?</p>