Share
Embed
[SpringOne2016] Distributed Tracing using Sleuth and Zipkin
SpringOne Platform 2016報告会
Shin Tanimoto
September 03, 2016
Transcript
61 slides
-
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 8IPBN* • ୩ຊ ৺ (Shin Tanimoto) • Acroquest Technologyגࣜձࣾ • ຊJavaϢʔβάϧʔϓ (JJUG) • JavaOneεϐʔΧʔ • Microservices, Elasticsearch • twitter: @cero_t • facebook: shin.tanimoto 2 -
@cero_t #jsug sli.do #4923 Copyright © Acroquest Technology Co., Ltd.
All rights reserved. ࣭ͳͲ ࣭ɺTwitter / slido Ͱड͚͚·͢ • Twitter : @cero_t or #jsug • http://sli.do/ : event code #4923 3 -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4 ·࣭ͣ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 5 ΨνʹϚΠΫϩαʔϏεͰ ։ൃɺӡ༻Λ͍ͯ͠Δਓʁ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 6 ϚΠΫϩαʔϏεͰͳ͘ͱ )551ɺ+.4ɺ".21ɺ,BGLB ͳͲͰෳͷαʔϏεΛ ௨৴ͤͯ͞γεςϜΛΜͰΔਓʁ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 7 গͳ͘ͱ͍͔ͭ ͦ͏͍͏γεςϜΛΉඞཁ͕ ͋ΔͩΖ͏ͳͱࢥ͏ਓʁ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 8 ͍·खΛڍ͛ͳ͔ͬͨਓ Կ͠ʹདྷͨʂ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 9 ౖͬͯͳ͍Α☺ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 10 ࢄγεςϜΛΉͱ͖ʹ ඞͣ໘͢Δͷ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 11 Ͳ͜Ͱ͕ى͖ͨͷ͔ʁ Ͳ͕͜ϘτϧωοΫͳͷ͔ʁ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 12 Service architecture isn’t this simple anymore Single-server scenarios aren’t realistic or don’t fully explain latency. David Vignoni Gnome-fs-server.svg -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 13 Can we make troubleshooting wizard-free? We no longer need wizards to deploy complex architectures. We shouldn’t need wizards to troubleshoot them, either! -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 14 © 2016 Pivotal !1 An introduction to Distributed Tracing and Zipkin Adrian Cole, Pivotal @adrianfcole How to Properly Blame Things for Causing Latency -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 15 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Implementing Microservices Tracing with Spring Cloud and Zipkin By Reshmi Krishna @reshmi9k By Marcin Grzejszczak @mgrzejszczak -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 5BCMFPGDPOUFOUT 1. ൃੜՕॴΛϩά͔ΒௐΔ 2. αʔϏεͷߏΛՄࢹԽ͢Δ 3. SleuthͱZipkinͷ࢝Ίํ 16 -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 ൃੜՕॴΛϩά͔ΒௐΔ #1 17 -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 18 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ It doesn’t look like this -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 19 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ More like this -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 20 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ More like this -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 21 ϩάશ෦&MBTUJDTFBSDIʹ Ϳͬ͜ΜͰ͍ͨͱͯ͠ Ͳ͏ͬͯՕॴΛ୳͢ʁ ൃੜՕॴΛϩά͔ΒௐΔ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 22 ʮ͜ͷ͔࣌ؒΒ͜ͷ࣌ؒͷϩάʯ Λβʔοͱݕࡧ͢Δʁ ൃੜՕॴΛϩά͔ΒௐΔ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 23 ͨ͘͞ΜΤϥʔ͕ى͖ͯͨΒ Ͳ͏͢Μͷʁ ൃੜՕॴΛϩά͔ΒௐΔ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 24 ϦΫΤετʹରͯ͠*%Λൃߦ͠ ͦΕΛڞ༗͢Εྑ͘Ͷʁ ൃੜՕॴΛϩά͔ΒௐΔ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 25 4QSJOH$MPVE4MFVUI ൃੜՕॴΛϩά͔ΒௐΔ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 26 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Brixton.SR4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-sleuth</artifactId> </dependency> Spring Cloud Sleuth with Maven -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 27 ϦΫΤετશମ5SBDF ݸผϦΫΤετ4QBO ൃੜՕॴΛϩά͔ΒௐΔ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 28 )551".21ϔομʹ*%ΛຒΊΔ ड͚औͬͯ5ISFBE-PDBMʹೖΕΔ ࣍ʹ͢ɾɾɾͷ܁Γฦ͠ ൃੜՕॴΛϩά͔ΒௐΔ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 29 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 30 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 31 ϦΫΤετͷ*%ΛΩʔʹͯ͠ ෳαʔόͷϩάΛݕࡧͰ͖Δ ൃੜՕॴΛϩά͔ΒௐΔ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 32 ͳΔ΄Ͳ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 33 ͦΕΛͬͯ ՄࢹԽͰ͖ΔͷͰʁ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 αʔϏεͷߏΛՄࢹԽ͢Δ #2 34 -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 35 4MFVUIͰूΊͨใΛͬͯ ͍ͱ͜ΖΛ୳ͨ͠Γ αʔϏεͷؔ࿈Λݟ͍ͨ αʔϏεͷߏΛՄࢹԽ͢Δ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 36 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The answer is: ZIPKIN -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 37 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ SPANS SENT TO COLLECTORS SPANS SENT TO COLLECTORS STORE IN DB APP APP UI QUERIES FOR TRACE INFO VIA API How does Zipkin work? -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 38 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud Sleuth Zipkin with Maven <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Brixton.SR4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 39 %FNP αʔϏεͷߏΛՄࢹԽ͢Δ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 SleuthͱZipkinͷ࢝Ίํ #3 40 -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 42 4MFVUIͱ;JQLJOͷ࢝Ίํ • JavaOneʹΑ͘ࢀՃ͢ΔΜ͚ͩͲ ΞδΣϯμΛݟͯΔͱ໌Β͔ʹ SpringOneͷ΄͏ָ͕ͦ͠͏ɻ • ͦ͏ͩCfPΛग़ͦ͏ɻ • ͋ɺड͔ͬͨɻ͍ɻ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ • How to do? (1) Spring InitializrͰ “sleuth” and “zipkin” Λ୳͢ https://start.spring.io/ (2) ϚΠΫϩαʔϏεʹsleuthͷdependenciesΛՃ (3) zipkinͷdependenciesΛͬͯZipkinαʔόΛ࡞Δ 43 -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 44 -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 45 -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ Sleuth and Zipkin dependencies 46 Name on Initializr artifactId Sleuth spring-cloud-starter-sleuth Sleuth Stream spring-cloud-sleuth-stream Zipkin Client spring-cloud-starter-zipkin Zipkin Stream spring-cloud-sleuth-zipkin-stream Zipkin UI spring-boot-starter zipkin-autoconfigure-ui Zipkin Server spring-boot-starter zipkin-server -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 47 Microservice Microservice Zipkin Server HTTP Zipkin UI Server To start simply: -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ To start simply: 48 Microservice Microservice Zipkin Server HTTP Zipkin UI Server Zipkin Client (spring-cloud-starter-zipkin) Zipkin UI (zipkin-autoconfigure-ui) Zipkin Server (zipkin-server) -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 49 Microservice AMQP Zipkin UI Server Zipkin Server RabbitMQ AMQP To use RabbitMQ as a middle buffer: -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 50 Microservice AMQP Zipkin UI Server Zipkin Server RabbitMQ AMQP Zipkin UI (zipkin-autoconfigure-ui) Zipkin Stream (spring-cloud-sleuth-zipkin-stream) Stream Rabbit (spring-cloud-starter-stream-rabbit) Sleuth Stream (spring-cloud-sleuth-stream) Stream Rabbit (spring-cloud-starter-stream-rabbit) To use RabbitMQ as a middle buffer: -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 51 Microservice AMQP Zipkin UI Server Zipkin Server RabbitMQ AMQP Zipkin UI (zipkin-autoconfigure-ui) Zipkin Stream (spring-cloud-sleuth-zipkin-stream) spring-cloud-stream-binder-rabbit Sleuth Stream (spring-cloud-sleuth-stream) spring-cloud-stream-binder-rabbit To use RabbitMQ as a middle buffer: -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 52 Microservice AMQP Zipkin UI Server Zipkin Server RabbitMQ AMQP The exchange and the queue are created and bound automatically. Exchange: sleuth Queue: sleuth.sleuth -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ Sleuth and Zipkin dependencies 53 Name on Initializr artifactId Log HTTP AMQP Sleuth spring-cloud-starter-sleuth Service Sleuth Stream spring-cloud-sleuth-stream Service Zipkin Client spring-cloud-starter-zipkin Service Zipkin Stream spring-cloud-sleuth-zipkin-stream Zipkin Zipkin UI spring-boot-starter zipkin-autoconfigure-ui Zipkin Zipkin Zipkin Server spring-boot-starter zipkin-server Zipkin Stream Rabbit spring-cloud-starter-stream-rabbit Both -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 54 Zipkin server application (HTTP): @SpringBootApplication @EnableZipkinServer public class ZipkinApplication { public static void main(String[] args) { SpringApplication.run(ZipkinApplication.class, args); } } -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 55 Zipkin server application (Stream): @SpringBootApplication @EnableZipkinStreamServer public class ZipkinApplication { public static void main(String[] args) { SpringApplication.run(ZipkinApplication.class, args); } } -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 56 No source code modification in microservices! -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ • Note (1) Spring Cloud Sleuth RabbitTemplateΛαϙʔτ͍ͯ͠ͳ͍ (spring-boot-starter-amqp). (2) Stream Rabbitαϙʔτ͞Ε͍ͯΔ (spring-cloud-starter-stream-rabbit). 57 -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 58 ͳΜ͍ͯ͏εϥΠυΛ४උͯͨ͠લ #ZUIFXBZ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 59 5IF/FUqJY5FDI#MPH7J[DFSBM0QFO4PVSDF IUUQUFDICMPHOFUqJYDPNWJ[DFSBM PQFOTPVSDFIUNM #ZUIFXBZ -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 60 Infrastructures Evolution -FUTIBWFGVOWJTVBMJ[BUJPOZPVSNJDSPTFSWJDFT -
Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t
#jsug sli.do #4923 8SBQVQ • Sample code: https://github.com/cero-t/e-commerce-example • Clip arts: http://www.irasutoya.com/ 61