Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

The goal is to add Kafka Rest Server to Kafka Repository. This will allow any language/tool that
can work with HTTP to produce and consume messages, and perform administrative actions with Kafka service.

Why add Kafka Rest Server to Kafka?

There are already some open-source REST proxies are available. Some are specific to a particular user cases
Confluent REST Proxy got comprehensive interface. We want to add Kafka Rest Server to Kafka for the following reasons.

...

Some of the good practices and ideas will be borrowed from existing tools.

Proposed Changes

Rest Server:
The REST server is a separate server, sitting between Kafka cluster and client applications. It is wrapper around existing client libraries. 

...

Rest server can be easily scaled by deploying multiple proxy instances. This way we can spread the load across multiple proxy instance
Producer API:

REST server accepts produce requests for specific topics or partitions. It internally uses java producer instance to write messages into Kafka. 

Consumer API:

REST server uses the consumer API to consume the messages from the subscribed topic on behalf of the specified consumer group.
When a message is consumed on behalf of a consume group for the first time, then Kafka Consumer instance joins the consumer group
and subscribes to the topic. All Consumer instances that are currently members of that group and subscribed to that topic divide
topic partitions among themselves. If a Consumer instance has not consumed from a particular topic on behalf of a particular
consumer group for configured interval, then it unsubscribes from the topic on behalf of that group. Offset commit can be either
automatic or manual as requested by the user. We can also retrieve the messages for a consumer, from a specific partition,
starting with an offset.

We also want to take community opinion on other ways of implementing consumer group
functionality.

Admin API and Security Integration:

This will be taken up as future work after the KIP-4 implementation.

Public Interfaces

Producer APIs:

POST /topics/:topic
Description : Produce messages to a given topic

...

 

POST /topics/test/partitions/1 HTTP/1.1

Host:kafkarest.host.com

Content-Type: application/vnd.kafka.binary.v1+json

Accept: application/vnd.kafka.v1+json

{

  "records": [

   {

     "key": "a2V5",

     "value": "dmFsdWU="

   },

   {

     "value": "dmFsdWU="

   }

 ]

}


Example response:

 

HTTP/1.1 200 OK

 Content-Type: application/vnd.kafka.v1+json


{

 "offsets": [

   {

     "partition": 1,

     "offset": 1,

   },

   {

     "partition": 1,

     "offset": 2,

   }

 ]

}

Consumer APIs:

GET /topics/:topic_name/partitions/:partition?offset=(int)
Description : Consume messages from one partition of the topic.

Parameters:

     topic_name (String) - topic name
     partition (int) - partition number
     offset (int) - offset to fetch

Response:
    JSON Object contains response objects

Status Codes:
    404 Not Found
        Error Code 40401 - topic Not Found
        Error Code 40402 - partition Not Found
   500 Internal Server Error
       Error Code 50001 - Kafka Error

 

...

 

HTTP/1.1 200 OK

Content-Type: application/vnd.kafka.v1+json


[

 {

   "topic": "topic",

   "partition": 1,

   "committed": 1

 },

 {

   "topic": "topic",

   "partition": 2,

   "committed": 2

 },

]

 

Compatibility, Deprecation, and Migration Plan

  • This KIP only proposes additions. There should be no compatibility issues.


Rejected Alternatives

Make Kafka Rest Server an external third-party tool:

Main Reason for this KIP is to add Rest Server to Kafka. Shipping Kafka Rest Server as part of a normal Kafka release
makes it immediately available to every user that downloads Kafka. Also helps to maintain the version compatibility
between Kafka clients and Rest Server.

...