View
4
Download
0
Category
Preview:
Citation preview
AGIM EMRULI - MIMACOM
SPRING CLOUD
CLOUD
SERVICE REGISTRY,CIRCUIT BREAKER, METRICS
CORE
FRAMEWORK SECURITY GROOVY REACTOR
IO E
XECU
TION
IO F
OUND
ATIO
NGRAILS
FULL STACK, WEB
XD
STREAMS, TAPS, JOBS
BOOT
BOOTABLE, MINIMAL, OPS-READY
BATCH
JOBS, STEPS,READERS, WRITERS
DATA
RELATIONAL DATA NON-RELATIONAL DATA
BIG DATA
INGESTION, EXPORT,ORCHESTRATION, HADOOP
WEB
CONTROLLERS, REST, WEBSOCKET
INTEGRATION
CHANNELS, FILTERS,ADAPTERS, TRANSFORMERS
IO C
OORD
INAT
ION
TOOLBOXFOR DISTRIBUTED SYSTEMS
DISTRIBUTED SYSTEM DEPLOYMENTS@GITHUB
175 DEPLOYMENTS / DAY
NETFLIXSERVICE ORIENTED ARCHITECTURE
SPRING CLOUDINTRODUCTION
Spring Cloud
BusConfig Netflix
AWS
Cloud FoundryCLIConnectors
Starters
CONFIGURATION MANAGEMENTMONOLITHIC VS. DISTRIBUTED
Application
JNDI
Application
Service
ServiceService
Service
Service
Spring Cloud Config
Spring Cloud Config Server
GIT
SVN
File
Config Server
@Configuration@EnableAutoConfiguration@EnableConfigServerpublic class ConfigServerApplication { public static void main(String[] args) { SpringApplication.run(ConfigServerApplication.class, args); } }
Spring Cloud Config Server
Application
Spring Cloud Config Client
Application
Spring Cloud Config Client
Application
Spring Cloud Config Client
Application
Spring Cloud Config Client
@SpringBootApplicationpublic class CustomerApp { public static void main(String[] args) { SpringApplication.run(CustomerApp.class, args); } }
Bootstrap
Spring Cloud Bus 02
Spring Cloud Config Server
Application
Application
/bus/refresh
AMQP
PATTERNSSTABILITY CAPACITY TRANSPARENCY
SPRING CLOUDNETFLIX
Hystrix
Feign
Zuul
Eureka
Turbine
Ribbon
Service Registry
Circuit Breaker
Stream Aggregator
Load Balancer
Edge Service
HTTP Communication
HYSTRIXCIRCUIT BREAKER
Execute Command
QueuePool
available
Run
Fallback
HYSTRIXBULKHEADS
Tomcat Thread Pool
Th
read
- 1
Service
Service
Service Service
Th
read
- 2
Th
read
- 3
XT
hre
ad -
4
Th
read
- 5
Th
read
- 6
Th
read
- 7
Th
read
- 8
HYSTRIXBULKHEADS
Execute Command
QueuePool
available
Execute Command
QueuePool
available
Execute Command
QueuePool
available
HYSTRIX EXAMPLESERVICE CONSUMER
class SearchGateway { @HystrixCommand(fallbackMethod = "fallback") public List<SearchHit> search(String query) { return …; } public List<SearchHit> fallback() { return Collections.emptyList(); } }
HYSTRIXTRANSPARENCY
HYSTRIX DASHBOARDEXAMPLE
@EnableCircuitBreaker@EnableHystrixDashboardpublic class HystrixApp { public static void main(String[] args) { SpringApplication.run(HystrixApp.class, args); }}
TURBINEAGGREGATOR
Dashboard
Service
Service
Dashboard
Service
Service Service
EUREKASERVICE DISCOVERY
Service
Service
Service
Service
XService
Service
Service
Service
Eu
reka
EUREKA REGISTRATIONEXAMPLE
@SpringBootApplication@EnableDiscoveryClientpublic class CustomerApp { public static void main(String[] args) { SpringApplication.run(CustomerApp.class, args); } }
spring.application.name=customers
EUREKA REGISTRATIONEXAMPLE
Discovery Client
Application
HostPortURI
RIBBONLOAD-BALANCER
Service
Service
Eu
reka
Service
Service
Eu
reka
ServiceService
Load Balacner
@Servicepublic class Service { @Autowired @LoadBalanced RestTemplate restTemplate; public String callService() { return restTemplate.getForObject("http://CUSTOMERS/{id}", String.class,"23"); }}
ZUULEDGE-SERVICE
Service
Eu
reka
Edge Proxy
Service
Eu
reka
ServiceService
Load Balacner
Web Browser
Web Browser
ZUULREVERSE PROXY SETUP
@EnableAutoConfiguration@EnableZuulProxypublic class SimpleZuulServerApplication { public static void main(String[] args) { SpringApplication.run(SampleZuulProxyApplication.class, args); } }
http://localhost:9090/customers http://localhost:9090/stores
Web ServerLoad Balancer
Service Discovery
EurekaCustomers Stores
Config Server
Circuit Breaker Dashboard
Browser
SPRING CLOUDAMAZON WEBSERVICES
Instance Meta-data@Componentpublic class ApplicationInfoBean { @Value("${ami-id}") private String amiId; @Value("${hostname}") private String hostname; @Value("${instance-type}") private String instanceType; @Value("${services/domain}") private String serviceDomain; }
Amazon RDS
Schema Design
Query construction / tuning
Availability
Backup & Recovery
Patch Management
Storage Upgrades
Amazon RDS
@EnableRdsInstance( dbInstanceIdentifier = “test", password = “secret", readReplicaSupport = true) public static class AppConfig {}
RDS Instance Support@Servicepublic class JdbcPersonService implements PersonService { private final JdbcTemplate jdbcTemplate; @Autowired public JdbcPersonService(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); } @Override @Transactional(readOnly = true) public List<Person> all() { return this.jdbcTemplate.query("SELECT * FROM Person”, … ); } @Override @Transactional public void store(Person person) { this.jdbcTemplate.update("INSERT INTO Person …”); }}
Amazon SQS
HTTP Messaging
Only String payload
No Transactions
Visibility Rules
Message Listeners
@Componentpublic class SqsController { @MessageMapping("myQueue") @SendTo("replyQueue") private String receiveMessage(MessageToProcess message, @Header(“ApproximateFirstReceiveTimestamp”) String timeStamp) { return "someReply"; }}
Application Instance
Application Instance
Application Instance
SNS Controllers@RestController@RequestMapping("/sns/receive") public class SnsEndpointController { @NotificationSubscriptionMapping public void confirmSubscription( NotificationStatus notificationStatus) { notificationStatus.confirmSubscription(); } @NotificationMessageMapping public void receiveNotification( @NotificationMessage String message, @NotificationSubject String subject) { }}
Elasticache
Application Instance
Application Instance
Application Instance
Application Instance
Caching Service
@Servicepublic class ExpensiveService { @Cacheable("CacheCluster") public String calculateExpensiveValue(String key){ return …; }}
{ "Resources": { "ec2instance": { "Type": "AWS::EC2::Instance", "Properties": { "ImageId": "ami-6a56b81d", "InstanceType": "m1.small", } }, "database": { "Type": "AWS::RDS::DBInstance", "Properties": { "AllocatedStorage": "5", "DBInstanceClass": "db.m1.small", "DBName": "test", } } }
Other talks
Talk Speaker Time
From Zero To Hero with Spring Boot Stéphane Nicoll 11:00
Modern Enterprise Java Architectures with Spring 4.1 Jürgen Höller 12:00
Anatomy of Microservice Landscapes Michael Plöd 17:00
Master Spring Boot auto-configuration Stéphane Nicoll 11:00
Cloud Patterns on AWS Agim Emruli 16:00
Agim Emruli - mimacom
@aemruli
Recommended