GitHub user ScrapCodes opened a pull request:

    https://github.com/apache/spark/pull/17308

    [SPARK-19968][SS] Use a cached instance of `KafkaProducer` instead of 
creating one every batch.

    ## What changes were proposed in this pull request?
    Changes include a new API for doing cleanup of resources in KafkaSink is 
added to Sink trait.
    
    In summary, cost of recreating a KafkaProducer for writing every batch is 
high as it starts a lot threads and make connections and then closes them. A 
KafkaProducer instance is promised to be thread safe in Kafka docs. Reuse of 
KafkaProducer instance while writing via multiple threads is encouraged.
    
    Furthermore, I have performance improvement of 10x in latency, with this 
patch.
    
    TODO: post exact results.
    
    ## How was this patch tested?
    Running distributed benchmarks comparing runs with this patch and without 
it.
    Added relevant unit tests.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ScrapCodes/spark cached-kafka-producer

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/17308.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #17308
    
----
commit febf3874cf07bad04e574b571f1caa839c9c28b7
Author: Prashant Sharma <prash...@in.ibm.com>
Date:   2017-03-15T11:03:45Z

    [SPARK-19968][SS] Use a cached instance of KafkaProducer instead of 
creating one every batch.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to