Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

マイクロサービスに必要な技術要素はすべてSpring Cloudにある #DO07

4.655 visualizaciones

Publicado el

de:code 2017 DO07

Publicado en: Tecnología
  • Sé el primero en comentar

マイクロサービスに必要な技術要素はすべてSpring Cloudにある #DO07

  1. 1. • Toshiaki Maki (@making) https://blog.ik.am • Sr. Solutions Architect @Pivotal • Spring Framework • Cloud Foundry
  2. 2. https://github.com/Pivotal-Japan/cloud-native-workshop
  3. 3. Application coordination boilerplate patterns Application configuration boilerplate patterns Enterprise Java application boilerplate patterns Runtime Platform, Infrastructure Automation boilerplate patterns (provision, deploy, secure, log, data services, etc.) CLOU D DESKTOP Spring Boot Spring Framework Pivotal Cloud Foundry Spring Cloud Microservice operation boilerplate patterns (Config Server, Service Discovery, Circuit Breaker) SERVICES Spring Cloud Services 今日の範囲
  4. 4. Application coordination boilerplate patterns Application configuration boilerplate patterns Enterprise Java application boilerplate patterns Runtime Platform, Infrastructure Automation boilerplate patterns (provision, deploy, secure, log, data services, etc.) CLOU D DESKTOP Spring Boot Spring Framework Pivotal Cloud Foundry Spring Cloud Microservice operation boilerplate patterns (Config Server, Service Discovery, Circuit Breaker) SERVICES Spring Cloud Services
  5. 5. API Gateway
  6. 6. API Gateway
  7. 7. <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency> @SpringBootApplication @EnableConfigServer public class MyConfigServerApplication { ... } server.port=8888 spring.cloud.config.server.git.uri=https://github.com/xyz/config.git
  8. 8. <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> spring.application.name=order-service spring.cloud.config.uri=http://localhost:8888
  9. 9. application-dev.properties order-service-dev.properties payment-service.profile payment-service-dev.profile payment-service-dev.profile
  10. 10. message message POST /refresh
  11. 11. @RefreshScope public class OrderService { @Value("${message}") String message; public String hello() { return message; } }
  12. 12. https://www.vaultproject.io/
  13. 13. spring.profiles.active=vault,git spring.cloud.config.server.vault.host=... spring.cloud.config.server.git.uri=... spring.cloud.config.token=...
  14. 14. API Gateway
  15. 15. RESTAPIRESTAPI #0: URL + MD #1: URL + MD #2: URL + MD #0: URL + MD #1: URL + MD #2: URL + MD
  16. 16. http://techblog.netflix.com/2012/09/eureka.html
  17. 17. <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-eureka-server</artifactId> </dependency> @SpringBootApplication @EnableEurekaServer public class MyEurekaServerApplication { ... } server.port=8761 eureka.client.register-with-eureka=false eureka.client.fetch-registry=false
  18. 18. <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> spring.application.name=order-service # config-server使用時は # bootstrap.propertiesに eureka.client.service-url.defaultZone=http://localhost:8761 @SpringBootApplication @EnableDiscovertyClient public class OrderServiceApplication { ... }
  19. 19. public class OrderService { DiscoveryClient discoveryClient; public void order() { List<ServiceInstance> list = discoveryClient.getInstances("payment-service"); URL paymentUrl = list.get(0).getUri() // ... } }
  20. 20. http://techblog.netflix.com/2013/01/announcing-ribbon-tying-netflix-mid.html
  21. 21. @Bean @LoadBalanced public RestTemplate restTemplate() { return new RestTemplate(); } public class OrderService { @LoadBalanced RestTemplate restTemplate; public void order() { restTemplate .postForEntity("http://payment-service", Payment.class);}}
  22. 22. Ribbon Server List Server List ⏱
  23. 23. 🙌 • レイテンシ低下 • ロードバランサの 負荷を軽減
  24. 24. API Gateway
  25. 25. 行列ができるECサイトの悩み~ショッピングや決済の技術的問題と処方箋 https://www.slideshare.net/techblogyahoo/ec-72726085
  26. 26. 行列ができるECサイトの悩み~ショッピングや決済の技術的問題と処方箋 https://www.slideshare.net/techblogyahoo/ec-72726085
  27. 27. http://techblog.netflix.com/2012/11/hystrix.html
  28. 28. ClosedOpenHalf-OpenClosed
  29. 29. <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency> @SpringBootApplication @EnableCircuitBreaker public class OrderServiceApplication { ... }
  30. 30. @HystrixCommand(fallbackMethod = "getTop10") public Recommendations getRecommendation(String username) { return restTemplate.getForObject("http://recommendation?u={u}", username, Recommendations.class); } public Recommendations getTop10(String username) { return recommendationsCache.getTop10(); }
  31. 31. <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency> @SpringBootApplication @EnableHystrixDashboard public class HystrixDashboardApplication { ... }
  32. 32. API Gateway
  33. 33. @SpringBootApplication @EnableBinding(Source.class) public class OrderServiceApplication { // ... @Autowired Source source; @PostMapping void order(@RequestBody Order order) { Message message = MessageBuilder.fromPayload(order).build(); source.output().send(message); } } spring.cloud.stream.bindings.output.destination=order
  34. 34. @SpringBootApplication @EnableBinding(Sink.class) public class DeliveryServiceApplication { // ... @StreamListener(Sink.INPUT) void handlerOrder(@Payload Order order) { deliverySerivice.deliver(order); } } spring.cloud.stream.bindings.input.destination=order
  35. 35. spring.cloud.stream.bindings.input.destination=order spring.cloud.stream.bindings.input.group=point-service spring.cloud.stream.bindings.input.destination=order spring.cloud.stream.bindings.input.group=delivery-service spring.cloud.stream.bindings.input.destination=order spring.cloud.stream.bindings.input.group=notification-service
  36. 36. https://www.slideshare.net/makingx/event-driven-microservices-with-spring-cloud-stream-jjugccc-ccca3
  37. 37. API Gateway
  38. 38. 2017-02-26 11:15:47.561 INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio- 8081-exec-1] i.s.c.sleuth.docs.service1.Application : Hello from service1. Calling service2 2017-02-26 11:15:47.710 INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio- 8082-exec-1] i.s.c.sleuth.docs.service2.Application : Hello from service2. Calling service3 and then service4 2017-02-26 11:15:47.895 INFO [service3,2485ec27856c56f4,1210be13194bfe5,true] 68060 --- [nio- 8083-exec-1] i.s.c.sleuth.docs.service3.Application : Hello from service3 2017-02-26 11:15:47.924 INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio- 8082-exec-1] i.s.c.sleuth.docs.service2.Application : Got response from service3 [Hello from service3] 2017-02-26 11:15:48.134 INFO [service4,2485ec27856c56f4,1b1845262ffba49d,true] 68061 --- [nio- 8084-exec-1] i.s.c.sleuth.docs.service4.Application : Hello from service4 2017-02-26 11:15:48.156 INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio- 8082-exec-1] i.s.c.sleuth.docs.service2.Application : Got response from service4 [Hello from service4] 2017-02-26 11:15:48.182 INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio- 8081-exec-1] i.s.c.sleuth.docs.service1.Application : Got response from service2 [Hello from service2, response from service3 [Hello from service3] and from service4 [Hello from service4]]
  39. 39. http://zipkin.io/
  40. 40. <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-sleuth-stream</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency>
  41. 41. API Gateway
  42. 42. Consumer Producer
  43. 43. API Gateway
  44. 44. steeltoe.io
  45. 45. Application coordination boilerplate patterns Application configuration boilerplate patterns Enterprise Java application boilerplate patterns Runtime Platform, Infrastructure Automation boilerplate patterns (provision, deploy, secure, log, data services, etc.) CLOU D DESKTOP Spring Boot Spring Framework Pivotal Cloud Foundry Spring Cloud Microservice operation boilerplate patterns (Config Server, Service Discovery, Circuit Breaker) SERVICES Spring Cloud Services
  46. 46. IaaS Cloud Foundry ファイアウォールの設定 死活監視の設定 SSLの設定 ロードバランサの設定 アプリケーションのデプロイ ランタイムのインストール VMのプロビジョニング cf push myapp -p app.jar
  47. 47. マーケットプレースからインストール可能 https://azuremarketplace.microsoft.com/en-us/marketplace/apps/pivotal.pivotal-cloud-foundry
  48. 48. Application coordination boilerplate patterns Application configuration boilerplate patterns Enterprise Java application boilerplate patterns Runtime Platform, Infrastructure Automation boilerplate patterns (provision, deploy, secure, log, data services, etc.) CLOU D DESKTOP Spring Boot Spring Framework Pivotal Cloud Foundry Spring Cloud Microservice operation boilerplate patterns (Config Server, Service Discovery, Circuit Breaker) SERVICES Spring Cloud Services
  49. 49. https://youtu.be/BiY3amrDIo0
  50. 50. run.pivotal.io
  51. 51. Application coordination boilerplate patterns Application configuration boilerplate patterns Enterprise Java application boilerplate patterns Runtime Platform, Infrastructure Automation boilerplate patterns (provision, deploy, secure, log, data services, etc.) CLOU D DESKTOP Spring Boot Spring Framework Pivotal Cloud Foundry Spring Cloud Microservice operation boilerplate patterns (Config Server, Service Discovery, Circuit Breaker) SERVICES Spring Cloud Services 武器は揃っています。 いつ始めるのですか?
  52. 52. 📧
  53. 53. セッションアンケートにご協力ください  専用アプリからご回答いただけます。 decode 2017  スケジュールビルダーで受講セッションを 登録後、アンケート画面からご回答ください。  アンケートの回答時間はたったの 15 秒です!
  54. 54. Ask the Speaker のご案内 本セッションの詳細は『Ask the Speaker Room』各コーナーカウンタにて ご説明させていただきます。是非、お立ち寄りください。
  55. 55. © 2017 Microsoft Corporation. All rights reserved. 本情報の内容(添付文書、リンク先などを含む)は、作成日時点でのものであり、予告なく変更される場合があります。
  56. 56. リリース名 主な新プロジェクト 対応するSpring Boot Angel Spring Cloud Netflix Spring Cloud Config 1.2.x Brixton Spring Cloud Stream Spring Cloud Task Spring Cloud Sleuth Spring Cloud Consul 1.3.x, 1.4.x Camden Spring Cloud Contract 1.4.x, 1.5.x Dalston Spring Cloud Vault 1.5.x Edgware ? ?

×