首页 » 猿-技术 » 正文

Dubbo面试大纲

发表于: CoderCoder.cn · 作者: ·  2019-9-7 ·  547 views  ·  31 replies 
本站文章均为原创,转载请注明出处和链接!

Dubbo

简介

  本篇文章不是进行详细的Dubbo实现以及原理分析的文章,适用于用过Dubbo,对Dubbo有一定了解准备面试的小伙伴阅读。下面列的一些点,如果能在面试时候说到,那面试官肯定觉得不错了。

服务暴露

1.从xml读取ServiceBean配置,订阅了spring容器上下文刷新事件进行export动作
2.暴露过程中,如果是延迟暴露,则启动一个线程,延迟delay时长在进行doExport动作
3.会遍历所有的协议,所有的url进行暴露。(这也就是dubbo支持多协议多注册中心)
4.接下来就是一系列的构建url操作(获取ip,端口,提供方法等)
5.将bean进行一个代理(最终调用就不是通过反射调用)换成一个Invoker对象
6.将Invoker对象去注册中心上进行export动作

  • 本地进行暴露,主要就是根据传输层协议扩展点启动一个netty服务,监听一个端口,返回一个exporter对象
  • 将提供者url信息注册到zookeeper,并且监听provider下目录数据的变化
服务引用

1.从xml读取ReferenceBean配置,ReferenceBean实现了FactoryBean接口,会调用getObject进行引用ref
2.通过注册中心想provider目录下的consumers目录下注册本机消费者地址,同时订阅provider下providers、configurators、routers目录数据变化
3.通过获取到provider的url,将提供者的url列表转换成invoker列表
– 转换的过程中,每一个url会初始化创建一个netty新连接,以及开启心跳

4.最终将多个invoker,封装成一个invoker对外使用,封装出来的invoker就继承了集群,负载均衡,容错等功能
5.最后将ReferenceBean进行一个代理,传入上面获取的invoker

服务调用
  • 消费方调用provider方法,会进入到invoker.invoke方法,判断是否走mock,以及集群,容错,负载,在经过一系列的filter,最终调用到具体的一个invoker对象。通过ref时候的client连接向服务端发送一个请求。
    consumer :
    MockClusterInvoker->FailoverClusterInvoke->ListenerInvokerWrapper->ProtocolFilterWrapper->
    ConsumerTraceFilter->InvokeResultLogFilter->FutureFilter->MonitorFilter->DubboInvoker

  • 提供方接受到请求后,进行消息解码,消息转换成Invocation对象,从exporterMap中获取到exporter和Invoker对象,根据方法名调用provider方法,得到返回结果返回

SPI

1.普通扩展点
2.自适应扩展点
3.wrapper扩站点
4.自动激活扩展点

负载均衡-LoadBalance

  • 基于权重的随机(默认负载均衡策略)。首先判断权重是否都相同,如果都相同则直接随机选取,如果权重不一样,则根据权重得到一个总和,遍历来确定某个提供者
  • 基于权重的轮询。同样的首先判断权重是否都相同,如果都相同则根据序号取模轮询,如果不同则序号对最大权重取模得到当前权重,遍历获得比当前权重大的集合在轮询
  • 最少活跃连接数。为每个提供者维护了一个活跃连接数值,获得最少的活跃连接数列表,然后随机取值。
  • 一致性hash。默认一个提供者对应的160个虚拟节点

集群-Cluster

  • 失败转移/失败重试(failover)默认策略)。当调用失败后,根据配置重试次数重新选取另一个提供者进行调用,直至成功或者最大重试次数
  • 可用(available)。遍历所有提供者,只要一个可用就返回
  • 广播(broadcast)。遍历所有提供者,所有都调用一次
  • 失败降级(failback)。调用失败降级,后台记录失败请求,定时重发,适用消息通知操作
  • 快速失败(failfast)。调用失败后,直接报错
  • 失败安全(failsafe)。调用失败后,降级,只记录失败日志,可用户写入审计日志
  • 并行调用(forking)。并行调用,只要有一个成功就返回,通常适用于实时性要求较高场景,但会浪费更多服务资源

使用dubbo过程中遇到的坑

  • 使用(2.5.3)时候,异步调用存在传递,A调B异步调用,B里面去调用C的时候也变成异步调用,拿到是NULL
    解决:在B里面手动调用从RpcContext attachements里面删除异步调用key
    新版本解决这个问题,ContextFilter里面删除了异步调用KEY
  • 版本:(2.6.5)dubbo优雅关闭,spring容器关闭了,dubbo可能还未关闭,造成dubbo请求去获取redis连接时候报连接池已经关闭,报错。
    解决:利用spring关闭提供的Lifecycle接口start, stop钩子,执行时机在spring关闭destroyBean之前,这样等dubbo关闭了spring在关闭
    利用spring关闭提供的ContextCloseEvent事件

  • 使用(2.5.3)时候,Provider方在ContextFilter之前如果自己设置参数到RpcContext#attachements中,到后面就没有了,经过ContextFilter就被覆盖了

2.6.5相较于2.5.3 diff

1.替换zkClient为Apache Curator
2.增加QOS模块
3.外部化配置
4.ServiceConfig hostToRegistry

不好的点

  • 很多兼容的代码,和很多重复的判断,可以去掉精简

使用到设计模式:

1.模版模式
2.代理模式
3.装饰器模式

1.SPI ExtensionLoader
2.ServiceConfig export服务暴露
2.ReferenceConfig refer服务引用
3.服务一次调用过程

provider接收请求处理类流程:
NettyHandler->MultiMessageHandler->HeartbeatHandler->AllChannelHandler->DecodeHandler->HeaderExchangeHandler->DubboProtocol(requestHandler)

consumer filter:
MockClusterInvoker->FailoverClusterInvoke->ListenerInvokerWrapper->ProtocolFilterWrapper->ConsumerTraceFilter->InvokeResultLogFilter->FutureFilter->MonitorFilter->DubboInvoke

本文链接: http://codercoder.cn/index.php/2019/09/dubbo-interview/
«上一篇: :下一篇»

评论区

  1. Leanne发表于:2021-07-12 13:17

    Thanks designed for sharing such a nice thinking, piece of writing is nice,
    thats why i have read it entirely

  2. Grazyna发表于:2021-07-17 02:33

    Hi colleagues, how is all, and what you wish for to say regarding this
    article, in my view its really awesome in favor
    of me.

  3. Pure Optimum Keto Burn Review发表于:2021-07-17 15:02

    Quality articles is the main to invite the users to pay a quick visit the web page, that’s what this web site is providing.

    My page – Pure Optimum Keto Burn Review

  4. http://forum.adm-tolka.ru发表于:2021-07-17 20:21

    I always was interested in this topic and still am, thanks
    for posting.

    Also visit my web site … http://forum.adm-tolka.ru

  5. Good blog you’ve got here.. It?s difficult to find quality writing like yours nowadays.
    I truly appreciate individuals like you! Take care!!

    Feel free to surf to my homepage: http://myweddinglight.us/index.php?action=profile;u=128271

  6. Cryogen Air Cooler发表于:2021-07-17 20:55

    Thanks for some other informative web site.
    The place else may I get that type of info written in such an ideal method?

    I have a project that I am simply now operating on, and I’ve been on the
    look out for such info.

    Here is my blog post :: Cryogen Air Cooler

  7. Jacelyn发表于:2021-07-17 22:56

    Attractive section of content. I just stumbled upon your website and in accession capital to assert that I acquire actually
    enjoyed account your blog posts. Anyway I’ll be subscribing
    to your feeds and even I achievement you access consistently rapidly.

  8. instagram takipci satin al发表于:2021-07-17 23:44

    Great article, just what I was looking for.

  9. playboy2 vip发表于:2021-07-18 00:13

    I loved as much as you’ll receive carried out right here.
    The sketch is tasteful, your authored material stylish. nonetheless, you command get got an nervousness over that
    you wish be delivering the following. unwell unquestionably come further formerly again as exactly the same nearly
    a lot often inside case you shield this hike.

    Here is my web site :: playboy2 vip

  10. TechPro Wifi发表于:2021-07-18 00:27

    This is really fascinating, You’re a very
    skilled blogger. I’ve joined your rss feed and look ahead to seeking extra of
    your wonderful post. Also, I have shared your site in my social networks!

    Also visit my web page … TechPro Wifi

  11. New Flow XL发表于:2021-07-18 01:15

    Appreciate the recommendation. Let me try it out.

    Also visit my homepage … New Flow XL

  12. Pure Optimum Keto发表于:2021-07-18 01:45

    I blog quite often and I genuinely appreciate your information. This article has really
    peaked my interest. I will take a note of your site and keep checking for new details about once a week.
    I opted in for your RSS feed too.

    Here is my website: Pure Optimum Keto

  13. Solvolt Charger发表于:2021-07-18 01:55

    Pretty section of content. I just stumbled upon your
    blog and in accession capital to assert that I get in fact
    enjoyed account your blog posts. Anyway I will be subscribing to your augment and even I achievement you access
    consistently rapidly.

    My blog post; Solvolt Charger

  14. Gaia's Choice CBD Isolate发表于:2021-07-18 02:33

    I do not even know how I finished up here, however I thought
    this submit was once great. I do not recognise who you are however definitely you are going to a famous blogger if you happen to aren’t already 😉 Cheers!

    Visit my web-site :: Gaia’s Choice CBD Isolate

  15. Xoth Keto BHB Review发表于:2021-07-18 02:40

    Hello! I’m at work browsing your blog from my new apple iphone!
    Just wanted to say I love reading through your blog and
    look forward to all your posts! Carry on the fantastic work!

    My blog post: Xoth Keto BHB Review

  16. Gretchen发表于:2021-07-18 04:28

    Thank you for each of your efforts on this site. Gloria enjoys doing internet research and it’s really obvious why.
    We hear all relating to the compelling way you create precious techniques through your blog and as well attract
    contribution from the others on that area of interest while our favorite girl is actually being taught so much.
    Have fun with the remaining portion of the year. You are always doing a good job.

    Also visit my homepage; Gretchen

  17. is bitcoin gambling legal in the us发表于:2021-07-18 04:53

    Greetings! Very helpful advice in this particular post!
    It’s the little changes which will make the biggest changes.
    Thanks for sharing!

  18. Annette发表于:2021-07-18 05:38

    Heya i am for the first time here. I found this board and I find It truly useful & it helped me out much.

    I hope to give something back and aid others like you
    helped me.

    Also visit my web blog :: Annette

  19. www.goldenanapa.ru发表于:2021-07-18 22:27

    I conceive other website owners should take this site as an example, very clean and wonderful user genial design and style.

    Feel free to surf to my blog :: http://www.goldenanapa.ru

  20. anapapansion.ru发表于:2021-07-18 23:16

    Great post.

    My web site … anapapansion.ru

  21. https://tanhuaba.xyz/发表于:2021-07-19 04:30

    Thanks for the good writeup. It actually used to be a entertainment account it.
    Look complicated to more introduced agreeable from you!

    However, how could we keep in touch?

    Look at my homepage … https://tanhuaba.xyz/

  22. Muama Ryoko发表于:2021-07-19 09:37

    I think that is among the most significant info for me.
    And i’m glad reading your article. But should observation on some general issues,
    The site style is great, the articles is truly great :
    D. Excellent process, cheers.

    Here is my web-site Muama Ryoko

  23. SoloVolt Reviews发表于:2021-07-19 15:08

    I am sure this article has touched all the internet viewers, its really
    really nice article on building up new weblog.

    Also visit my web site: SoloVolt Reviews

  24. craksracing.com发表于:2021-07-20 21:50

    I needed to write you that very small observation in order
    to say thank you once again for these pleasing concepts you
    have documented in this case. It’s surprisingly generous
    with you to make openly all that a number of us could have
    advertised for an e-book to earn some dough on their own,
    notably seeing that you might well have done it in case you decided.
    Those good tips additionally served to become a fantastic way to know
    that some people have the identical eagerness the same
    as mine to know the truth lots more regarding this
    matter. I think there are many more pleasurable times ahead for many who take a look at your website.

    my site – craksracing.com

  25. SoloVolt Solar Charger发表于:2021-07-21 00:19

    I savour, cause I found just what I used to be taking a look for.
    You’ve ended my four day lengthy hunt! God Bless you man. Have a nice day.
    Bye

    Here is my web page SoloVolt Solar Charger

  26. Eggplant Explosion Reviews发表于:2021-07-21 04:34

    Enjoyed looking through this, very good stuff, appreciate
    it.

    my web-site :: Eggplant Explosion Reviews

  27. cacophonyfarm.com发表于:2021-07-21 09:55

    Neat blog! Is your theme custom made or did you download it
    from somewhere? A design like yours with a few simple tweeks would really make my blog stand
    out. Please let me know where you got your theme. Thanks

    Feel free to surf to my web-site – cacophonyfarm.com

  28. It’s truly very complex in this busy life to listen news on TV,
    thus I only use internet for that reason, and take the most
    up-to-date news.

    Look into my web blog … http://vip5.moisait2021.ru/viewtopic.php?id=58562

  29. Alpha Extracts CBD发表于:2021-07-22 13:33

    Hi would you mind sharing which blog platform you’re working
    with? I’m planning to start my own blog in the near future but I’m having
    a hard time choosing between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different
    then most blogs and I’m looking for something completely unique.
    P.S Apologies for being off-topic but I had to ask!

    Also visit my homepage; Alpha Extracts CBD

  30. Xoth Keto BHB Ingredients发表于:2021-07-22 16:31

    Enjoyed looking through this, very good stuff, regards.

    my webpage: Xoth Keto BHB Ingredients

  31. Herbivore CBD Review发表于:2021-07-23 11:40

    I have been exploring for a little for any high-quality articles or weblog
    posts in this sort of house . Exploring in Yahoo I eventually
    stumbled upon this website. Studying this information So i’m glad to convey that I have a very just right uncanny feeling I found
    out exactly what I needed. I so much undoubtedly will make
    certain to do not forget this web site and give it a look regularly.

    Feel free to visit my website … Herbivore CBD Review