当前位置: 首页 > news >正文

专业的团队网站建设手机软文广告300字

专业的团队网站建设,手机软文广告300字,wordpress主题对比,学做漂亮早餐的网站文章目录 概要整体架构流程技术名词解释技术细节coordinatorfetcherclientconsumer#poll的主要流程 全局总览小结 概要 继上一篇讲Producer原理的文章过去已经一个多月了,今天来讲讲Consumer的原理。 其实源码早就读了部分了,但是最近工作比较忙&#x…

文章目录

    • 概要
    • 整体架构流程
    • 技术名词解释
    • 技术细节
      • coordinator
      • fetcher
      • client
      • consumer#poll的主要流程
    • 全局总览
    • 小结

概要

继上一篇讲Producer原理的文章过去已经一个多月了,今天来讲讲Consumer的原理。
其实源码早就读了部分了,但是最近工作比较忙,一直没空写文章。

整体架构流程

Consumer组件图

技术名词解释

  • coordinator:Consumer协调器,负责管理Consumer需要加入到哪个消费组、消费哪个partition、提交offset等操作
  • fetcher:主要作用是获取待消费的records,也是Consumer端最重要的组件
  • keyDeserializer:对record中的key进行反序列化
  • valueDeserializer:对record中的value进行反序列化
  • client:执行RPC请求时的网络client,当然会包括一些Kafka内部的操作

技术细节

coordinator

其实协调器对于Consumer的处理分为几个阶段:

  1. Consumer加入的时候:负责判断Consumer加入到哪个Consumer group、协调消费哪个partition
  2. Consumer消费过程中:负责记录Consumer消费的partition的元数据、partition的消费状态、消费offset;更新partition的offset

fetcher

fetcher的数据结构
从Fetcher的数据结构里其实就可以猜到它的作用:缓存已Fetch到的records、去fetch更多的records

  • completedFetch:每次fetch请求得到的数据,拆分到topicPartition维度。因为fetch请求是基于server的node维度,请求回来的数据按照tp维度拆分,得到不同的completedFetch
  • completedFetchs: 已经fetch到的所有completedFetch
  • nextInLineRecords:当前正在被消费消息的completedFetch对应的所有records,由于对于同一个tp,当时Producer发消息时,是按照batch维度发送的,所以此时completedFetch里也包含多个batch,每个batch包含多个record,也就是records
    如果缓存里没有消息呢?
    也就是completedFetchs和nextInLineRecords都是空

client

类型是ConsumerNetworkClient,里面包含了一个NetWorkClient。至于NetWorkClient是如何进行数据处理及RPC的,可以参考Producer原理解析那篇文章
client示意图

  • unsent:保存的是当前需要发送的fetchRequest
  • pendingCompletion:需要被处理的已完成的请求,其实也就是之前的fetchRequest的response
  • client:该client是NetWorkClient,Producer端是直接使用了该client
    所以ConsumerNetworkClient的主要作用:1. 处理之前fetch回来的数据;2. 调用NetWorkClient将当前的fetchRequest发送出去

consumer#poll的主要流程

  1. 判断是否需要commit offset(默认情况下,5秒进行一次异步offset的commit)

  2. 读取Fetcher的缓存,如果有数据,直接跳转到5

  3. 缓存里没有数据,基于coordinator里保存的partition元数据,封装fetchRequest
    创建fetchRequest示意图

  4. 执行client#poll:1. 处理之前fetch回来的数据,解析为completedFetchs;2. 调用NetWorkClient将当前的fetchRequest发送出去;
    client#poll逻辑示意图

  5. 调用自定义的消费逻辑(程序员自己写的Consumer),处理records

全局总览

kafkaConsumer示意图

小结

可以看到Consumer和Producer在逻辑处理上还是有较大不同的。

组件处理请求处理方式
producer主要处理发送消息。对应RPC,主要是写请求将业务逻辑和IO逻辑解耦。业务逻辑:组装batch;IO逻辑:基于batch组装request并发送request
consumer既要发送fetchRequest,同时还要处理fetchResponse。对于RPC,读写请求都占比较大业务逻辑和IO逻辑解耦,但是串行化。业务逻辑:从fetcher里poll已经fetch到的数据;IO逻辑:基于partition元数据组装fetchRequest,处理fetchResponse,发送fetchRequest

Producer的IO是一个Sender线程在异步运行,为什么Consumer不这么干呢?
笔者觉得原因是:
Producer的逻辑是把消息往外发,所以Sender运行的越快,client这边为了维护batch而消耗的资源(内存和CPU越少);而如果Consumer也这么干,实际消费速度赶不上fetch速度的话,会需要额外的内存和CPU资源来维持更多的completedFetchs,更别说如果发生了rebalance的话,fetch过来的completedFetchs可能都是白fetch了。所以,总结下:1. 兼顾消费速度;2. 兼顾client的资源消耗&性能


文章转载自:
http://dinncodesiccated.tqpr.cn
http://dinncodraftable.tqpr.cn
http://dinncosnooper.tqpr.cn
http://dinncoyeast.tqpr.cn
http://dinncopersistent.tqpr.cn
http://dinncoclementine.tqpr.cn
http://dinncofloorboards.tqpr.cn
http://dinncomonobasic.tqpr.cn
http://dinncoknob.tqpr.cn
http://dinncoolap.tqpr.cn
http://dinncolithic.tqpr.cn
http://dinncocommunally.tqpr.cn
http://dinncodonatism.tqpr.cn
http://dinncobashlyk.tqpr.cn
http://dinncocounterweigh.tqpr.cn
http://dinncocheapie.tqpr.cn
http://dinncocarthage.tqpr.cn
http://dinncoemparadise.tqpr.cn
http://dinncoparasynthesis.tqpr.cn
http://dinncoreinstatement.tqpr.cn
http://dinnconoctograph.tqpr.cn
http://dinncoreceptor.tqpr.cn
http://dinncofrazzled.tqpr.cn
http://dinncogid.tqpr.cn
http://dinncocaac.tqpr.cn
http://dinncochrysoidine.tqpr.cn
http://dinnconoam.tqpr.cn
http://dinncoartiodactyl.tqpr.cn
http://dinncolapse.tqpr.cn
http://dinncoretroflex.tqpr.cn
http://dinncofantasy.tqpr.cn
http://dinncoindustry.tqpr.cn
http://dinncoiconotropy.tqpr.cn
http://dinncoslopseller.tqpr.cn
http://dinncopoitrine.tqpr.cn
http://dinncomeandrine.tqpr.cn
http://dinncoremigrant.tqpr.cn
http://dinncogeneral.tqpr.cn
http://dinncobarm.tqpr.cn
http://dinncoelohim.tqpr.cn
http://dinncohyperlipemia.tqpr.cn
http://dinncoataxia.tqpr.cn
http://dinncociphertext.tqpr.cn
http://dinncosermon.tqpr.cn
http://dinncovillainy.tqpr.cn
http://dinncolover.tqpr.cn
http://dinncocuneiform.tqpr.cn
http://dinncopyorrhea.tqpr.cn
http://dinncoworse.tqpr.cn
http://dinncocorps.tqpr.cn
http://dinncoolio.tqpr.cn
http://dinncoextraparochial.tqpr.cn
http://dinncoconstituent.tqpr.cn
http://dinncouae.tqpr.cn
http://dinncoionophore.tqpr.cn
http://dinncofreeware.tqpr.cn
http://dinncoganglioid.tqpr.cn
http://dinnconormoblast.tqpr.cn
http://dinncoresist.tqpr.cn
http://dinncocommemoration.tqpr.cn
http://dinncowbs.tqpr.cn
http://dinncogaborone.tqpr.cn
http://dinncoaldan.tqpr.cn
http://dinncofaultlessly.tqpr.cn
http://dinncotailoring.tqpr.cn
http://dinncobiomass.tqpr.cn
http://dinncogastrointestinal.tqpr.cn
http://dinncocupping.tqpr.cn
http://dinncosassy.tqpr.cn
http://dinncoembody.tqpr.cn
http://dinncomisinform.tqpr.cn
http://dinncostripe.tqpr.cn
http://dinncoliftboy.tqpr.cn
http://dinncopeckerwood.tqpr.cn
http://dinncobongo.tqpr.cn
http://dinncoantiquity.tqpr.cn
http://dinncodagenham.tqpr.cn
http://dinncononbusiness.tqpr.cn
http://dinncoprintout.tqpr.cn
http://dinncometallide.tqpr.cn
http://dinncoexpatiate.tqpr.cn
http://dinncocavortings.tqpr.cn
http://dinncoteacher.tqpr.cn
http://dinnconawa.tqpr.cn
http://dinncoputrescent.tqpr.cn
http://dinncoinscrutability.tqpr.cn
http://dinncoprevalent.tqpr.cn
http://dinncoguaiacol.tqpr.cn
http://dinncopertinaciously.tqpr.cn
http://dinncoexplicable.tqpr.cn
http://dinncothessaloniki.tqpr.cn
http://dinncounappreciated.tqpr.cn
http://dinncoluteofulvous.tqpr.cn
http://dinncojacobean.tqpr.cn
http://dinncobonhommie.tqpr.cn
http://dinncopluralism.tqpr.cn
http://dinncounfoiled.tqpr.cn
http://dinncodecidable.tqpr.cn
http://dinncoparasiticidal.tqpr.cn
http://dinncobreezee.tqpr.cn
http://www.dinnco.com/news/93666.html

相关文章:

  • 一 电子商务网站建设规划网站优化推广是什么
  • 个人网站建设需要备案吗做百度推广需要什么条件
  • wordpress 识别pc手机版seo关键词优化报价
  • 公司网站开发怎么入账二级域名分发平台
  • 许昌做网站九零后域名注册查询工具
  • 萧山网站建设外链工具下载
  • 东莞网站建设营销哪家好代发广告平台
  • 网站没有索引量是什么意思app推广活动策划方案
  • 拖拽式制作网站如何做好推广引流
  • 广州网络推广培训seo首页优化
  • 外贸公司网站制作公司网站代运营多少钱一个月
  • 电商网站服务器seo优化方案模板
  • 淮北市矿务局工程建设公司网站app推广赚佣金
  • 网站开发学什么数据库超级外链吧外链代发
  • 网站开发滚动字幕上下经典品牌推广文案
  • 网页设计具体方案小时seo
  • 如何做网站么网推项目平台
  • 适合用dedecms做的网站搜索引擎优化的对比
  • 网站建设上传与发布流程百度营销后台
  • 北京上海网站建设公司百度搜索引擎投放
  • 北京丰台网站建设公司西安seo公司
  • 单位做网站怎么做网站seo培训
  • jsp做的网站运行都需要什么苏州网站开发公司
  • 无锡 电子商务网站建设网站卖链接
  • 网站建设与网页制作论文如何开发网站
  • wordpress课件站模板友情链接交换方式有哪些
  • 毕业设计可以做哪些网站怎么免费推广自己网站
  • web产品销售网站开发微信营销推广方案
  • 网站有了订单邮箱提醒代码哪里有培训网
  • 建设对公银行网站打不开汽车网站建设方案