Let's Visualize Your Spring Boot Applications

1,383 views

Published on

SpringOne Platform 2016
Speaker: Shin Tanimoto; Technical Consultant, Acroquest Technology

In the microservice era, working with tens of hundreds of services leads to difficulties getting a grasp of the application health such as error frequency, server resources, response times and throughput. It is said visualization tools can help us command a view of the whole system and detect problems in the early stages or prevent them from occurring, but the important thing is to choose proper tools and create dashboards the right way.

This session offers techniques for visualizing microservices built by Spring Boot applications using Elasticsearch, Kibana and Spring Cloud Sleuth. Besides visualizing server resources and access logs, service dependencies and performance bottlenecks, and business statuses such as conversion rate are also visualized. Let's have fun diving into visualizing your applications.

Published in: Technology

Let's Visualize Your Spring Boot Applications

  1. 1. Let's Visualize Your
 Spring Boot Applications Acroquest Technology Co., LTD.
 Shin Tanimoto (@cero_t)
  2. 2. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. Who am I? • ⾕谷本 ⼼心 (Shin Tanimoto) • Acroquest Technology (in Japan) • Board member of Japan Java User Group (JJUG) • System Architect / Troubleshooter • Microservices, Elasticsearch • Pokemon: Team Mystic • twitter: @cero_t • facebook: shin.tanimoto 2
  3. 3. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. I ask you ... If you have any question, ask me by • twitter with mention to @cero_t or hashtag #s1p_vis • http://sli.do/ with event code #5463 3
  4. 4. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4 Seeing is believing
  5. 5. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 5 Seeing is deceiving?
  6. 6. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 6 You can t even believe
 without seeing
  7. 7. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 7 Seeing is getting insights
  8. 8. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 8
  9. 9. Let's Visualize Your
 Spring Boot Applications Acroquest Technology Co., LTD.
 Shin Tanimoto ( @cero_t )
  10. 10. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. Table of contents 1. Tools 2. Are your services working well? 3. Are your services enough comfortable? 4. How do your microservices look like? 5. Do your services contribute to your business? 10
  11. 11. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. Tools #1 11
  12. 12. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. Tools 1. AWS CloudWatch • for monitoring and alerting 2. Elasticsearch + Logstash + Kibana + Beats • for monitoring and visualizing logs 3. Spring Cloud Sleuth + Zipkin • for visualizing microservices 12
  13. 13. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. Tools 1. AWS CloudWatch 13
  14. 14. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. Tools 1. AWS CloudWatch • Built-in monitoring service for AWS. • Custom metrics can be collected by aws-cli or SDK on each server. • Logs can be collected by “awslogs" agent on each server.
 • Datadog can be alternative. 14
  15. 15. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. Tools 2. Elasticsearch + Logstash + Kibana + Beats 15
  16. 16. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. Tools 2. Elasticsearch + Logstash + Kibana + Beats • Elasticsearch : Full-text search engine • Logstash : Data collector, processor, sender • Kibana : Visualization platform • Beats : Data shipper 16
  17. 17. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. Tools They are so called “ELK”. 17
  18. 18. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. Tools ELK-bee? 18
  19. 19. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 19 Elastic stack 1. Tools
  20. 20. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. Tools 3. Spring Cloud Sleuth + Zipkin
 • Spring Cloud Sleuth is a distributed tracing solution. • Embeds the trace id (correlation id) and the span id (message id)
 into the HTTP request headers, RabbitMQ headers, and so on. • Embeds those ids into the logs through SLF4J MDC. • Send trace data to Zipkin or Spring Cloud Stream.
 • Zipkin is a distributed tracing system. • Collects and lookup trace data. • Zipkin UI shows the data. 20
  21. 21. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. Are your services working well? #2 21
  22. 22. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 2. Are your services working well? 1. What to do? • Per server monitoring (1) CPU usage (2) Physical memory usage / available (3) Disk space usage / available • Per service / middleware monitoring (1) Process status (2) Health check • Put them on the same dashboard. • Create alert notifications of them. 22
  23. 23. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 2. Are your services working well? 23
  24. 24. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 2. Are your services working well? 2. Why do this? (1) To see if servers are woking well now. (2) To see if servers were woking well in the past. (3) To see if servers will be working well in the near future. 24
  25. 25. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 2. Are your services working well? 3. How to do? • I believe you already know to setup monitoring. • Do you know topboat of elastic stack? 25
  26. 26. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 26 Demo! 2. Are your services working well?
  27. 27. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. Are your services enough comfortable? #3 27
  28. 28. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. What to do? • Monitor the web access (1) Access count (2) Response time (Per public API) (3) Response code • Monitor the datasource (1) Query count (2) Query response time 28 3. Are your services enough comfortable?
  29. 29. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 3. Are your services enough comfortable? 29 Avg. of response time
 per API (Search only) Avg. of response time
 per API (All) Access count per API
  30. 30. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 3. Are your services enough comfortable? 2. Why do this? • To see if the visitors feel comfortable or annoyed. 30
  31. 31. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 3. Are your services enough comfortable? 3. How to do? • If you use ELB, just use ELB monitoring
 on AWS CloudWatch. • Collect access logs using Logstash or Filebeat and forward them to Elasticsearch.
 And visualize them on Kibana. • Do you know packetbeat? 31
  32. 32. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 32 3. Are your services enough comfortable?
  33. 33. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. How do your microservices look like? #4 33
  34. 34. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 1. What to do? • Trace microservices request by Spring Cloud Sleuth • Send trace data to Zipkin and visualize them 34 4. How do your microservices look like?
  35. 35. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 2. Why do this? (1) To get a grasp of your system looks like. (2) When modifying some microservices,
 to confirm the influence range. (3) To find unused services. 35
  36. 36. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 3. How to do? (1) Go to Spring Initializr web site and
 find “sleuth” and “zipkin”. (2) Add sleuth dependencies to your microservices. (3) Create zipkin server using zipkin dependencies. 36
  37. 37. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 37
  38. 38. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 38
  39. 39. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? Sleuth and Zipkin dependencies 39 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
  40. 40. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 40 Microservice Microservice Zipkin Server HTTP Zipkin UI Server To start simply:
  41. 41. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? To start simply: 41 Microservice Microservice Zipkin Server HTTP Zipkin UI Server Zipkin Client 
 (spring-cloud-starter-zipkin) Zipkin UI (zipkin-autoconfigure-ui)
 Zipkin Server (zipkin-server)
  42. 42. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 42 Microservice AMQP Zipkin UI Server
 Zipkin Server RabbitMQ AMQP To use RabbitMQ as a middle buffer:
  43. 43. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 43 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:
  44. 44. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 44 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:
  45. 45. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 45 Microservice AMQP Zipkin UI Server
 Zipkin Server RabbitMQ AMQP The exchange and the queue are created and bound automatically. Exchange:
 sleuth Queue:
 sleuth.sleuth
  46. 46. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? Sleuth and Zipkin dependencies 46 Name on Initializr artifactId HTTP AMQP Sleuth spring-cloud-starter-sleuth Sleuth Stream spring-cloud-sleuth-stream Producer Zipkin Client spring-cloud-starter-zipkin Client Zipkin Stream spring-cloud-sleuth-zipkin-stream Consumer Zipkin UI spring-boot-starter
 zipkin-autoconfigure-ui Server Consumer Zipkin Server spring-boot-starter
 zipkin-server Server Stream Rabbit spring-cloud-starter-stream-rabbit Both
  47. 47. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? Sleuth and Zipkin dependencies 47 Name on Initializr artifactId HTTP AMQP Sleuth spring-cloud-starter-sleuth Adds trace and span ids to the logs
  48. 48. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 48 Zipkin server application (HTTP): @SpringBootApplication @EnableZipkinServer public class ZipkinApplication { public static void main(String[] args) { SpringApplication.run(ZipkinApplication.class, args); } }
  49. 49. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 49 Zipkin server application (Stream): @SpringBootApplication @EnableZipkinStreamServer public class ZipkinApplication { public static void main(String[] args) { SpringApplication.run(ZipkinApplication.class, args); } }
  50. 50. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? 50 No source code modification in microservices!
  51. 51. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 51 Demo! 4. How do your microservices look like?
  52. 52. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 4. How do your microservices look like? • Note (1) Spring Cloud Sleuth does NOT support RabbitTemplate (spring-boot-starter-amqp). (2) It supports Stream Rabbit
 (spring-cloud-starter-stream-rabbit). 52
  53. 53. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. Do your services contribute to your business? #5 53
  54. 54. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 5. Do your services contribute to your business? 1. What to do? • Collect access logs in Elasticsearch. • Session ID or user id should be contained
 in the access log. • Visualize logs using Kibana. 54
  55. 55. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 55 Demo! 5. Do your services contribute to your business?
  56. 56. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 5. Do your services contribute to your business? 2. Why do this? (1) To see how your system contribute to. (2) To make your boss or manager
 to invest more $$$ to the developers! 56
  57. 57. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. Summary At last 57
  58. 58. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. Summary • Use server monitoring and process monitoring. • Gathering the system performance and business performance into one dashboard shows the relationship of them! • Zipkin is cool, enough cool. 58
  59. 59. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 59 Yesterday I found a big news. By the way,
  60. 60. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 60 The Netflix Tech Blog: Vizceral Open Source http://techblog.netflix.com/2016/08/vizceral- open-source.html By the way,
  61. 61. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. 61 Infrastructures Evolution Let's have fun visualization your microservices!
  62. 62. @cero_t #s1p_vis sli.do #5463 Copyright © Acroquest Technology Co., Ltd. All rights reserved. Summary • Sample code: https://github.com/cero-t/e-commerce-example • Clip arts: http://www.irasutoya.com/ 62

×