Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Apache Kafka

Apache Kafka

JVM Meetup #5 - Apache Kafka at Blibli.com

Eko Kurniawan Khannedy

August 30, 2017
Tweet

More Decks by Eko Kurniawan Khannedy

Other Decks in Technology

Transcript

  1. APACHE KAFKA AGENDA ▸ Kafka Intro ▸ Kafka Internals ▸

    Installing Kafka ▸ Kafka Producer ▸ Kafka Consumer ▸ Kafka in blibli.com ▸ Demo ▸ Conclusion
  2. APACHE KAFKA PUBLISH / SUBSCRIBE MESSAGING MEMBER ORDER RISK PAYMENT

    … ERP FINANCE … MESSAGING SYSTEM / MESSAGE BROKER
  3. APACHE KAFKA WHAT IS KAFKA ▸ Apache Kafka is a

    publish/subscribe messaging system, or more recently a “distributing streaming platform” ▸ Opensource project under Apache Software Foundation.
  4. APACHE KAFKA KAFKA HISTORY ▸ Kafka was born to solve

    the data pipeline problem in LinkedIn. ▸ The development team at LinkedIn was led by Jay Kreps, now CEO of Confluent. ▸ Kafka was released as an Open Source project on Github in late 2010, and join Apache Software Foundation in 2011.
  5. APACHE KAFKA CLUSTER TOPIC A
 PARTITION 0 TOPIC A
 PARTITION

    1 (LEADER) KAFKA BROKER 1 TOPIC A
 PARTITION 0 TOPIC A
 PARTITION 1 (LEADER) KAFKA BROKER 2
  6. APACHE KAFKA TOPICS ▸ Messages in Kafka are categorized into

    Topics. ▸ The closest analogy for topic is a database table, or a folder in filesystem.
  7. APACHE KAFKA REPLICATION FACTOR TOPIC A
 PARTITION 0 TOPIC A


    PARTITION 1 KAFKA BROKER 1 TOPIC A
 PARTITION 0 KAFKA BROKER 2 TOPIC A
 PARTITION 1 KAFKA BROKER 3 TOPIC A
 PARTITION 0 TOPIC A
 PARTITION 1 KAFKA BROKER 4
  8. APACHE KAFKA RETENTION POLICY ▸ A key feature of Apache

    Kafka is that of retention, or the durable storage of messages for some period of time. ▸ We can set retention policy per topics by time or by size.
  9. APACHE KAFKA KAFKA BROKER # Minimum Broker Configuration broker.id=0 #

    must unique in cluster zookeeper.connect=localhost:2181 log.dirs=data/kafka-logs
  10. APACHE KAFKA CREATE / UPDATE TOPIC kafka-topics.sh --create --zookeeper localhost:2181

    -- replication-factor 1 --partitions 1 --topic topic_name kafka-topics.sh --zookeeper localhost:2181 --alter --topic topic_name --partitions 2 --replication-factor 2
  11. APACHE KAFKA KAFKA PRODUCER Properties props = new Properties(); props.put("bootstrap.servers",

    "broker1:9092,broker2:9092"); props.put("key.serializer", “org.apache.kafka.common.serialization.StringSerializer"); props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); producer = new KafkaProducer<String, String>(kafkaProps);
  12. APACHE KAFKA KAFKA CONSUMER Properties props = new Properties(); props.put("bootstrap.servers",

    "broker1:9092,broker2:9092"); props.put("group.id", "GroupName"); props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); consumer = new KafkaConsumer<String, String>(props);
  13. APACHE KAFKA API GATEWAY EVENT API GATEWAY MEMBER API GATEWAY

    COMMON API GATEWAY … KAFKA ANALYTICS … …
  14. APACHE KAFKA CURRENT PRODUCT (CODENAME X) X MEMBER X CART

    X AUTH X WISHLIST API GATEWAY X YYYY X XXX X ORDER X PRODUCT
  15. APACHE KAFKA NEW PRODUCT (CODENAME VERONICA) VERONICA MEMBER VERONICA CORE

    VERONICA MERCHANT KAFKA VERONICA NOTIFICATION API GATEWAY
  16. APACHE KAFKA WHY KAFKA? ▸ Multiple Consumer ▸ Flexible Scalability

    ▸ Flexible Durability ▸ High Performance ▸ Multi-Datacenter