using Spring Cloud Netflix Jacek Bukowski Consultant Engineering JUG Zielona Góra 30112016 Spring was always about simplifying the complicated aspects of your enterprise system Netflix went to ID: 540226
Download Presentation The PPT/PDF document "Cloud Native Applications" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Cloud Native Applications using Spring Cloud Netflix
Jacek Bukowski
Consultant Engineering
JUG Zielona Góra 30.11.2016Slide2
Spring was always about simplifying the complicated aspects of your enterprise system. Netflix went to microservice architecture long before this term even was created. Both are very much contributed to open source software. How can you benefit from joint forces of the both?
Joint forces of Netflix and
SpringSlide3
Cloud and Cloud Native ApplicationSlide4
any computing environment in which computing, networking, and storage resources can be provisioned and released elastically in an on-demand, self-service manner
from
„Migrating to Cloud Native Applications Architectures”
by Matt Stine
CloudSlide5
Target cloud
Service model
Cloud Provider
SaaS
PaaS
IaaS
MBaaS
EaaS
XaaS
*aaSSlide6
Technology stack
Language
PersistenceSlide7
Style of application developmentCharacteristicsTwelve-Factor Applications – http://12factor.net MicroservicesSelf-Service Agile InfrastructureAPI-Based Collaboration
Antifragility
Cultural & Organizational changes
Cloud NativeSlide8
Codebase One codebase tracked in revision control, many deploysDependencies
Explicitly declare and isolate
dependen
cies
Config
Store config
in the environment
Backing services
Treat backing services as attached resources
Build, release, run
Strictly separate build and run stages
Processes
Execute the app as one or more stateless processes
The Twelve-Factor App (from 12factor.net)
Port bindingExport services via port bindingConcurrencyScale out via the process model
DisposabilityMaximize robustness with fast startup and graceful shutdownDev/prod parityKeep development, staging, and production as similar as possibleLogs
Treat logs as event streamsAdmin processesRun admin/management tasks as one-off processesSlide9
Style of application developmentCharacteristicsTwelve-Factor Applications – http://12factor.net MicroservicesSelf-Service Agile InfrastructureAPI-Based Collaboration
Antifragility
Cultural & Organizational changes
Cloud NativeSlide10
NetflixSlide11
Moved away of monolithic architecture before microservices where named (started in 2009, ended early 2016)30% of the Internet traffic500+ microservices2+ billion API
gateway
requests
d
ailyEach API call requires avarage six calls to backend services
Over 800 different client devices
Open sourced much of their tools and services
Netflix – some factsSlide12
Netflix provides the Open Source Software Center: http://netflix.github.io/Big DataBuild and Delivery ToolsCommon Runtime Services & Libraries
Content Encoding
Data Persistence
Insight, Reliability and Performance
Security
User Interface
Netflix Open Source Software (OSS)Slide13
Eureka – registry/service discoveryArchaius – distributed configurationRibbon – inter process and service communicationHystrix – reliability of calls and fault toleranceKaryon and Governator – containers
Prana – support for non-JVM runtimes
Zuul –
dynamic routing, monitoring, resiliency and security
, used to handle front end requests
Fenzo – scheduler for Apache Mesos
Netflix Open Source Software (OSS)
Runtime and LibrariesSlide14
Spring CloudSlide15
Facilitates the Cloud Native stylesCommon features required by all the components in a distributed systemDistributed/versioned configurationService registration and discoveryRouting
Service-to-service calls
Load balancing
Circuit Breakers
Global locks
Leadership election and cluster state
Distributed messaging
Spring CloudSlide16
Spring Cloud
Spring Boot
Spring
Spring Cloud Context
Spring Cloud Commons
Spring Cloud Netfix
Spring Cloud Consul
Spring Cloud Config
Spring Cloud for Amazon Web Services
Spring Cloud Bus
Spring Cloud for Cloud Foundry
Spring Cloud ...Slide17
Parent of Main Application ContextUsed to load properties from external sourcesOut of the box loads properties form Config ServerCan be configured to do anything you wantHandling environment changes
Re-bind
@ConfigurationProperties
Set log levels for
logging.level.*
@RefreshScope
Spring Boot Context
Bootstrap Context
Environment
Main Applicatin Context
Bootstrap
Context
application.yml
application-{profile}.yml
bootstrap.yml
bootstrap-{profile}.yml
External properties
(e.g. Config Server)
Higher precedenceSlide18
HTTP, resource-based API for external configurationJSON/YML/properties resourcesGit backend (default)
Integrates with Spring Security
Spring Cloud Config
Config-first bootstrap
Discovery-first bootstrap
Fail-fast option
Like reading local
application*.yml
family with extra dimention „label”
Config Server
Config Client
/{application}/{profile}/{
label}
${spring.application.name
}
${spring.profiles.active
}
master
spring.cloud.config
.[name|env|label]
/{application
}/{profile}[/{
label
}]
/{
application
}-{profile}.yml
/{
label}/{application}-{profile}.
yml
/{
application}-{profile}.
properties
/{
label}/{application}-{profile}.propertiesSlide19
S
ervice
D
iscovery
L
oad
B
alancing
C
ircuit Breakers
Implementations:Spring Cloud NetflixSpring Cloud ConsuleSpring Cloud Commons
Common AbstractionsSlide20
Enable common patterns with just annotations:Discovery: EurekaCircuit Breaker: HystrixClient Side Load Balancer: RibbonDeclarative REST Client: Feign
Router
and Filter:
Zuul
External
Configuration: Archaius
Spring Cloud NetflixSlide21
Run by @EnableEurekaServer
By default is also a client, so needs a peer
Optional standalone mode
Keep registration in memory
Discovery: Eureka
Enable by
@EnableDiscoveryClient
or
@EnableEurekaClient
Sending heartbeats to Eureka server
Optionally send full health check status
Special virutal URL:
http://users/...
Discovery clients:
Native EurekaClientSpring Cloud DiscoveryClient
Feign clientSpring RestTemplate
Eureka ServerEureka ClientSlide22
Proxy the beans enabling circuit breaker
Enabled by annotation on the method
@HystrixCommand(fallbackMethod=„”)
public Article getArticle(String id) {
// call external system
}
Fallback can be provided
Hystrix metrics stream:
/hystrix.stream
Hystrix Dashboard
Turbine combining hystrix streams
Circuit Breaker: HystrixSlide23
Used by default in @FeignClientRibbon API can be used directlyConfiguring by
<client>.ribbon.listOfServers
Can get
„listOfServers” from Eureka, if available
Client side load balancer: RibbonSlide24
Declarative Web Service ClientCreate interface and annotate itFeign annotations, JAX-RS annotations, Spring MVC (added by Spring Cloud)
@FeignClient(name = "articles-service")
public interface ArticlesClient
{
@RequestMapping(value = "/articles/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Article getArticle(@PathVariable("id") String id);
}
In Spring Cloud uses Eureka, Ribbon and Hystrix
Feign ClientSlide25
DemoSlide26
Registry Server
(Eureka)
Config Server
News Service
Articles Service
Client
Git
YAML files
get properties – default number of articles
find Articles Service
Get article content
Give me news!
Load balanced
Protected with Circuit Breaker
1 class
1 class
5 classes
4 classes
Articles ServiceSlide27
QuestionsSlide28
Thank you
Jacek Bukowski
Consultant Engineering
jacek.bukowski
@globallogic.com
+
48 728 869 133
Github:
https
://
github.com/buczyn/spring-cloud-netflix-demo