[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
SlideShare a Scribd company logo
1@Copyright 2016 Pivotal. All rights reserved. 1@Copyright 2016 Pivotal. All rights reserved.
Spring Cloud Netflixを使おう
Japan Spring User Group勉強会2016その1
Toshiaki Maki ● @making
Feb 1 2016
2@Copyright 2016 Pivotal. All rights reserved.
Contents
• NetflixとSpring Cloudについて
• Spring Cloud Netflixについて
• PaaSにデプロイしよう
• Spring Cloud Services
3@Copyright 2016 Pivotal. All rights reserved.
資料のURL
ハッシュタグは #jsug
http://bit.ly/jsug-cloud
4@Copyright 2016 Pivotal. All rights reserved.
今日のソースコード
https://github.com/making/jsug-spring-cloud
5@Copyright 2016 Pivotal. All rights reserved.
6@Copyright 2016 Pivotal. All rights reserved.
2015年9月1日 日本でもストーリーミングサービス開始
7@Copyright 2016 Pivotal. All rights reserved.
http://hibana-netflix.jp/
8@Copyright 2016 Pivotal. All rights reserved.
https://ja.wikipedia.org/wiki/ネットフリックス
9@Copyright 2016 Pivotal. All rights reserved.
http://www.statista.com/statistics/250934/quarterly-number-of-netflix-streaming-subscribers-worldwide/
10@Copyright 2016 Pivotal. All rights reserved.
http://www.slideshare.net/BruceWong3/the-case-for-chaos/12
Micro Services
Continuous
Delivery
DevOps
圧倒的スピードで成長するビジネスを支える
11@Copyright 2016 Pivotal. All rights reserved.
http://netflix.github.io/
• Eureka
• Ribbon
• Hystrix
• Turbine
• Zuul
• Feign
• Atlas
• …
12@Copyright 2016 Pivotal. All rights reserved.
Spring Cloud
• 分散システムの共通パターンの実装を提供
 Distributed Configuration
 Service Registry
 Circuit Breaker
 Leadership Election
 Distributed Messaging
 Distributed Tracing
 …
• Dr. Dave Syer, Spencer Gibbがメイン開発者
http://projects.spring.io/spring-cloud/
13@Copyright 2016 Pivotal. All rights reserved.
Spring Cloudサブプロジェクト
• Spring Cloud Config
• Spring Cloud Netflix
• Spring Cloud Consul
• Spring Cloud Sleuth
• Spring Cloud Stream
• Spring Cloud Task
• Spring Cloud Data Flow
• …
14@Copyright 2016 Pivotal. All rights reserved.
Spring Cloud Netflix
• Netflix OSSをSpring Bootと合わせて簡単に使う
ためのライブラリ
• Netflixでも使われている
https://youtu.be/6wvVANQ6EJ8
15@Copyright 2016 Pivotal. All rights reserved.
Release Train
Spring Cloud (BOM) Angel.SR6 Brixton.M4 Brixton.BUILD-SNAPSHOT
Spring Cloud Netflix 1.0.7.RELEASE 1.1.0.M4 1.1.0.BUILD-SNAPSHOT
Spring Cloud Config 1.0.4.RELEASE 1.1.0.M4 1.1.0.BUILD-SNAPSHOT
Spring Cloud Commons 1.0.5.RELEASE 1.1.0.M4 1.1.0.BUILD-SNAPSHOT
Spring Cloud Consul - 1.0.0.M5 1.0.0.BUILD-SNAPSHOT
Spring Cloud Zookeeper - 1.0.0.M4 1.0.0.BUILD-SNAPSHOT
Spring Cloud Sleuth - 1.0.0.M4 1.0.0.BUILD-SNAPSHOT
Spring Cloud Stream - 1.0.0.M3 1.0.0.BUILD-SNAPSHOT
Spring Cloud Task - - 1.0.0.BUILD-SNAPSHOT
Spring Cloud Dataflow - 1.0.0.M2 1.0.0.BUILD-SNAPSHOT
Spring Boot 1.2.8.RELEASE 1.3.1.RELEASE 1.3.2.RELEASE
16@Copyright 2016 Pivotal. All rights reserved.
Spring Cloudの使い方
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.M4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
17@Copyright 2016 Pivotal. All rights reserved. 17@Copyright 2016 Pivotal. All rights reserved.
Spring Cloud Netflix
18@Copyright 2016 Pivotal. All rights reserved.
サービス多すぎ
接続情報の管理大変
19@Copyright 2016 Pivotal. All rights reserved.
Service Discoveryパターン
https://docs.pivotal.io/spring-cloud-services/service-registry/
Client(Consumer)が
API(Producer)へ直接
アクセスするのではな
く、Registryを経由す
る
20@Copyright 2016 Pivotal. All rights reserved.
サービス名から物理アドレスを解決
Service Name IP:PORT
customer 192.168.11.1:8080
192.168.11.2:8080
…
order
192.168.11.11:8080
192.168.11.12:8080
…
catalog 192.168.11.21:8080
192.168.11.22:8080
…
21@Copyright 2016 Pivotal. All rights reserved.
Eureka
• RESTベースのService Registryサーバー
• Netflixを支えるベース
http://techblog.netflix.com/2012/09/eureka.html
22@Copyright 2016 Pivotal. All rights reserved.
Eureka Client
Service Consumer
Service Producer
Service Registry
Eureka Server
Eurekaを使う場合の基本構成
23@Copyright 2016 Pivotal. All rights reserved.
Eureka Client
Service Consumer
Service Producer
Service Registry
Eureka Server
Service Info (Cache)
Heart Beat
Eurekaを使う場合の基本構成
24@Copyright 2016 Pivotal. All rights reserved.
Eurekaを使う場合の基本構成
Eureka Client
Service Consumer
Service Producer
Service Registry
Eureka Server
Service Info (Cache)
キャシュを使うので、
Eureka Serverがダウンしても
Clientはサービス継続可能
25@Copyright 2016 Pivotal. All rights reserved.
Eureka Serverの作成
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
26@Copyright 2016 Pivotal. All rights reserved.
https://start.spring.io
27@Copyright 2016 Pivotal. All rights reserved.
Eureka Serverの作成
@SpringBootApplication
@EnableEurekaServer
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class,args);
}
}
28@Copyright 2016 Pivotal. All rights reserved.
Stand Aloneモード
# 慣習的ポート番号
server.port=8761
# Eurekaサーバーへの登録は不要
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
application.properties
29@Copyright 2016 Pivotal. All rights reserved.
Dashboard
30@Copyright 2016 Pivotal. All rights reserved.
DEMO
31@Copyright 2016 Pivotal. All rights reserved.
マルチインスタンスモード
server.port=8761
eureka.instance.hostname=peer1
# Eurekaサーバーへ登録
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
# 登録するEurekaサーバーへのURL(Eurekaサーバー自体がクライアント)
eureka.client.service-url.defaultZone=http://peer2:8762/eureka/
application-peer1.properties
32@Copyright 2016 Pivotal. All rights reserved.
マルチインスタンスモード
server.port=8762
eureka.instance.hostname=peer2
# Eurekaサーバーへ登録
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
# 登録するEurekaサーバーへのURL(Eurekaサーバー自体がクライアント)
eureka.client.service-url.defaultZone=http://peer1:8761/eureka/
application-peer2.properties
33@Copyright 2016 Pivotal. All rights reserved.
$ ./mvnw clean package -Dmaven.test.skip=true
$ java -jar target/*.jar --spring.profile.active=peer1
$ java -jar target/*.jar --spring.profile.active=peer2
Eureka Serverインスタンス1(ビルド&)起動
Eureka Serverインスタンス2起動
ローカルで試す場合は/etc/hostsにpeer1とpeer2を登録
34@Copyright 2016 Pivotal. All rights reserved.
インメモリのキャッシュにメタデータを保持し
ているので、自動復旧機能があるプラットフ
ォーム(Cloud Foundryなど)上であれば
Stand Aloneモードで十分
35@Copyright 2016 Pivotal. All rights reserved.
Eureka Clientの作成
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
36@Copyright 2016 Pivotal. All rights reserved.
37@Copyright 2016 Pivotal. All rights reserved.
Eureka Client (Producer)
@SpringBootApplication
@EnableDiscoveryClient
@RestController
public class ProducerApplication {
private static final UUID id = UUID.randomUUID();
@RequestMapping(path = "/")
String hello() {
return "Hello @" + id;
}
public static void main(String[] args) {
SpringApplication.run(ProducerApplication.class, args);
}
}
38@Copyright 2016 Pivotal. All rights reserved.
Eureka Client (Producer)
server.port=9000
# 登録するEurekaサーバーのURL
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/
application.properties
# Eurekaサーバーに登録するサービス名
spring.application.name=jsug-producer
bootstrap.properties
39@Copyright 2016 Pivotal. All rights reserved.
その他のプロパティ
# 情報の更新間隔(デフォルト30秒)
eureka.instance.lease-renewal-interval-in-seconds=3
# インスタンスのID(ダッシュボードのリンク名などに使われる)
eureka.instance.metadata-map.instanceId=${spring.application.name}:${random.value}
# ホスト名の代わりにIPアドレスを使用(ホスト名を解決できないDockerを使う場合など)
eureka.instance.prefer-ip-address=true
application.properties
40@Copyright 2016 Pivotal. All rights reserved.
41@Copyright 2016 Pivotal. All rights reserved.
42@Copyright 2016 Pivotal. All rights reserved.
43@Copyright 2016 Pivotal. All rights reserved.
Eureka Client (Consumer)
@SpringBootApplication
@EnableDiscoveryClient @RestController
public class ConsumerApplication {
@Autowired EurekaClient client;
@RequestMapping(path = "/") String hello() {
String url = client
.getNextServerFromEureka("jsug-producer", false)
.getHomePageUrl();
String res = new RestTemplate()
.getForObject(url, String.class);
return res + " from " + url;
}
public static void main(String[] args) {/*...*/}
}
44@Copyright 2016 Pivotal. All rights reserved.
Eureka Client (Consumer)
server.port=9100
# 登録するEurekaサーバーのURL
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/
application.properties
# Eurekaサーバーに登録するサービス名
spring.application.name=jsug-consumer
bootstrap.properties
45@Copyright 2016 Pivotal. All rights reserved.
Eureka Client (Consumer)
eureka.client.service-url.defaultZone=
http://peer1:8761/eureka/,http://peer2:8762/eureka/
Eureka Serverが複数の場合
46@Copyright 2016 Pivotal. All rights reserved.
47@Copyright 2016 Pivotal. All rights reserved.
48@Copyright 2016 Pivotal. All rights reserved.
DEMO
49@Copyright 2016 Pivotal. All rights reserved.
DiscoveryClient
org.springframework.cloud.client.discovery.DiscoveryClient
各種Service Registryに対するクライアントの 共通インタフェース
• EurekaDiscoveryClient (Spring Cloud Netflix)
• ConsulDiscovertyClient (Spring Cloud Consul)
• ZookeeperDiscoveryClient (Spring Cloud Zookeeper)
• CloudFoundryDiscoveryClient (Spring Cloud CloudFoundry)
• EtcdDiscoveryClient (Spring Cloud Etcd) incubator
50@Copyright 2016 Pivotal. All rights reserved.
DiscoveryClientを使って書き直し
@Autowired DiscoveryClient client;
@RequestMapping(path = "/") String hello() {
List<ServiceInstance> instances = client
.getInstances("jsug-producer");
if (instances.isEmpty()) {
return "No ServiceRegistry!";
}
ServiceInstance instance = instances.get(0);
URI uri = instance.getUri();
String res = new RestTemplate()
.getForObject(uri, String.class);
return res + " from " + url;
}
51@Copyright 2016 Pivotal. All rights reserved.
Ribbon
• HTTPクライアントと連携するクライアントサイドロ
ードバランサ
• Eurekaの情報を使ってロードバランス可能
http://techblog.netflix.com/2013/01/announcing-ribbon-tying-netflix-mid.html
52@Copyright 2016 Pivotal. All rights reserved.
Service ProducerService Producer
Service Consumer
Service Producer
Service Registry
Load Balancer
Load Balancerあり
53@Copyright 2016 Pivotal. All rights reserved.
@SpringBootApplication
@EnableDiscoveryClient
@RestController
public class ConsumerApplication {
@Autowired
RestTemplate restTemplate;
@RequestMapping(path = "/")
String hello() {
String res = restTemplate
.getForObject("http://jsug-producer", String.class);
return res + " from " + url;
}
public static void main(String[] args) {/*...*/}
}
自動でRibbonを使った
インターセプタが組み込まれる
54@Copyright 2016 Pivotal. All rights reserved.
$ ./mvnw clean package -Dmaven.test.skip=true
$ java -jar target/jsug-producer-*.jar --server.port=9000
$ java -jar target/jsug-producer-*.jar --server.port=9001
Consumerインスタンス1(ビルド&)起動
Consumerインスタンス2起動
55@Copyright 2016 Pivotal. All rights reserved.
56@Copyright 2016 Pivotal. All rights reserved.
57@Copyright 2016 Pivotal. All rights reserved.
DEMO
58@Copyright 2016 Pivotal. All rights reserved.
その他Spring Cloud + Ribbon
対応HTTPクライアント
• Feign http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#spring-cloud-feign
• OkHttp https://github.com/spencergibb/okhttp-ribbon
• Retrofit (OkHttp利用)
59@Copyright 2016 Pivotal. All rights reserved.
Hystrix
• Circuit Breakerパターンを提供
• 障害のあるサービスへのアクセスを一
時的に遮断して、代替値を返すことで
障害の伝播を防ぐ
http://techblog.netflix.com/2012/11/hystrix.html
60@Copyright 2016 Pivotal. All rights reserved.
Circuit Breaker
61@Copyright 2016 Pivotal. All rights reserved.
Hystrixの利用
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
62@Copyright 2016 Pivotal. All rights reserved.
Hystrixの利用
@Component
class DemoService {
@Autowired
RestTemplate restTemplate;
@HystrixCommand(fallbackMethod = "defaultResponse")
public String getResponse() {
return restTemplate
.getForObject("http://jsug-producer", String.class);
}
public String defaultResponse() {
return "Not Available now";
}
}
63@Copyright 2016 Pivotal. All rights reserved.
Hystrixの利用
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
@RestController
public class ConsumerApplication {
@Autowired
DemoService demoService;
@RequestMapping(path = "/")
String hello() {
String res = demoService.getResponse();
return res + " from " + url;
}
public static void main(String[] args) {/*...*/}
}
64@Copyright 2016 Pivotal. All rights reserved.
65@Copyright 2016 Pivotal. All rights reserved.
66@Copyright 2016 Pivotal. All rights reserved.
67@Copyright 2016 Pivotal. All rights reserved.
Recover!
68@Copyright 2016 Pivotal. All rights reserved.
69@Copyright 2016 Pivotal. All rights reserved.
70@Copyright 2016 Pivotal. All rights reserved.
71@Copyright 2016 Pivotal. All rights reserved.
Hystrix Metrics Stream
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-cloud-starter-actuator</artifactId>
</dependency>
エンドポイント/hystrix.stream
が追加される
72@Copyright 2016 Pivotal. All rights reserved.
Server-Sent Events
73@Copyright 2016 Pivotal. All rights reserved.
Dashboard
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
74@Copyright 2016 Pivotal. All rights reserved.
Dashboardアプリケーション
@SpringBootApplication
@EnableHystrixDashboard
public class HystrixDashboardApplication {
public static void main(String[] args) {/*...*/}
}
75@Copyright 2016 Pivotal. All rights reserved.
76@Copyright 2016 Pivotal. All rights reserved.
77@Copyright 2016 Pivotal. All rights reserved.
78@Copyright 2016 Pivotal. All rights reserved.
普通のtry-catchと何が違う?
• ダウンしたサービスへのアクセスを遮断しないと、
エラー発生までのリソース(スレッド、メモリ、…)が
無駄になる
→障害の伝播につながる
79@Copyright 2016 Pivotal. All rights reserved.
複数のHystrixストリームを集約
• Turbineを使って複数のストリームを集約可能
• Turbine + AMQP (RabbitMQ)を使った集約も可能
http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#_turbine
80@Copyright 2016 Pivotal. All rights reserved.
Zuul
• Eurekaの情報を使ったプロキシ
• エッジサーバーとして利用
• その他様々なルーティング機能
http://techblog.netflix.com/2013/06/announcing-zuul-edge-service-in-cloud.html
81@Copyright 2016 Pivotal. All rights reserved.
Zuulの利用
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>
82@Copyright 2016 Pivotal. All rights reserved.
Zuulの利用
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
@EnableZuulProxy
@RestController
public class ConsumerApplication {
// ...
public static void main(String[] args) {/*...*/}
}
83@Copyright 2016 Pivotal. All rights reserved.
84@Copyright 2016 Pivotal. All rights reserved.
application.propertiesでルーティング設定
zuul.routes.jsug-producer=/foo/**
http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#_router_and_filter_zuul
ymlの方が書
きやすい
85@Copyright 2016 Pivotal. All rights reserved. 85@Copyright 2016 Pivotal. All rights reserved.
PaaSにデプロイしよう
86@Copyright 2016 Pivotal. All rights reserved.
Cloud Foundry上にデプロイ
• OpenなPaaSプラットフォーム
• cfコマンドでアプリケーションのデプロイを操作
• 基本的な話は https://blog.ik.am/entries/359
87@Copyright 2016 Pivotal. All rights reserved.
Pivotal Web Services
https://run.pivotal.io/
• Pivotalが運用するパブリックなCloud Foundry
$ cf login -a api.run.pivotal.io
https://blog.ik.am/entries/361(FYI) local環境で試したい場合はMicroPCFを
88@Copyright 2016 Pivotal. All rights reserved.
Eureka Serverのデプロイ
$ ./mvnw clean package -Dmaven.test.skip=true
$ cf push jsug-eureka-server -p target/*.jar
http://jsug-eureka-server.cfapps.io/
jarをcf pushするだけ
89@Copyright 2016 Pivotal. All rights reserved.
Eureka ServerをCFのサービスとして公開
$ cf create-user-provided-service jsug-eureka-service -p
'{"uri":"http://jsug-eureka-server.cfapps.io/"}'
$ cf services
name service plan bound apps
jsug-eureka-service user-provided
接続先情報や認証情報など環境依存の情報をサービスとして
公開し、(後で)接続するアプリケーションにバインドする
90@Copyright 2016 Pivotal. All rights reserved.
Eureka Clientのデプロイ
eureka.client.service-url.defaultZone=
${vcap.services.jsug-eureka-service.credentials.uri}/eureka/
eureka.instance.hostname=
${vcap.application.uris[0]}
eureka.instance.metadata-map.instanceId=
${vcap.application.instance_id}
eureka.instance.non-secure-port=80
application-cloud.properties
CF上では自動でcloudプロフ
ァイルが適用される
91@Copyright 2016 Pivotal. All rights reserved.
Eureka Clientのデプロイ
eureka.client.service-url.defaultZone=
${vcap.services.jsug-eureka-service.credentials.uri}/eureka/
eureka.instance.hostname=
${vcap.application.uris[0]}
eureka.instance.metadata-map.instanceId=
${vcap.application.instance_id}
eureka.instance.non-secure-port=80
application-cloud.properties
Spring Bootアプリには自動で
vcap.application.*にアプリに関する情報
vcap.services.*にサービスに関する情報
が設定される
92@Copyright 2016 Pivotal. All rights reserved.
Eureka Clientのデプロイ
eureka.client.service-url.defaultZone=
${vcap.services.jsug-eureka-service.credentials.uri}/eureka/
eureka.instance.hostname=
${vcap.application.uris[0]}
eureka.instance.metadata-map.instanceId=
${vcap.application.instance_id}
eureka.instance.non-secure-port=80
application-cloud.properties
サービス名 cfコマンドで設定したjsonの
プロパティ名
93@Copyright 2016 Pivotal. All rights reserved.
Eureka Clientのデプロイ
$ ./mvnw clean package -Dmaven.test.skip=true
$ cf push jsug-producer -p target/*.jar --no-start
$ cf bind-service jsug-producer jsug-eureka-service
$ cf start jsug-producer
http://jsug-producer.cfapps.io/
http://jsug-consumer.cfapps.io/
consumerも同様
94@Copyright 2016 Pivotal. All rights reserved.
eureka.instance.metadata-map.instanceId
で指定した値
95@Copyright 2016 Pivotal. All rights reserved.
スケールアウト
$ cf scale jsug-producer -i 3
$ cf scale jsug-consumer -i 2
96@Copyright 2016 Pivotal. All rights reserved.
スケールアウト結果がService Registryに
反映されている
97@Copyright 2016 Pivotal. All rights reserved.
98@Copyright 2016 Pivotal. All rights reserved.
DEMO
99@Copyright 2016 Pivotal. All rights reserved.
Heroku上にデプロイ
See
https://blog.heroku.com/archives/2015/3/3/manag
ing_your_microservices_on_heroku_with_netflix_s_eure
ka
100@Copyright 2016 Pivotal. All rights reserved. 100@Copyright 2016 Pivotal. All rights reserved.
Spring Cloud Services
by Pivotal Cloud Foundry
101@Copyright 2016 Pivotal. All rights reserved.
Pivotal Cloud Foundry
http://pivotal.io/platform
102@Copyright 2016 Pivotal. All rights reserved.
Spring Cloud Services
http://docs.pivotal.io/spring-cloud-services/
103@Copyright 2016 Pivotal. All rights reserved.
Spring Cloud Services
http://docs.pivotal.io/spring-cloud-services/
104@Copyright 2016 Pivotal. All rights reserved.
Service Registryサービス
$ cf create-service p-service-registry standard jsug-eureka-service
自分でEureka Server
を作る必要なし
105@Copyright 2016 Pivotal. All rights reserved.
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-starter-service-registry</artifactId>
<groupId>1.0.2.RELEASE</groupId>
</dependency>
現時点でSpring CloudはAngel.SR4
にしか対応していないこの依存関係を追加すれば
Eureka Client側にEureka Serverの設定
が不要になる
106@Copyright 2016 Pivotal. All rights reserved.
$ cf push jsug-producer -p target/*.jar --no-start
$ cf bind-service jsug-producer jsug-eureka-service
$ cf start jsug-producer
consumerも同様
107@Copyright 2016 Pivotal. All rights reserved.
Spring Cloud Services
http://docs.pivotal.io/spring-cloud-services/
今日は説明できませんが、
3つを組み合わせることで
最大の効果を得られる
108@Copyright 2016 Pivotal. All rights reserved.
概要はYoutubeで
• Config Server https://youtu.be/bJvReWt2jLc
• Service Registry https://youtu.be/tnVNiRn-TLw
• Circuit Breaker https://youtu.be/Vd243GqrkMI
109@Copyright 2016 Pivotal. All rights reserved.
まとめ
• Netflixビジネスのスピードを支えるマイク
ロサービスはSpring Cloud Netflixで簡単
に構築可能
• PaaSに簡単にデプロイ可能
• Spring Cloud Servicesを使うことでより簡
単にシステムを構築可能
110@Copyright 2016 Pivotal. All rights reserved.
Transforming How The World Builds Software

More Related Content

Spring Cloud Netflixを使おう #jsug

  • 1. 1@Copyright 2016 Pivotal. All rights reserved. 1@Copyright 2016 Pivotal. All rights reserved. Spring Cloud Netflixを使おう Japan Spring User Group勉強会2016その1 Toshiaki Maki ● @making Feb 1 2016
  • 2. 2@Copyright 2016 Pivotal. All rights reserved. Contents • NetflixとSpring Cloudについて • Spring Cloud Netflixについて • PaaSにデプロイしよう • Spring Cloud Services
  • 3. 3@Copyright 2016 Pivotal. All rights reserved. 資料のURL ハッシュタグは #jsug http://bit.ly/jsug-cloud
  • 4. 4@Copyright 2016 Pivotal. All rights reserved. 今日のソースコード https://github.com/making/jsug-spring-cloud
  • 5. 5@Copyright 2016 Pivotal. All rights reserved.
  • 6. 6@Copyright 2016 Pivotal. All rights reserved. 2015年9月1日 日本でもストーリーミングサービス開始
  • 7. 7@Copyright 2016 Pivotal. All rights reserved. http://hibana-netflix.jp/
  • 8. 8@Copyright 2016 Pivotal. All rights reserved. https://ja.wikipedia.org/wiki/ネットフリックス
  • 9. 9@Copyright 2016 Pivotal. All rights reserved. http://www.statista.com/statistics/250934/quarterly-number-of-netflix-streaming-subscribers-worldwide/
  • 10. 10@Copyright 2016 Pivotal. All rights reserved. http://www.slideshare.net/BruceWong3/the-case-for-chaos/12 Micro Services Continuous Delivery DevOps 圧倒的スピードで成長するビジネスを支える
  • 11. 11@Copyright 2016 Pivotal. All rights reserved. http://netflix.github.io/ • Eureka • Ribbon • Hystrix • Turbine • Zuul • Feign • Atlas • …
  • 12. 12@Copyright 2016 Pivotal. All rights reserved. Spring Cloud • 分散システムの共通パターンの実装を提供  Distributed Configuration  Service Registry  Circuit Breaker  Leadership Election  Distributed Messaging  Distributed Tracing  … • Dr. Dave Syer, Spencer Gibbがメイン開発者 http://projects.spring.io/spring-cloud/
  • 13. 13@Copyright 2016 Pivotal. All rights reserved. Spring Cloudサブプロジェクト • Spring Cloud Config • Spring Cloud Netflix • Spring Cloud Consul • Spring Cloud Sleuth • Spring Cloud Stream • Spring Cloud Task • Spring Cloud Data Flow • …
  • 14. 14@Copyright 2016 Pivotal. All rights reserved. Spring Cloud Netflix • Netflix OSSをSpring Bootと合わせて簡単に使う ためのライブラリ • Netflixでも使われている https://youtu.be/6wvVANQ6EJ8
  • 15. 15@Copyright 2016 Pivotal. All rights reserved. Release Train Spring Cloud (BOM) Angel.SR6 Brixton.M4 Brixton.BUILD-SNAPSHOT Spring Cloud Netflix 1.0.7.RELEASE 1.1.0.M4 1.1.0.BUILD-SNAPSHOT Spring Cloud Config 1.0.4.RELEASE 1.1.0.M4 1.1.0.BUILD-SNAPSHOT Spring Cloud Commons 1.0.5.RELEASE 1.1.0.M4 1.1.0.BUILD-SNAPSHOT Spring Cloud Consul - 1.0.0.M5 1.0.0.BUILD-SNAPSHOT Spring Cloud Zookeeper - 1.0.0.M4 1.0.0.BUILD-SNAPSHOT Spring Cloud Sleuth - 1.0.0.M4 1.0.0.BUILD-SNAPSHOT Spring Cloud Stream - 1.0.0.M3 1.0.0.BUILD-SNAPSHOT Spring Cloud Task - - 1.0.0.BUILD-SNAPSHOT Spring Cloud Dataflow - 1.0.0.M2 1.0.0.BUILD-SNAPSHOT Spring Boot 1.2.8.RELEASE 1.3.1.RELEASE 1.3.2.RELEASE
  • 16. 16@Copyright 2016 Pivotal. All rights reserved. Spring Cloudの使い方 <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-parent</artifactId> <version>Brixton.M4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
  • 17. 17@Copyright 2016 Pivotal. All rights reserved. 17@Copyright 2016 Pivotal. All rights reserved. Spring Cloud Netflix
  • 18. 18@Copyright 2016 Pivotal. All rights reserved. サービス多すぎ 接続情報の管理大変
  • 19. 19@Copyright 2016 Pivotal. All rights reserved. Service Discoveryパターン https://docs.pivotal.io/spring-cloud-services/service-registry/ Client(Consumer)が API(Producer)へ直接 アクセスするのではな く、Registryを経由す る
  • 20. 20@Copyright 2016 Pivotal. All rights reserved. サービス名から物理アドレスを解決 Service Name IP:PORT customer 192.168.11.1:8080 192.168.11.2:8080 … order 192.168.11.11:8080 192.168.11.12:8080 … catalog 192.168.11.21:8080 192.168.11.22:8080 …
  • 21. 21@Copyright 2016 Pivotal. All rights reserved. Eureka • RESTベースのService Registryサーバー • Netflixを支えるベース http://techblog.netflix.com/2012/09/eureka.html
  • 22. 22@Copyright 2016 Pivotal. All rights reserved. Eureka Client Service Consumer Service Producer Service Registry Eureka Server Eurekaを使う場合の基本構成
  • 23. 23@Copyright 2016 Pivotal. All rights reserved. Eureka Client Service Consumer Service Producer Service Registry Eureka Server Service Info (Cache) Heart Beat Eurekaを使う場合の基本構成
  • 24. 24@Copyright 2016 Pivotal. All rights reserved. Eurekaを使う場合の基本構成 Eureka Client Service Consumer Service Producer Service Registry Eureka Server Service Info (Cache) キャシュを使うので、 Eureka Serverがダウンしても Clientはサービス継続可能
  • 25. 25@Copyright 2016 Pivotal. All rights reserved. Eureka Serverの作成 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency>
  • 26. 26@Copyright 2016 Pivotal. All rights reserved. https://start.spring.io
  • 27. 27@Copyright 2016 Pivotal. All rights reserved. Eureka Serverの作成 @SpringBootApplication @EnableEurekaServer public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class,args); } }
  • 28. 28@Copyright 2016 Pivotal. All rights reserved. Stand Aloneモード # 慣習的ポート番号 server.port=8761 # Eurekaサーバーへの登録は不要 eureka.client.register-with-eureka=false eureka.client.fetch-registry=false application.properties
  • 29. 29@Copyright 2016 Pivotal. All rights reserved. Dashboard
  • 30. 30@Copyright 2016 Pivotal. All rights reserved. DEMO
  • 31. 31@Copyright 2016 Pivotal. All rights reserved. マルチインスタンスモード server.port=8761 eureka.instance.hostname=peer1 # Eurekaサーバーへ登録 eureka.client.register-with-eureka=true eureka.client.fetch-registry=true # 登録するEurekaサーバーへのURL(Eurekaサーバー自体がクライアント) eureka.client.service-url.defaultZone=http://peer2:8762/eureka/ application-peer1.properties
  • 32. 32@Copyright 2016 Pivotal. All rights reserved. マルチインスタンスモード server.port=8762 eureka.instance.hostname=peer2 # Eurekaサーバーへ登録 eureka.client.register-with-eureka=true eureka.client.fetch-registry=true # 登録するEurekaサーバーへのURL(Eurekaサーバー自体がクライアント) eureka.client.service-url.defaultZone=http://peer1:8761/eureka/ application-peer2.properties
  • 33. 33@Copyright 2016 Pivotal. All rights reserved. $ ./mvnw clean package -Dmaven.test.skip=true $ java -jar target/*.jar --spring.profile.active=peer1 $ java -jar target/*.jar --spring.profile.active=peer2 Eureka Serverインスタンス1(ビルド&)起動 Eureka Serverインスタンス2起動 ローカルで試す場合は/etc/hostsにpeer1とpeer2を登録
  • 34. 34@Copyright 2016 Pivotal. All rights reserved. インメモリのキャッシュにメタデータを保持し ているので、自動復旧機能があるプラットフ ォーム(Cloud Foundryなど)上であれば Stand Aloneモードで十分
  • 35. 35@Copyright 2016 Pivotal. All rights reserved. Eureka Clientの作成 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency>
  • 36. 36@Copyright 2016 Pivotal. All rights reserved.
  • 37. 37@Copyright 2016 Pivotal. All rights reserved. Eureka Client (Producer) @SpringBootApplication @EnableDiscoveryClient @RestController public class ProducerApplication { private static final UUID id = UUID.randomUUID(); @RequestMapping(path = "/") String hello() { return "Hello @" + id; } public static void main(String[] args) { SpringApplication.run(ProducerApplication.class, args); } }
  • 38. 38@Copyright 2016 Pivotal. All rights reserved. Eureka Client (Producer) server.port=9000 # 登録するEurekaサーバーのURL eureka.client.service-url.defaultZone=http://localhost:8761/eureka/ application.properties # Eurekaサーバーに登録するサービス名 spring.application.name=jsug-producer bootstrap.properties
  • 39. 39@Copyright 2016 Pivotal. All rights reserved. その他のプロパティ # 情報の更新間隔(デフォルト30秒) eureka.instance.lease-renewal-interval-in-seconds=3 # インスタンスのID(ダッシュボードのリンク名などに使われる) eureka.instance.metadata-map.instanceId=${spring.application.name}:${random.value} # ホスト名の代わりにIPアドレスを使用(ホスト名を解決できないDockerを使う場合など) eureka.instance.prefer-ip-address=true application.properties
  • 40. 40@Copyright 2016 Pivotal. All rights reserved.
  • 41. 41@Copyright 2016 Pivotal. All rights reserved.
  • 42. 42@Copyright 2016 Pivotal. All rights reserved.
  • 43. 43@Copyright 2016 Pivotal. All rights reserved. Eureka Client (Consumer) @SpringBootApplication @EnableDiscoveryClient @RestController public class ConsumerApplication { @Autowired EurekaClient client; @RequestMapping(path = "/") String hello() { String url = client .getNextServerFromEureka("jsug-producer", false) .getHomePageUrl(); String res = new RestTemplate() .getForObject(url, String.class); return res + " from " + url; } public static void main(String[] args) {/*...*/} }
  • 44. 44@Copyright 2016 Pivotal. All rights reserved. Eureka Client (Consumer) server.port=9100 # 登録するEurekaサーバーのURL eureka.client.service-url.defaultZone=http://localhost:8761/eureka/ application.properties # Eurekaサーバーに登録するサービス名 spring.application.name=jsug-consumer bootstrap.properties
  • 45. 45@Copyright 2016 Pivotal. All rights reserved. Eureka Client (Consumer) eureka.client.service-url.defaultZone= http://peer1:8761/eureka/,http://peer2:8762/eureka/ Eureka Serverが複数の場合
  • 46. 46@Copyright 2016 Pivotal. All rights reserved.
  • 47. 47@Copyright 2016 Pivotal. All rights reserved.
  • 48. 48@Copyright 2016 Pivotal. All rights reserved. DEMO
  • 49. 49@Copyright 2016 Pivotal. All rights reserved. DiscoveryClient org.springframework.cloud.client.discovery.DiscoveryClient 各種Service Registryに対するクライアントの 共通インタフェース • EurekaDiscoveryClient (Spring Cloud Netflix) • ConsulDiscovertyClient (Spring Cloud Consul) • ZookeeperDiscoveryClient (Spring Cloud Zookeeper) • CloudFoundryDiscoveryClient (Spring Cloud CloudFoundry) • EtcdDiscoveryClient (Spring Cloud Etcd) incubator
  • 50. 50@Copyright 2016 Pivotal. All rights reserved. DiscoveryClientを使って書き直し @Autowired DiscoveryClient client; @RequestMapping(path = "/") String hello() { List<ServiceInstance> instances = client .getInstances("jsug-producer"); if (instances.isEmpty()) { return "No ServiceRegistry!"; } ServiceInstance instance = instances.get(0); URI uri = instance.getUri(); String res = new RestTemplate() .getForObject(uri, String.class); return res + " from " + url; }
  • 51. 51@Copyright 2016 Pivotal. All rights reserved. Ribbon • HTTPクライアントと連携するクライアントサイドロ ードバランサ • Eurekaの情報を使ってロードバランス可能 http://techblog.netflix.com/2013/01/announcing-ribbon-tying-netflix-mid.html
  • 52. 52@Copyright 2016 Pivotal. All rights reserved. Service ProducerService Producer Service Consumer Service Producer Service Registry Load Balancer Load Balancerあり
  • 53. 53@Copyright 2016 Pivotal. All rights reserved. @SpringBootApplication @EnableDiscoveryClient @RestController public class ConsumerApplication { @Autowired RestTemplate restTemplate; @RequestMapping(path = "/") String hello() { String res = restTemplate .getForObject("http://jsug-producer", String.class); return res + " from " + url; } public static void main(String[] args) {/*...*/} } 自動でRibbonを使った インターセプタが組み込まれる
  • 54. 54@Copyright 2016 Pivotal. All rights reserved. $ ./mvnw clean package -Dmaven.test.skip=true $ java -jar target/jsug-producer-*.jar --server.port=9000 $ java -jar target/jsug-producer-*.jar --server.port=9001 Consumerインスタンス1(ビルド&)起動 Consumerインスタンス2起動
  • 55. 55@Copyright 2016 Pivotal. All rights reserved.
  • 56. 56@Copyright 2016 Pivotal. All rights reserved.
  • 57. 57@Copyright 2016 Pivotal. All rights reserved. DEMO
  • 58. 58@Copyright 2016 Pivotal. All rights reserved. その他Spring Cloud + Ribbon 対応HTTPクライアント • Feign http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#spring-cloud-feign • OkHttp https://github.com/spencergibb/okhttp-ribbon • Retrofit (OkHttp利用)
  • 59. 59@Copyright 2016 Pivotal. All rights reserved. Hystrix • Circuit Breakerパターンを提供 • 障害のあるサービスへのアクセスを一 時的に遮断して、代替値を返すことで 障害の伝播を防ぐ http://techblog.netflix.com/2012/11/hystrix.html
  • 60. 60@Copyright 2016 Pivotal. All rights reserved. Circuit Breaker
  • 61. 61@Copyright 2016 Pivotal. All rights reserved. Hystrixの利用 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency>
  • 62. 62@Copyright 2016 Pivotal. All rights reserved. Hystrixの利用 @Component class DemoService { @Autowired RestTemplate restTemplate; @HystrixCommand(fallbackMethod = "defaultResponse") public String getResponse() { return restTemplate .getForObject("http://jsug-producer", String.class); } public String defaultResponse() { return "Not Available now"; } }
  • 63. 63@Copyright 2016 Pivotal. All rights reserved. Hystrixの利用 @SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker @RestController public class ConsumerApplication { @Autowired DemoService demoService; @RequestMapping(path = "/") String hello() { String res = demoService.getResponse(); return res + " from " + url; } public static void main(String[] args) {/*...*/} }
  • 64. 64@Copyright 2016 Pivotal. All rights reserved.
  • 65. 65@Copyright 2016 Pivotal. All rights reserved.
  • 66. 66@Copyright 2016 Pivotal. All rights reserved.
  • 67. 67@Copyright 2016 Pivotal. All rights reserved. Recover!
  • 68. 68@Copyright 2016 Pivotal. All rights reserved.
  • 69. 69@Copyright 2016 Pivotal. All rights reserved.
  • 70. 70@Copyright 2016 Pivotal. All rights reserved.
  • 71. 71@Copyright 2016 Pivotal. All rights reserved. Hystrix Metrics Stream <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-cloud-starter-actuator</artifactId> </dependency> エンドポイント/hystrix.stream が追加される
  • 72. 72@Copyright 2016 Pivotal. All rights reserved. Server-Sent Events
  • 73. 73@Copyright 2016 Pivotal. All rights reserved. Dashboard <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency>
  • 74. 74@Copyright 2016 Pivotal. All rights reserved. Dashboardアプリケーション @SpringBootApplication @EnableHystrixDashboard public class HystrixDashboardApplication { public static void main(String[] args) {/*...*/} }
  • 75. 75@Copyright 2016 Pivotal. All rights reserved.
  • 76. 76@Copyright 2016 Pivotal. All rights reserved.
  • 77. 77@Copyright 2016 Pivotal. All rights reserved.
  • 78. 78@Copyright 2016 Pivotal. All rights reserved. 普通のtry-catchと何が違う? • ダウンしたサービスへのアクセスを遮断しないと、 エラー発生までのリソース(スレッド、メモリ、…)が 無駄になる →障害の伝播につながる
  • 79. 79@Copyright 2016 Pivotal. All rights reserved. 複数のHystrixストリームを集約 • Turbineを使って複数のストリームを集約可能 • Turbine + AMQP (RabbitMQ)を使った集約も可能 http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#_turbine
  • 80. 80@Copyright 2016 Pivotal. All rights reserved. Zuul • Eurekaの情報を使ったプロキシ • エッジサーバーとして利用 • その他様々なルーティング機能 http://techblog.netflix.com/2013/06/announcing-zuul-edge-service-in-cloud.html
  • 81. 81@Copyright 2016 Pivotal. All rights reserved. Zuulの利用 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zuul</artifactId> </dependency>
  • 82. 82@Copyright 2016 Pivotal. All rights reserved. Zuulの利用 @SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker @EnableZuulProxy @RestController public class ConsumerApplication { // ... public static void main(String[] args) {/*...*/} }
  • 83. 83@Copyright 2016 Pivotal. All rights reserved.
  • 84. 84@Copyright 2016 Pivotal. All rights reserved. application.propertiesでルーティング設定 zuul.routes.jsug-producer=/foo/** http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#_router_and_filter_zuul ymlの方が書 きやすい
  • 85. 85@Copyright 2016 Pivotal. All rights reserved. 85@Copyright 2016 Pivotal. All rights reserved. PaaSにデプロイしよう
  • 86. 86@Copyright 2016 Pivotal. All rights reserved. Cloud Foundry上にデプロイ • OpenなPaaSプラットフォーム • cfコマンドでアプリケーションのデプロイを操作 • 基本的な話は https://blog.ik.am/entries/359
  • 87. 87@Copyright 2016 Pivotal. All rights reserved. Pivotal Web Services https://run.pivotal.io/ • Pivotalが運用するパブリックなCloud Foundry $ cf login -a api.run.pivotal.io https://blog.ik.am/entries/361(FYI) local環境で試したい場合はMicroPCFを
  • 88. 88@Copyright 2016 Pivotal. All rights reserved. Eureka Serverのデプロイ $ ./mvnw clean package -Dmaven.test.skip=true $ cf push jsug-eureka-server -p target/*.jar http://jsug-eureka-server.cfapps.io/ jarをcf pushするだけ
  • 89. 89@Copyright 2016 Pivotal. All rights reserved. Eureka ServerをCFのサービスとして公開 $ cf create-user-provided-service jsug-eureka-service -p '{"uri":"http://jsug-eureka-server.cfapps.io/"}' $ cf services name service plan bound apps jsug-eureka-service user-provided 接続先情報や認証情報など環境依存の情報をサービスとして 公開し、(後で)接続するアプリケーションにバインドする
  • 90. 90@Copyright 2016 Pivotal. All rights reserved. Eureka Clientのデプロイ eureka.client.service-url.defaultZone= ${vcap.services.jsug-eureka-service.credentials.uri}/eureka/ eureka.instance.hostname= ${vcap.application.uris[0]} eureka.instance.metadata-map.instanceId= ${vcap.application.instance_id} eureka.instance.non-secure-port=80 application-cloud.properties CF上では自動でcloudプロフ ァイルが適用される
  • 91. 91@Copyright 2016 Pivotal. All rights reserved. Eureka Clientのデプロイ eureka.client.service-url.defaultZone= ${vcap.services.jsug-eureka-service.credentials.uri}/eureka/ eureka.instance.hostname= ${vcap.application.uris[0]} eureka.instance.metadata-map.instanceId= ${vcap.application.instance_id} eureka.instance.non-secure-port=80 application-cloud.properties Spring Bootアプリには自動で vcap.application.*にアプリに関する情報 vcap.services.*にサービスに関する情報 が設定される
  • 92. 92@Copyright 2016 Pivotal. All rights reserved. Eureka Clientのデプロイ eureka.client.service-url.defaultZone= ${vcap.services.jsug-eureka-service.credentials.uri}/eureka/ eureka.instance.hostname= ${vcap.application.uris[0]} eureka.instance.metadata-map.instanceId= ${vcap.application.instance_id} eureka.instance.non-secure-port=80 application-cloud.properties サービス名 cfコマンドで設定したjsonの プロパティ名
  • 93. 93@Copyright 2016 Pivotal. All rights reserved. Eureka Clientのデプロイ $ ./mvnw clean package -Dmaven.test.skip=true $ cf push jsug-producer -p target/*.jar --no-start $ cf bind-service jsug-producer jsug-eureka-service $ cf start jsug-producer http://jsug-producer.cfapps.io/ http://jsug-consumer.cfapps.io/ consumerも同様
  • 94. 94@Copyright 2016 Pivotal. All rights reserved. eureka.instance.metadata-map.instanceId で指定した値
  • 95. 95@Copyright 2016 Pivotal. All rights reserved. スケールアウト $ cf scale jsug-producer -i 3 $ cf scale jsug-consumer -i 2
  • 96. 96@Copyright 2016 Pivotal. All rights reserved. スケールアウト結果がService Registryに 反映されている
  • 97. 97@Copyright 2016 Pivotal. All rights reserved.
  • 98. 98@Copyright 2016 Pivotal. All rights reserved. DEMO
  • 99. 99@Copyright 2016 Pivotal. All rights reserved. Heroku上にデプロイ See https://blog.heroku.com/archives/2015/3/3/manag ing_your_microservices_on_heroku_with_netflix_s_eure ka
  • 100. 100@Copyright 2016 Pivotal. All rights reserved. 100@Copyright 2016 Pivotal. All rights reserved. Spring Cloud Services by Pivotal Cloud Foundry
  • 101. 101@Copyright 2016 Pivotal. All rights reserved. Pivotal Cloud Foundry http://pivotal.io/platform
  • 102. 102@Copyright 2016 Pivotal. All rights reserved. Spring Cloud Services http://docs.pivotal.io/spring-cloud-services/
  • 103. 103@Copyright 2016 Pivotal. All rights reserved. Spring Cloud Services http://docs.pivotal.io/spring-cloud-services/
  • 104. 104@Copyright 2016 Pivotal. All rights reserved. Service Registryサービス $ cf create-service p-service-registry standard jsug-eureka-service 自分でEureka Server を作る必要なし
  • 105. 105@Copyright 2016 Pivotal. All rights reserved. <dependency> <groupId>io.pivotal.spring.cloud</groupId> <artifactId>spring-cloud-services-starter-service-registry</artifactId> <groupId>1.0.2.RELEASE</groupId> </dependency> 現時点でSpring CloudはAngel.SR4 にしか対応していないこの依存関係を追加すれば Eureka Client側にEureka Serverの設定 が不要になる
  • 106. 106@Copyright 2016 Pivotal. All rights reserved. $ cf push jsug-producer -p target/*.jar --no-start $ cf bind-service jsug-producer jsug-eureka-service $ cf start jsug-producer consumerも同様
  • 107. 107@Copyright 2016 Pivotal. All rights reserved. Spring Cloud Services http://docs.pivotal.io/spring-cloud-services/ 今日は説明できませんが、 3つを組み合わせることで 最大の効果を得られる
  • 108. 108@Copyright 2016 Pivotal. All rights reserved. 概要はYoutubeで • Config Server https://youtu.be/bJvReWt2jLc • Service Registry https://youtu.be/tnVNiRn-TLw • Circuit Breaker https://youtu.be/Vd243GqrkMI
  • 109. 109@Copyright 2016 Pivotal. All rights reserved. まとめ • Netflixビジネスのスピードを支えるマイク ロサービスはSpring Cloud Netflixで簡単 に構築可能 • PaaSに簡単にデプロイ可能 • Spring Cloud Servicesを使うことでより簡 単にシステムを構築可能
  • 110. 110@Copyright 2016 Pivotal. All rights reserved. Transforming How The World Builds Software