zoukankan      html  css  js  c++  java
  • (t,p,o) t:p>=o there cannot be more consumer instances in a consumer group than partitions

    https://kafka.apache.org/intro.html

    Kafka as a Messaging System

    How does Kafka's notion of streams compare to a traditional enterprise messaging system?

    【队列有扩展性,不支持多订阅者 --- 发布者-订阅者 反之   queue publish-subscribe 】

    【 scale processing  multi-subscriber】

    【queues aren't multi-subscriber—once one process reads the data it's gone】

    【.Publish-subscribe allows you broadcast data to multiple processes, but has no way of scaling processing since every message goes to every subscriber】

    Messaging traditionally has two models: queuing and publish-subscribe. In a queue, a pool of consumers may read from a server and each record goes to one of them; in publish-subscribe the record is broadcast to all consumers. Each of these two models has a strength and a weakness. The strength of queuing is that it allows you to divide up the processing of data over multiple consumer instances, which lets you scale your processing. Unfortunately, queues aren't multi-subscriber—once one process reads the data it's gone. Publish-subscribe allows you broadcast data to multiple processes, but has no way of scaling processing since every message goes to every subscriber.

    【 consumer group  解决了上述2个问题】

    【群内扩展,群间广播】

    【不同消费群是可以订阅同一个主题的】

    The consumer group concept in Kafka generalizes these two concepts. As with a queue the consumer group allows you to divide up processing over a collection of processes (the members of the consumer group). As with publish-subscribe, Kafka allows you to broadcast messages to multiple consumer groups.

    【Kafka's model is that every topic can scale processing and is also multi-subscriber】

    The advantage of Kafka's model is that every topic has both these properties—it can scale processing and is also multi-subscriber—there is no need to choose one or the other.

    Kafka has stronger ordering guarantees than a traditional messaging system, too.

    A traditional queue retains records in-order on the server, and if multiple consumers consume from the queue then the server hands out records in the order they are stored. However, although the server hands out records in order, the records are delivered asynchronously to consumers, so they may arrive out of order on different consumers. This effectively means the ordering of the records is lost in the presence of parallel consumption. Messaging systems often work around this by having a notion of "exclusive consumer" that allows only one process to consume from a queue, but of course this means that there is no parallelism in processing.

    【(t,p,o)   t:p>=o 】

    【By having a notion of parallelism—the partition—within the topics, Kafka is able to provide both ordering guarantees and load balancing over a pool of consumer processes. 】

    【partitions 】

    【一话题,多分区:一个分区同时只被一个消费者消费,保证顺序;多分区,保证平行】

    Kafka does it better. By having a notion of parallelism—the partition—within the topics, Kafka is able to provide both ordering guarantees and load balancing over a pool of consumer processes. This is achieved by assigning the partitions in the topic to the consumers in the consumer group so that each partition is consumed by exactly one consumer in the group. By doing this we ensure that the consumer is the only reader of that partition and consumes the data in order. Since there are many partitions this still balances the load over many consumer instances. Note however that there cannot be more consumer instances in a consumer group than partitions.

  • 相关阅读:
    Java内存泄漏分析系列之七:使用MAT的Histogram和Dominator Tree定位溢出源
    Java内存泄漏分析系列之六:JVM Heap Dump(堆转储文件)的生成和MAT的使用
    Java内存泄漏分析系列之五:常见的Thread Dump日志案例分析
    Java内存泄漏分析系列之四:jstack生成的Thread Dump日志线程状态
    Java内存泄漏分析系列之三:jstat命令的使用及VM Thread分析
    Java内存泄漏分析系列之二:jstack生成的Thread Dump日志结构解析
    Java内存泄漏分析系列之一:使用jstack定位线程堆栈信息
    安全框架Shiro
    JDK动态代理与CGLib动态代理
    解读分库分表中间件Sharding-JDBC
  • 原文地址:https://www.cnblogs.com/rsapaper/p/7760840.html
Copyright © 2011-2022 走看看