《贝聊微服务架构实战历程》-杨钦民

内容大纲:

  • 业务背景介绍
  • 诞生期 技术架构选型
  • 成长期 技术架构重构
  • 爆发期 微服务架构
展开查看详情

1.ᨬᘱங๐‫ۓ‬ຝ຅ਫ౴ܲᑕ ๷ᰭ࿆ ᨬᘱದ๞ᶶᳯ

2.๷ᰭ࿆ ᨬᘱದ๞ᶶᳯ ᨮᨱᨬᘱᎸ‫֛ݎ‬ᔮୌᦡ̵ࢫᴚୌᦡ̵Ո಍ङِ ຅ୌᨬᘱங๐‫ۓ‬ຝ຅֛ᔮ̵ଘ‫ݣ‬ຝ຅֛ᔮ̵ᛔ ۖ۸ᬩᖌ֛ᔮ

3.1 ӱ‫ۓ‬ᙧวՕᕨ 2 ᦿኞ๗-ದ๞ຝ຅ᭌࣳ 3 ౮ᳩ๗-ದ๞ຝ຅᯿຅ 4 ᆷ‫ݎ‬๗-ங๐‫ۓ‬ຝ຅

4.1 ӱ‫ۓ‬ᙧวՕᕨ

5.‫ى‬ԭᨬᘱ • ᨬᘱ౮ᒈԭ2013ଙ҅ฎӾࢵଞ‫ࢮد‬ਹᳩૡ֢ଘ‫ݣ‬ • ᛘ‫ێ‬ԭ᭗ᬦ԰ᘶᗑԾߝ݊ਧ‫ګ‬۸ᥴ٬ොໜ҅ଆۗଞ‫ࢮد‬ᥴ ٬઀ᐏ̵᭗Ꭳ̵ဋ᭗ᒵਹᳩૡ֢Ӿጱዳᅩ҅‫׏‬ᬰਹࢮ‫ى‬ᔮ ޾᧯

6.2 ᦿኞ๗-ದ๞ຝ຅ᭌࣳ

7.ದ๞ຝ຅ᭌࣳᘍᡤᅩ Ꮈ‫ݎ‬ᩒრ Ꮈ‫ݎ‬Ո‫ێ‬ ದ๞‫ؙ॓‬ ள᭛Ꮈ‫ݎ‬

8.ದ๞ຝ຅ Android IOS PC አಁ੶ Nginx ള‫੶ف‬ 3‫ݣ‬ECS๐‫࢏ۓ‬ NginxӨᔮᕹ᮱ᗟࣁ1‫ݣ‬๢࢏ ӱ‫ۓ‬ᔮᕹ ᔮᕹ੶ RDSහഝପ1‫ݣ‬๢࢏ Memcache1‫ݣ‬๢࢏ RDSහഝପ Memcacheᖨਂ ਂ‫੶ؙ‬

9.ದ๞ຝ຅ᇙᅩ ‫֛ܔ‬ຝ຅ ள᭛Ꮈ‫ݎ‬ ֗౮๜ • ‫֛ܔ‬ຝ຅҅ຝ຅ᓌ‫҅ܔ‬Ⴔศጱ‫੶ړ‬ᕮ຅ • ‫ݢ‬զள᭛Ꮈ‫҅ݎ‬ჿ᪃Ծߝள᭛ᬽդᵱ࿢ • ဌํ॔๥ጱದ๞҅ದ๞਍ԟ౮๜֗҅‫ݶ‬෸ᬩᖌ౮๜֗҅෫ᵱӫӱጱᬩᖌ҅ᜓ፜୏ඪ

10.3 ౮ᳩ๗-ದ๞ຝ຅᯿຅

11.ದ๞ຝ຅᯿຅ॶ๢ ӱ‫઀ݎۓ‬ ള‫ݗ‬ਧԎ ӱ‫ۓ‬ᘠ‫ݳ‬ ᬥ᭛ ӧᥢ᝜ ᔲੂ ‫و‬አහഝ ᘠ‫ݳ‬ᒫӣ හഝପᦡ ପ ො๐‫ۓ‬ ᦇႰԤ

12.ᔮᕹೆ‫ړ‬ Kindergarten Community Card API API API kindergarten Community Card य़ᔮᕹೆ‫ڊړ‬ग़ӻӱ‫ۓ‬ᇿᒈৼᔮᕹ ‫ݣݸ‬ ‫ݣݸ‬ ‫ݣݸ‬ ग़ᔮᕹᖀᖅ‫و‬አ‫ݶ‬ӞӻRDSහഝପ ӧ‫ݶ‬ӱ‫ۓ‬ᔮᕹԏᳵӧᚆ԰ፘᦢᳯᤒ RDSහഝପ

13.DBೆ‫ړ‬ Kindergarten Community Card API API API kindergarten Community Card ‫ݣݸ‬ ‫ݣݸ‬ ‫ݣݸ‬ ‫ৼݱ‬ᔮᕹׁᩢጱᤒᇿᒈೆ‫ړ‬ ᇿᒈRDSහഝପ ਫሿහഝପԆ՗‫ړ‬ᐶ හഝପᇔቘᵍᐶ Kindergarten Community Card RDS master RDS master RDS master RDS slave RDS slave RDS slave

14.‫ྍڡ‬๐‫ۓ‬۸ Kindergarten Card API RPC᧣አ API kindergarten Card ‫ݣݸ‬ ‫ݣݸ‬ Hessianਫሿᓌ‫ܔ‬RPC᧣አ ᇿᒈᒫӣො๐‫ۓ‬ RPC᧣አ RPC᧣አ Push๐‫ۓ‬ SMSᎨ‫מ‬๐‫ۓ‬

15.ᨮ᫹࣐ᤍ SLB SLB Nginx Nginx Nginx ग़SLBᨮ᫹࣐ᤍ ग़Nginx‫ݻݍ‬դቘᨮ᫹࣐ᤍ ᭿‫ܔع‬ᅩඳᵑ ᔮᕹ1 ᔮᕹ2 ᔮᕹ3 ᔮᕹ1 ᔮᕹ2 ᔮᕹ3 ᔮᕹ1 ᔮᕹ2 ᔮᕹ3

16.ದ๞ຝ຅ Androidᘌ૵ᇇ IOSᘌ૵ᇇ PC web አಁ੶ Androidਹᳩᇇ IOSਹᳩᇇ ᘍ۪APP SLB SLB ള‫੶ف‬ Nginx Nginx Nginx Kindergarten Card Community ᔮᕹ੶ Agent Check ᒫӣො SMS๐‫ۓ‬ IM๐‫ۓ‬ Push๐‫ۓ‬ ๐‫੶ۓ‬ MQ ਂ‫੶ؙ‬ Memchache Redisᵞᗭ RDS

17.ದ๞ຝ຅ᇙᅩ ‫૲ړ‬ୗ ᔮᕹᕆ ‫ྍڡ‬๐‫ۓ‬ ຝ຅ ೆ‫ړ‬ ۸ DBᇔቘᵍ MQձ‫ۓ‬ SLBᨮ᫹ ᐶ ୑ྍ۸ ࣐ᤍ

18.4 ᆷ‫ݎ‬๗-ங๐‫ۓ‬ຝ຅

19.ங๐‫ۓ‬ದ๞ຝ຅ਫෞॶ๢ ӱ‫ۓ‬ṛ᭛ ӱ‫ۓ‬᭦ᬋ ӱ‫࣋ۓ‬ว ‫઀ݎ‬ ᘠ‫ݳ‬ ॔๥ አಁᥢཛྷ Ꮈ‫ݎ‬Ոާ դᎱᥢཛྷ ᆷ‫ݎ‬ ಘୟ ᛆᙡ

20.ਫෞங๐‫ۓ‬ጱ‫پ‬ӻ‫ى‬Ძᅩ զ๐‫ۓ‬ԅ ຂᘠ‫ݳ‬ ṛಘ઀ Ӿஞ • զ๐‫ۓ‬ԅӾஞ҅Ӟ‫ڔ‬᮷ฎ๐‫ྯ҅ۓ‬ӻ๐‫ۓ‬᮷ᰒ੒‫ܔ‬Ӟӱ‫ۓ‬ᬰᤈ੗ᤰ҅‫ۑᦤכ‬ᚆਠෆ௔޾ᘳᨱ‫ܔ‬Ӟ௔ • ຂᘠ‫ݳ‬௔҅๐‫ۓ‬ԏᳵ‫ۑ‬ᚆᇿᒈ҅ᚆड़ᇿᒈ᮱ᗟ҅๐‫ۓ‬ԏᳵፘ԰ׁᩢ • ṛಘ઀௔҅‫ړ‬වᩒრ҅ࢫᴚ‫ݶܐ‬ૡ֢҅‫ݢ‬෫ᴴಘ઀҅ๅṛጱդᎱ᯿አሲ

21.Dubboங๐‫ۓ‬໛ຝ ဳٙӾஞᵞᗭ 2 subscribe 1 register 3 notify ங ங๐‫ۓ‬ၾᩇᘏ ங๐‫ۓ‬൉‫׀‬ᘏ ๐ ౮ᆧጱṛ௔ᚆ‫૲ړ‬ୗ໛ຝ҅ྲ᫾ᑞਧ ‫ۓ‬ ᓕ Consumer 4 invoke Provider ෫ᖲള‫ف‬Spring໛ຝ ቘ ଘ ٍ॓๐‫ဳۓ‬̵ٙ‫ݎ‬ሿ̵᪠ኧ̵ᨮ᫹࣐ᤍ̵ᴳᕆ̵๦᯿ ‫ݣ‬ ᧣ᜓ Consumer Provider դᎱ୏რ҅‫ݢ‬զਧ‫ګ‬۸ಘ઀‫ۑ‬ᚆ 5 count ங๐‫ۓ‬ፊഴଘ‫ݣ‬

22.Dubboங๐‫ۓ‬໛ຝಘ઀ԏദ๦๐‫ۓ‬ ԅྯӞӻ๐‫ړۓ‬ᯈӞӻAPPID҅consumer᭗ᬦ attachment಩appIdփ᭓ᕳprovider ӧ᭗ᬦ Consumerᦡᗝғ RpcContext.getContext().setAttachment(“appId”,123); ࣁprovider᧛‫ݐ‬appIdғ invoke ḵᦤ String appId=invocation.getAttachment(“appId”); Consumer Provider ദ๦๐‫ۓ‬ ᬬࢧᕮຎ ᭗ᬦ რappId ᥝᦢᳯጱappId ‫ݢ‬զᦢᳯጱള‫ݗ‬ app1 app2 com.biz.UserProvider.getUser app1 app2 com.biz.PushProvider.* app2 App3 *

23.Dubboங๐‫ۓ‬໛ຝಘ઀ԏᕹᦇӾஞ pull push Consumer Filebeat pull push Logstash pull push Consumer Filebeat ElasticSea Dubboള Kafka pull push Logstash rch ‫ݗ‬௔ᚆ Cluster Cluster ᕹᦇ pull push Provider Filebeat pull push Logstash push pull Provider Filebeat

24.Dubboங๐‫ۓ‬໛ຝಘ઀ԏᕹᦇӾஞಸᤒ ള‫ݗ‬ᘙ෸ഭᤈ ᔄࣳ ๐‫ۓ‬ ොဩ ᘙ෸>=100ms ௛හ ጯ‫ྲړ‬ PROVIDER com.ibeiliao.aaa.bbbProvider test 1000 10000 10% Consumer com.ibeiliao.ccc.ddd get 100 10000 1% ള‫ݗ‬०ᨳഭᤈ ᔄࣳ ๐‫ۓ‬ ොဩ ०ᨳහ ௛හ ጯ‫ྲړ‬ PROVIDER com.ibeiliao.eee.fffProvider add 50 10000 0.5% Consumer com.ibeiliao.ee1.ff2 test 20 10000 0.2%

25.Dubboங๐‫ۓ‬໛ຝಘ઀ԏᕹᦇӾஞಸᤒ ᔮᕹᦢᳯᰁഭᤈ ๋ṛQPS෸॒ቘ෸ᳵ>1sጱ ᔮᕹ‫ݷ‬ᑍ ᦢᳯᰁ ੒ྲฌॠ ๋ṛQPS ๋ṛQPS෸ᳵ හᰁ ᔮᕹ1 10000000 +20% 3000 2018-02-18 18ғ00ғ00 20 ᔮᕹ2 3000000 -10% 900 2018-02-18 19ғ00ғ00 10 ള‫ᦢݗ‬ᳯᰁഭᤈ ๋ṛQPS෸॒ቘ෸ᳵ>1sጱ ള‫ݷݗ‬ᑍ ᦢᳯᰁ ੒ྲฌॠ ๋ṛQPS ๋ṛQPS෸ᳵ හᰁ ള‫ݗ‬1 2000000 -1% 800 2018-02-18 19ғ00ғ00 5 ള‫ݗ‬2 400000 +0% 100 2018-02-18 20ғ00ғ00 1

26.ங๐‫ۓ‬ຝ຅ଘჶᄍᬰ ‫ࣘܔ‬๐‫ۓ‬ ‫ࣘܔ‬๐‫ۓ‬ ۖா ᐒ‫܄‬ ۖா ᐒ‫܄‬ ۖா ᐒ‫܄‬ ۖா ᐒ‫܄‬ դᎱ դᎱ դᎱ դᎱ ๐‫ۓ‬ ๐‫ۓ‬ ๐‫ۓ‬ ๐‫ۓ‬ ‫ࣘܔ‬ᤒ ۖாᤒ ᐒ‫܄‬ᤒ ۖாᤒ ᐒ‫܄‬ᤒ ۖா ᐒ‫܄‬ ᕮ຅ ᕮ຅ ᕮ຅ ᕮ຅ ᕮ຅ හഝପ හഝପ 1 ‫ܔ‬Ӟ๐‫ۓ‬ 2 ‫ܔ‬Ӟ๐‫ۓ‬ 3 ग़๐‫ۓ‬ 4 ग़๐‫ۓ‬ ‫ܔ‬Ӟᤒᕮ຅ ग़ᤒᕮ຅ ग़ᤒᕮ຅ ग़හഝପ

27.ங๐‫ۓ‬ຝ຅ਫෞ ᔮᕹ ங๐‫ۓ‬A ங๐‫ۓ‬B ங๐‫ۓ‬C ᇿᒈӱ‫ۓ‬ೆ‫ړ‬ங๐‫҅ۓ‬ᇿᒈ᮱ᗟ ங๐‫ۓ‬A ங๐‫ۓ‬B ங๐‫ۓ‬C ᔮᕹ‫ۑ‬ᚆ‫ق‬᮱᭗ᬦ᧣አங๐‫ۓ‬ਫሿ҅ᔮᕹӧᚆፗ ളᦢᳯDB ྯӻங๐‫ۓ‬᮷ᖌಷᇿᒈጱDB ங๐‫ۓ‬D ங๐‫ۓ‬E ங๐‫ۓ‬F ங๐‫ۓ‬G ங๐‫ۓ‬D ங๐‫ۓ‬E ங๐‫ۓ‬F ங๐‫ۓ‬G

28.ங๐‫ۓ‬ຝ຅ໜֺ—ቔᕆۖாங๐‫ۓ‬ Kindergarten Kindergarten API ᓕቘ‫ݣݸ‬ Timeline Timeline Timeline ங๐‫ۓ‬ ங๐‫ۓ‬ ங๐‫ۓ‬ ቔᕆۖாங๐‫ۓ‬੒ӱ‫᧣ۓ‬አො᭐ก҅ӱ‫ۓ‬ො෫ᵱ‫ဳى‬ਫሿᕡᜓ դᎱ॔አ௔҅ᇿᒈங๐‫ۓ‬ᕟկ҅ӱ‫ۓ‬ᔮᕹӧٚව៧ቔᕆۖாӱ‫ۓ‬᭦ᬋ դᎱ Redisᵞᗭ Redis Redis Redis ਫෞԧ‫ړ‬ପ‫ړ‬ᤒ҅ᥴ٬ԧ‫ܔ‬හഝପහഝᰁय̵़හഝ॒ቘᚆ‫ํێ‬ᴴጱኒ ᷀ᳯ᷌҅ള‫ݗ‬ጱෆ֛௔ᚆ൉‫܋‬ԧ‫׭پ‬ ‫ړ‬ପ‫ړ‬ᤒ Timeline DB Timeline DB Timeline DB

29.ங๐‫ۓ‬ຝ຅ໜֺ—ቔᕆۖாங๐‫ۓ‬Redisᵞᗭ Redisᵞᗭ Ԇᜓᅩ3‫ݣ‬๐‫࢏ۓ‬ A B C Redis3.xᇇ๜؉ᵞᗭcluster 6‫ݣ‬๢࢏҅3ӻԆᜓᅩ҅3ӻ՗ᜓᅩ A1 B1 C1 ՗ᜓᅩ3‫ݣ‬๐‫࢏ۓ‬