operating a high velocity large organization with spring cloud microservices
TRANSCRIPT
![Page 1: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/1.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/
Operating a High Velocity Large Organization with Spring Cloud
MicroservicesNoriaki (Nori) Tatsumi
Capital One
![Page 2: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/2.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/
Who we are
2
![Page 3: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/3.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/
Data LakePowered by C1 Data Intelligence Team
CC Image by Stanislav Sedov on Flickr
![Page 4: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/4.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/4
Continuous Delivery
Build, test, and release fast and frequently to operate high velocity organization
Prerequisite. Not luxury.
![Page 5: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/5.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/5
Continuous delivery principles• Eliminate non-value added actions• Release process must be repeatable and reliable• Quality is built in• Version everything• Done = “Released”• Small batches of features and experimentations• Everyone is responsible• Kaizen – Improve continuously
![Page 6: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/6.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/6
Our challengesCategory Examples
Complex systems Large code base and deploymentImplementation sensitivityTest feedback speed
Many teams Collaboration of design & technologyMerge conflicts
Non functional qualities SecurityHigh availability, reliability, maintainabilitySame qualities across components/features
Compliance TraceabilityData lineage
Legacy and 3rd party applications
Implementation of same qualities as the rest
Processes Time consuming reviews and approvals
![Page 7: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/7.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/7
Customer expectation• Quality• Availability• Velocity - fast and frequent deliveries of features
But they don’t know about the technical challenges
![Page 8: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/8.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/8
Microservices architecturehttp://martinfowler.com/articles/microservices.html
The twelve factor methodologyhttp://12factor.net/
![Page 9: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/9.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/9
Intranet/VPN
![Page 10: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/10.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/10
![Page 11: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/11.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/11
Spring CloudFor foundation of microservices architecture
![Page 12: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/12.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/12
Spring Cloud• *Spring Cloud Config• *Spring Cloud Netflix• Spring Cloud Bus• Spring Cloud for Cloud Foundry• Spring Cloud Cloud Foundry
Service Broker• Spring Cloud Cluster• Spring Cloud Consul• *Spring Cloud Security• *Spring Cloud Sleuth• Spring Cloud Data Flow
• Spring Cloud Stream• Spring Cloud Stream Modules• Spring Cloud Task• Spring Cloud Zookeeper• Spring Cloud for Amazon Web
Services• Spring Cloud Connectors• Spring Cloud Starters• Spring Cloud CLI
![Page 13: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/13.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/13
Technology selection• JVM-based
• Developer productivity• Production support
• Spring Boot• Opinionated view for developer productivity• Production grade qualities
• Netflix OSS• Proven microservices technology
![Page 14: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/14.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/14
Decoupling• Work in parallel• Quicker and smaller deploys• Domain driven design• Do one scope of things well
![Page 15: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/15.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/15
Decoupling• Work in parallel• Quicker and smaller deploys• Domain driven design• Do one scope of things well• Technology stack agnostic
![Page 16: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/16.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/16
Decoupling• Work in parallel• Quicker and smaller deploys• Domain driven design• Do one scope of things well• Technology stack agnostic• Functions are shareable
![Page 17: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/17.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/17
Decoupling• Work in parallel• Quicker and smaller deploys• Domain driven design• Do one scope of things well• Technology stack agnostic• Functions are shareable• Independent scalability by comp.• Greater resiliency & availability• Continuous delivery friendly
![Page 18: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/18.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/18
This looks hard to orchestrate
![Page 19: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/19.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/19
Service discovery (registry)• Netflix Eureka (HashiCorp Consul, Apache Zookeeper)• Locate services• Load balancing• Failover• Resiliency
![Page 20: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/20.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/20
<application> <name>...</name> <instance> <instanceId>... </instanceId> <hostName>... </hostName> <app>...</app> <ipAddr>...</ipAddr> <status>UP</status> <overriddenstatus>UNKNOWN</overriddenstatus> <port enabled="false">...</port> <securePort enabled="true">...</securePort> <countryId>1</countryId> <dataCenterInfo class="com.netflix.appinfo.AmazonInfo"> <name>Amazon</name> <metadata> <accountId>...</accountId> <local-hostname>... </local-hostname> <instance-id>...</instance-id> <local-ipv4>...</local-ipv4> <instance-type>...</instance-type> <vpc-id>...</vpc-id> <ami-id>...</ami-id> <mac>...</mac> <availability-zone>...</availability-zone> </metadata> </dataCenterInfo> <leaseInfo> <renewalIntervalInSecs>...</renewalIntervalInSecs> <durationInSecs>...</durationInSecs> …..
DEMO TIME!
![Page 21: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/21.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/21
Service discovery (registry)@SpringBootApplication@EnableEurekaServerpublic class Discovery {
public static void main(String[] args) { SpringApplication.run(Discovery.class, args);}
}
![Page 22: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/22.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/22
Service discovery (registry)eureka:
instance: appname: discovery app-group-name: bedrock lease-renewal-interval-in-seconds: 30 #sending heartbeats; 90 secs removes from registry eureka.instance.preferIpAddress: false home-page-url: http://${spring.cloud.client.hostname}:${server.port}/discovery health-check-url: http://${spring.cloud.client.hostname}:${management.port}${management.context-path}/health status-page-url: http://${spring.cloud.client.hostname}:${management.port}${management.context-path}/info password: changeme dashboard: path: /discovery client: serviceUrl: defaultZone: http://user:changeme@peer2:8761/eureka/ healthcheck: enabled: true
![Page 23: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/23.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/23
Making your Spring Boot app discoverable
@SpringBootApplication@EnableDiscoveryClientpublic class Application {
public static void main(String[] args) { SpringApplication.run(Application.class, args);}
}
![Page 24: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/24.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/24
Making your Spring Boot app discoverable
protected static void registerShutdownHooks() {Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOG.info("Shutting down, unregister from discovery service!"); DiscoveryManager.getInstance().shutdownComponent(); }});…..
}
![Page 25: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/25.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/25
Making your Spring Boot app discoverable
@Bean@Profile("aws")public EurekaInstanceConfigBean eurekaInstanceAwsConfig(InetUtils inetUtils) {
LOG.info("Configuring this instance to be Amazon aware...");EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");config.setDataCenterInfo(info);return config;
}
Tip: Some Spring Cloud default configurations such as the Eureka instance ID and the Eureka instance port doesn’t take effect when customizing EurekaInstanceConfigBean. Set them explicitly.
![Page 26: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/26.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/26
Making your non-Spring Boot app discoverableEureka Client (Java)https://github.com/Netflix/eureka/wiki/Understanding-eureka-client-server-communication
Eureka REST API (Polyglot)https://github.com/Netflix/eureka/wiki/Eureka-REST-operationsNote: Omit “/v2” in URI
Sidecar/App Gateway (Polyglot)Sits next to your app. Enables applications to be service discoverable and secure without code modification.
![Page 27: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/27.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/27
Service discovery clients• Netflix Eureka Client• Spring Cloud
• Feign• Spring RestTemplate
• Any HTTP client
![Page 28: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/28.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/28
Spring Boot Admin with Eureka
https://github.com/codecentric/spring-boot-adminDEMO TIME!
![Page 29: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/29.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/29
Spring Boot Admin with Eureka@SpringBootApplication@EnableAutoConfiguration@EnableDiscoveryClient@EnableAdminServerpublic class Admin extends BaseSpringBootApplication { public static void main(String[] args) { SpringApplication.run(Admin.class, args); }
}
![Page 30: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/30.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/30
Spring Boot Admin with Eureka@Componentpublic class EurekaApplicationDiscoveryListener extends ApplicationDiscoveryListener { @Autowired public EurekaApplicationDiscoveryListener(DiscoveryClient discoveryClient, ApplicationRegistry registry) { super(discoveryClient, registry); ServiceInstanceConverter converter = new DefaultServiceInstanceConverter() { @Override public Application convert(ServiceInstance instance) { EurekaDiscoveryClient.EurekaServiceInstance eurekaServiceInstance = (EurekaDiscoveryClient.EurekaServiceInstance) instance; final Application temp = super.convert(instance); final Application converted = Application.create(temp) .withHealthUrl(eurekaServiceInstance.getInstanceInfo().getHealthCheckUrl()) .withManagementUrl(eurekaServiceInstance.getInstanceInfo().getStatusPageUrl().replaceFirst("/info", "")) .withServiceUrl(eurekaServiceInstance.getInstanceInfo().getHomePageUrl()) .build(); return converted; } }; setConverter(converter); }}
![Page 31: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/31.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/31
Spring Boot Admin with Component Auth
@Configuration@AutoConfigureAfter({RevereseZuulProxyConfiguration.class})protected static class ExtendedZuulProxyConfiguration extends ZuulConfiguration { @Bean public ComponentAuthEnrichFilter componentAuthEnrichFilter() { return new ComponentAuthEnrichFilter(); }
}
![Page 32: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/32.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/32
Centralized monitoring@Componentpublic class MetricsShipper { ….. public JSONObject composeMetrics() { JSONObject metricsJson = new JSONObject(); metricsJson.put("timestamp", System.currentTimeMillis()); metricsJson.put("application", appName); metricsJson.put("instance", eurekaInstanceConfig.getInstanceId()); metricsJson.put("status", healthEndpoint.invoke().getStatus().getCode()); Map<String, Object> metrics = metricsEndpoint.invoke(); for (String metricKey : metrics.keySet()) { metricsJson.put(metricKey.replaceAll("[.]", "-"), metrics.get(metricKey)); } return metricsJson; } @Scheduled(fixedRateString = "${monitoring.shipper.kafka.fixedRate}", initialDelayString = "${monitoring.shipper.kafka.fixedRate}") public void ship() { kafkaTarget.ship(composeMetrics()); }}
![Page 33: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/33.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/33
Distributed tracing
http://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html
![Page 34: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/34.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/34
Distributed tracing<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-sleuth</artifactId></dependency>
service1.log:2016-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
-----server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %I "%{x-b3-
spanid}i" "%{x-b3-traceid}i" "%{x-b3-parentspanid}i”
127.0.0.1 - - [24/May/2016:02:06:44 -0400] "POST /elasticsearch/_msearch?ignore_unavailable=true&preference=1464070003866&timeout=0 HTTP/1.1" 200 148 7 http-nio-8444-exec-5 "27c37d6638ab6c87" "150e347f81964ffd" "150e347f81964ffd"
![Page 35: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/35.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/35
Distributed tracing
![Page 36: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/36.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/36
Security*Across all components in various languages• SSO• User authorization• Component to component authentication and authorization• CORS• Appropriate routing• Auditing and logging• Insights and inspection• Rate limiting• A well known entry to platform
![Page 37: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/37.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/37
Intranet/VPN
![Page 38: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/38.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/38
Edge gateway@SpringBootApplication@EnableAutoConfiguration@EnableZuulProxypublic class EdgeGateway {
public static void main(String[] args) throws Exception { SpringApplication.run(EdgeGateway.class, args);}
}
![Page 39: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/39.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/39
Edge gateway - Routingzuul.ignoredServices=*
zuul.routes.root.path=/zuul.routes.root.url=forward:/redirectzuul.routes.app1.path=/app1/**zuul.routes.app1.serviceId=app1zuul.routes.app1.stripPrefix=falsezuul.routes.app1.sensitive-headers=Cookie,Set-Cookie
zuul.routes.app2.path=/app2/**zuul.routes.app2.url=https://app2:8443
![Page 40: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/40.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/40
Edge gateway - Authentication• SAML 2.0
Sample: https://github.com/vdenotaris/spring-boot-security-saml-sample
• OAuth 2.0Sample: https://github.com/royclarkson/spring-rest-service-oauth
![Page 41: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/41.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/41
Edge gateway - Filter@Componentpublic class ComponentAuthEnrichFilter extends ZuulFilter { …. @Override public String filterType() { return FilterType.pre.name(); } @Override public int filterOrder() { return FilterOrder.BASIC_AUTH_ENRICH_PRE_FILTER.getOrder(); } @Override public boolean shouldFilter() { return isFilterEnabled; } @Override public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); ctx.addZuulRequestHeader("Authorization", authorizationHeaderValue); return null; }}
• Enrich requests• Inspect requests• Collect stats• Redirect• Etc.
![Page 42: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/42.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/42
Sidecar / app gateway• Discover service registry• Authentication and authorization• Inspect compliance• Auditing and logging• Distributed tracing• Health check• Monitoring
![Page 43: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/43.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/43
Sidecar / app gateway
DEMO TIME!
![Page 44: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/44.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/44
Sidecar / app gateway (@EnableSidecar)
server: port: 5678spring: application: name: sidecarsidecar: port: 8000 health-uri: http://localhost:8000/health.json
![Page 45: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/45.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/45
Sidecar / app gateway (Custom @EnableZuulProxy)@Componentpublic class SidecarHealthIndicator extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) throws Exception { if (AppHeartbeatCheck.isHealthy()) { builder.up(); } else { builder.outOfService().withDetail("Failed attempts",AppHeartbeatCheck.getFailedAttempts()); } }}-----------sidecar.healthcheck.fixedRate=5000sidecar.healthcheck.maxAttempts=3sidecar.healthcheck.url=http://localhost:5601sidecar.healthcheck.expectedResponseCode=200
![Page 46: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/46.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/46
Circuit breaker• Help reduce resources tied up in operations
which are likely to fail with fallback• Avoid waiting on timeouts for the client• Avoid putting loads on a struggling server• Zuul uses Netflix Hystrix
http://martinfowler.com/bliki/CircuitBreaker.html
![Page 47: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/47.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/47
Circuit breaker@SpringBootApplication@EnableCircuitBreakerpublic class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class).web(true).run(args); }}@Componentpublic class StoreIntegration { @HystrixCommand(fallbackMethod = "defaultStores") public Object getStores(Map<String, Object> parameters) { //do stuff that might fail } public Object defaultStores(Map<String, Object> parameters) { return /* something useful */; }}
![Page 48: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/48.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/48
Zuul gotchas• No sticky session for your legacy and 3rd party apps that might need it• WebSockets, Server-sent Events, HTTP2 not supported
![Page 49: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/49.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/49
VersioningArtifacts - Semantic versioning• MAJOR version when you make incompatible API changes• MINOR version when you add functionality in a backwards-compatible
manner• PATCH version when you make backwards-compatible bug fixes
Configurations - Git revision hash• All configurations applied via automation
![Page 50: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/50.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/50
Configuration• There are more configurations to manage than monolith• Spring Boot application properties (application.properties/yml)• Spring Cloud bootstrap context (bootstrap.properties/yml)
• Parent context for main app (loaded before application properties)• Loads configs from external properties (e.g. Spring Cloud Config
Server)• Encryption/decryption of sensitive properties
• Immutable infrastructure with automation
![Page 51: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/51.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/51
Other keys things…• DevOps culture• Good documentation for the microservices foundation for multiple
teams to use• Automate everything
![Page 52: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/52.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/52
Take away• It’s not hard to get started with microservices… if you use Spring
Cloud• Start delivering faster and deploy more frequently
![Page 53: Operating a High Velocity Large Organization with Spring Cloud Microservices](https://reader031.vdocuments.net/reader031/viewer/2022022413/58ecd9f91a28ab2b568b462b/html5/thumbnails/53.jpg)
Unless otherwise indicated, these s l ides are © 2013-2016 Pivota l Software , Inc . and l icensed under a Creative Commons Attr ibution-NonCommerc ia l l i cense:
http:/ /c reativecommons .org/ l icenses/by-nc/3.0/
Learn More. Stay Connected.
Noriaki Tatsumi
https://www.linkedin.com/company/capital-one
https://twitter.com/capitalonejobs
https://github.com/capitalone