Dubbo's past and present life

roshilikang 2021-09-15 04:25:01
dubbo present life


This article has been included https://github.com/lkxiaolou/lkxiaolou welcome star.

background

A long time ago , Website application is the architecture of single application , The flow is small , All functions 、 The code is all deployed together , The cost is low . At this point, the database access framework ORM Is the key .

Later, the flow gradually increased , The single application is divided into several unrelated applications , This is the Vertical Architecture , At this time, the development of the front-end page is accelerated Web frame MVC Is the key .

later , Vertical applications are growing , Interaction between applications is inevitable , Distributed service framework RPC It became the key .

dubbo

RPC, Full name Remote Procedure Call, Remote procedure call , In a word, calling remote objects is as convenient and simple as calling local methods . common RPC Framework has dubbo、grpc、thrift etc. .

dubbo, |ˈdʌbəʊ| It's a high performance 、 Lightweight open source Java RPC frame , It provides three core competencies : Interface oriented remote method call , Intelligent fault tolerance and load balancing , And automatic service registration and discovery . Currently in use dubbo There are so many companies .

All men are mortal

dubbo The course of development can be summarized as 3 Stages :

  • The birth of Ali :dubbo Previous life 2008 It was born inside Ali in ,2011 In open source ,2012 Released in 2.5.3 Stop updating after version
  • We should continue our life :2014 Dangdang released dubbox, It's based on Alibaba open source dubbo 2.5.3 Version added rest Agreed dubbo edition
  • Restart the summit apache:2017 In 1997, Ali was rebooted dubbo project , And in 2018 in apache incubation ,2019 Become a year apache Top projects , It also released dubbo.js,dubbo-go Wait for multiple languages dubbo edition ,2020 Released in 3.0 A strategic plan for the development of cloud based projects

The main versions currently supported are 2.6.x and 2.7.x:

  • 2.6.x Mainly with bugfix And a small amount enhancements Mainly , So it can guarantee the stability completely
  • 2.7.x As the main development version of the community , Get continuous updates and add a lot of new feature And optimization , It also brings some stability challenges

agreement

dubbo The native protocol is defined as follows :

  • 0-15: magic number , Judge whether it is dubbo agreement
  • 16: Decide whether to request or return
  • 17: Determine whether you expect to return
  • 18: Determine whether it is an event message , Like a heartbeat event
  • 19-23: Serialization flag
  • 24-31: Flag response status ( similar http status)
  • 32-63: request id
  • 64-95: The length of the content ( byte )
  • 96-?: Serialized content ( Newline separator )

dubbo The advantage of the protocol is its compact design 、 Request response header Agreement ; The disadvantage is that you can't pass header Location resources ,header and body There is redundancy in the fields , The agreement cannot be extended .

Of course, it also supports the extension of multiple protocols , As Dangdang expanded rest agreement , And the latest support grpc Agreements, etc

When it comes to expansion , May be dubbo The highlight of design ,dubbo The extension of is based on SPI(Service Provide Interface) Design , Can be non intrusive code to achieve a lot of functions .

Registry Center

The registry has the following characteristics :

  • Dynamic join , Service providers dynamically expose themselves to consumers through the registry , No need for consumers to update profiles one by one .
  • Dynamic discovery services , Consumers can dynamically discover new services , No need to restart to take effect .
  • Unified configuration , Avoid the inconsistency of each service configuration caused by local configuration .
  • Dynamic adjustment , Registry supports dynamic parameter adjustment , The new parameters are automatically updated to all relevant service nodes .
  • Unified management , Rely on registry data , Service nodes can be managed and configured uniformly .dubbo Mainstream registries generally use zookeeper perhaps nacos, There are many other extension implementations .

colony

The cluster contains routing 、 Load balancing and cluster fault tolerance , Let's look at the differences in these three aspects from an example :

One dubbo User services for , Deployed in Beijing 10 individual , Deployed in Shanghai 20 individual . A service consumer in Hangzhou initiated a call , And then the following happened :

  1. According to the configured routing rules , If Hangzhou initiated the call , It will be routed to the nearest Shanghai 20 individual provider.
  2. According to the configured random load balancing strategy , stay 20 individual provider Randomly selected one to call
  3. Let's say it's random 7 individual provider. As a result, call the second 7 individual provider failed . configurable failover Cluster fault tolerant mode , Retry other servers . Tried the second time again 13 individual provider, Successful call . here 1 Corresponding to the route ,2 Corresponding to load balancing ,3 Corresponding to cluster fault tolerance .

filter

stay dubbo In the overall design of ,filter It's a very important concept , Include dubbo Most of its functions , All are based on this extension point , During each call ,filter All interceptions will be executed .filter It's a design pattern of responsibility chain :

common filter: Monitoring and management 、 logging 、 Current limiting the drop 、 Authentication etc. .

Three centers

The three centers refer to the registration centers , Metadata Center , Configuration center . Why three centers are needed , You can see one dubbo Data registered in the registry :

/dubbo/org.apache.dubbo.demo.DemoService/providers/dubbo%3A%2F%2F172.23.234.48%3A20880%2Forg.apache.dubbo.demo.DemoService%3Fanyhost%3Dtrue%26application%3Ddubbo-demo-api-provider%26default%3Dtrue%26deprecated%3Dfalse%26dubbo%3D2.0.2%26dynamic%3Dtrue%26generic%3Dfalse%26interface%3Dorg.apache.dubbo.demo.DemoService%26metadata-type%3Dremote%26methods%3DsayHello%2CsayHelloAsync%26pid%3D21563%26release%3D%26side%3Dprovider%26timestamp%3D1600336623852

You can see that there's a lot of data , It's also interface level data , When there are more and more interfaces , There's more and more pressure on the registry , More and more data is being pushed by change .

therefore , We need metadata center and configuration center to relieve the pressure of registry . Infrequently changing data can be placed in the metadata Center .

/dubbo/org.apache.dubbo.demo.DemoService/providers/dubbo%3A%2F%2F172.23.234.48%3A20880%2Forg.apache.dubbo.demo.DemoService%3Fapplication%3Ddubbo-demo-api-provider%26deprecated%3Dfalse%26dubbo%3D2.0.2%26timestamp%3D1600336144382

So is the configuration center , If there is no configuration center, the full amount will be changed url Push it down , With the configuration center, you just need to push the changed configuration .

Generalization call

Our common dubbo The calling method is to introduce provider Defined interfaces jar package , But without this jar package , Can I initiate a call ? Yes, of course , There are scenes like this , For example, service testing platform ,dubbo Service gateway, etc . Just know the interface name , Parameters and other information can be called .

The future development

dubbo At that time, the future planning actually took a curve , It's not a single step to the original direction of the cloud .2019 I want to go in the direction of responsive programming ( Or reactive programming ).IO Intensive application , In general, thread pool is one of the important factors limiting throughput , hypothesis consumer Thread pool is 100,provider The response time of the interface is 500ms,consumer Of qps Cap of (1000 / 500) x 100 = 200. Responsive programming is the solution to this problem .

Responsive programming (reactive programming) It's based on data flow (data stream) And the transmission of change (propagation of change) The declarative form of (declarative) Programming paradigm .RSocket It's a support reactive-stream Semantic open source network communication protocol , It will reactive The complex logic of semantics is encapsulated , So that the upper layer can easily realize the network program .Dubbo stay 3.0.0-SNAPSHOT The version is based on RSocket Support for responsive programming , Users can use it in request parameters and return values Mono and Flux Object of type .

But in the 2020 year , With the rise of cloud native concept and the landing of large factories one after another ,dubbo Can it also develop in this direction ?

Cloud nativity is based on containers 、 Service Grid 、 Microservices 、 Immutable infrastructure and declarative API Build flexible and scalable applications , Based on automation technology to build with high fault tolerance 、 A loosely coupled system that is easy to manage and easy to observe , Build a unified open source cloud technology ecosystem , It can be decoupled from the services provided by cloud vendors .

dubbo Service level registration discovery for , And k8s Application level service discovery of container choreography violates ,dubbo yes “ heavy sdk”, Contrary to easy management .

So in the latest version, application level service discovery is supported , It used to be such an interface :

/dubbo/org.apache.dubbo.demo.DemoService/providers/dubbo%3A%2F%2F172.23.234.48%3A20880%2Forg.apache.dubbo.demo.DemoService%3Fapplication%3Ddubbo-demo-api-provider%26deprecated%3Dfalse%26dubbo%3D2.0.2%26timestamp%3D1600336144382

Using application level service discovery to register with the registry is like this

/services/dubbo-demo-api-provider/172.23.234.48:20880

And heavy sdk, The future may be mesh improve , It is said that Ali already has dubbo mesh It's a new line of business .


WeChat official account " Master bug catcher ", Back end technology sharing , Architecture design 、 performance optimization 、 Source code reading 、 Troubleshoot problems 、 Step on the pit practice .

版权声明
本文为[roshilikang]所创,转载请带上原文链接,感谢
https://javamana.com/2021/09/20210909112309720w.html

  1. Java 16 is coming online. You can't even use the features of Java 8, can you?
  2. Java (3) basic data types and their type conversion
  3. 一位Java大牛的BAT面试心得与经验总结,2021年Java春招面试经历,
  4. 一举拿下腾讯美团滴滴offer,快来瞧瞧这份Spring面试小抄!
  5. 一个Java应届生从上海离职,万字长文总结Java多进程,
  6. Seven design principles of java object-oriented design pattern
  7. 一個Java應届生從上海離職,萬字長文總結Java多進程,
  8. Un nouvel étudiant Java a quitté Shanghai et a résumé plusieurs processus Java.
  9. Prenez d'un coup l'offre de Tencent meituan et jetez un coup d'oeil à cette copie de l'entrevue de printemps!
  10. L'expérience et l'expérience d'un Maverick Java en matière d'entrevue sur les MTD, l'expérience de l'entrevue d'embauche du printemps Java en 2021,
  11. Interface graphique X: mise à jour des tables de rendu et optimisation du Code (compilation intégrée 10)
  12. Widget de vérification de fichiers personnalisés Linux
  13. Java thread pool - work queue
  14. [Part 7] - Summary of B2B2C e-commerce technology of spring cloud live mall managed by git branch
  15. Reflection type of Java Foundation
  16. Want to get started with data structures, but always fall under the pomegranate skirt of the linked list?
  17. Interviewer: do redis transactions satisfy atomicity?
  18. 一篇文章教你搞定计算机网络面试,350道Java面试真题分享,
  19. 一条正确的Java职业生涯规划,揭秘今年Java春招面试必问问题有哪些?
  20. 一名毕业三年的女程序媛面试头条经验,关于Redis主从节点数据过期一致性的思考,
  21. Huawei cloud guassdb (for redis) released a new version: Lua script and SSL connection encryption
  22. Java thread pool - work queue
  23. 一名畢業三年的女程序媛面試頭條經驗,關於Redis主從節點數據過期一致性的思考,
  24. Trois ans d'expérience d'entrevue avec une femme de programmation diplômée, une réflexion sur la cohérence de l'expiration des données de redis Master slave Node,
  25. Un plan de carrière Java correct, découvrez les questions que vous devez poser lors de l'entrevue d'embauche du printemps Java de cette année.
  26. 万字详解微服务的哨兵机制,架构师带你玩转Redis高性能缓存设计实战,
  27. Un article vous a appris à gérer les entrevues sur le Web, à partager 350 vraies questions d'entrevue Java,
  28. Jquery Tools Methodology collation, Sharing a little interview Experience
  29. Tutoriel de développement Java, compétences de base nécessaires pour interviewer un programmeur Java dans une grande usine,
  30. "Anti Mafia storm" has just finished, another criminal investigation play has come, and the supporting actor is more popular than the protagonist
  31. 萬字詳解微服務的哨兵機制,架構師帶你玩轉Redis高性能緩存設計實戰,
  32. L'architecte vous guidera dans la conception de cache haute performance de redis.
  33. Linux驱动开发: 杂项字符设备
  34. Jquery plug - in urianchor, app front end Development
  35. Linux驅動開發: 雜項字符設備
  36. Développement de pilotes Linux: périphériques de caractères divers
  37. Utilisez @ async dans Spring boot pour effectuer des appels asynchrones et accélérer l'exécution des tâches!
  38. $in jquery, Visualized Web Development Tool
  39. Le développement Java doit être fait. Les entrevues https demandent souvent une analyse complète.
  40. 不明白JVM虚拟机还怎么面试,一起刷完了这份1307页的Java面试宝典吧,
  41. 不断提升自己创造溢价的能力,字节跳动 阿里 华为 腾讯等大厂Java面试题,
  42. Jdk's Past Life: The Classic Features of Thin Number - java5 - - - 15 -, webfront Development
  43. Résumé des questions d'entrevue pour les ingénieurs en développement Java, analyse des questions d'entrevue à haute fréquence Dubbo,
  44. Améliorer continuellement leur capacité à créer des primes, et les questions d'entrevue Java d'Alibaba Huawei Tencent et d'autres grandes usines sont sautées en octets.
  45. Install docker YJ version of openSUSE 11.3
  46. Je ne comprends pas comment la machine virtuelle JVM peut encore interviewer, et j'ai terminé ce dictionnaire d'entrevue Java de 1307 pages.
  47. 中软国际Java机试,如何写出高效率的SQL?
  48. 中级Java工程师面试,阿里 头条 腾讯等大厂Java笔试题目分享,
  49. 两年Java开发经验,为什么spring能最好地改变Java?
  50. Echarts realizes the rotation of the moon (super simple, you can see it at a glance)
  51. Deux ans d'expérience dans le développement de Java, pourquoi Spring peut - il le mieux changer Java?
  52. Entretien d'ingénieur Java intermédiaire, partage de sujets d'examen écrit Java de grandes usines comme Alibaba headline Tencent,
  53. Zhongsoft International Java Machine test, comment écrire un SQL efficace?
  54. Reflection type of Java Foundation
  55. Comment gérer efficacement les changements dans les ressources k8s?Analyse du mécanisme de mise en œuvre de k8s informer
  56. Installation de jdk1.8
  57. MySQL column - Linux underlying interaction and RAID storage architecture
  58. Interviewer: do redis transactions satisfy atomicity?
  59. 兩年Java開發經驗,為什麼spring能最好地改變Java?
  60. Migration practice from zookeeper to Nacos