Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-744

Bad response time for fetch request

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • None
    • None
    • None
    • None

    Description

      Getting a response to a fetch request from an empty partition after the first time takes lots of time.
      example:
      Post a fetch request to topic 'test' partition 0 which has no data in it, you get the response in ~0.0005 sec. When posting the same request for the second time (still no data the response time is ~0.04 sec.
      Following is a simplistic php script that demonstrate the problem (note that the time is measured for the 1st read)

      $host = "your-kafka-ip:port";

      $socket = stream_socket_client($host);
      if (!$socket) {
      print "can't connect\n";
      exit;
      }
      $topic = 'test';
      $data = pack('n', 1); // fetch
      $data .= pack('n', strlen($topic)) . $topic;//short string
      $data .= pack('N', 0);//partition
      $data .= str_repeat(chr(0), 8);//offset
      $data .= pack('N', 1000); //max size
      $requestSize = strlen($data);
      for ($i = 0; $i < 10; $i++) {
      fwrite($socket, pack('N', $requestSize));
      fwrite($socket, $data);
      $ts = microtime(true);
      $bytes32 = fread($socket, 4);
      $ts = microtime(true) - $ts;
      print "> {$ts}\n";
      $responseSize = current(unpack('N', $bytes32));
      $bytes16 = fread($socket,2);
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            dyeshurun Danny Yeshurun
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: