50
AGIM EMRULI - MIMACOM SPRING CLOUD

Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

AGIM EMRULI - MIMACOM

SPRING CLOUD

Page 2: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

AGIM EMRULI@AEMRULI AEMRULI

AGIM.EMRULI@ MIMACOM.COM

Page 3: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

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

Page 4: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

TOOLBOXFOR DISTRIBUTED SYSTEMS

Page 5: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

DISTRIBUTED SYSTEM DEPLOYMENTS@GITHUB

175 DEPLOYMENTS / DAY

Page 6: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

NETFLIXSERVICE ORIENTED ARCHITECTURE

Page 7: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

SPRING CLOUDINTRODUCTION

Spring Cloud

BusConfig Netflix

AWS

Cloud FoundryCLIConnectors

Starters

Page 8: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

CONFIGURATION MANAGEMENTMONOLITHIC VS. DISTRIBUTED

Application

JNDI

Application

Service

ServiceService

Service

Service

Page 9: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Spring Cloud Config

Spring Cloud Config Server

GIT

SVN

File

Page 10: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Config Server

@Configuration@EnableAutoConfiguration@EnableConfigServerpublic class ConfigServerApplication { public static void main(String[] args) { SpringApplication.run(ConfigServerApplication.class, args); } }

Page 11: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Spring Cloud Config Server

Application

Spring Cloud Config Client

Application

Spring Cloud Config Client

Application

Spring Cloud Config Client

Page 12: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Application

Spring Cloud Config Client

@SpringBootApplicationpublic class CustomerApp { public static void main(String[] args) { SpringApplication.run(CustomerApp.class, args); } }

Bootstrap

Page 13: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers
Page 14: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Spring Cloud Bus 02

Spring Cloud Config Server

Application

Application

/bus/refresh

AMQP

Page 15: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers
Page 16: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers
Page 17: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers
Page 18: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

PATTERNSSTABILITY CAPACITY TRANSPARENCY

Page 19: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

SPRING CLOUDNETFLIX

Hystrix

Feign

Zuul

Eureka

Turbine

Ribbon

Service Registry

Circuit Breaker

Stream Aggregator

Load Balancer

Edge Service

HTTP Communication

Page 20: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

HYSTRIXCIRCUIT BREAKER

Execute Command

QueuePool

available

Run

Fallback

Page 21: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

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

Page 22: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

HYSTRIXBULKHEADS

Execute Command

QueuePool

available

Execute Command

QueuePool

available

Execute Command

QueuePool

available

Page 23: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

HYSTRIX EXAMPLESERVICE CONSUMER

class SearchGateway { @HystrixCommand(fallbackMethod = "fallback") public List<SearchHit> search(String query) { return …; } public List<SearchHit> fallback() { return Collections.emptyList(); } }

Page 24: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

HYSTRIXTRANSPARENCY

Page 25: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

HYSTRIX DASHBOARDEXAMPLE

@EnableCircuitBreaker@EnableHystrixDashboardpublic class HystrixApp { public static void main(String[] args) { SpringApplication.run(HystrixApp.class, args); }}

Page 26: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

TURBINEAGGREGATOR

Dashboard

Service

Service

Dashboard

Service

Service Service

Page 27: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

EUREKASERVICE DISCOVERY

Service

Service

Service

Service

XService

Service

Service

Service

Eu

reka

Page 28: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

EUREKA REGISTRATIONEXAMPLE

@SpringBootApplication@EnableDiscoveryClientpublic class CustomerApp { public static void main(String[] args) { SpringApplication.run(CustomerApp.class, args); } }

spring.application.name=customers

Page 29: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

EUREKA REGISTRATIONEXAMPLE

Discovery Client

Application

HostPortURI

Page 30: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

RIBBONLOAD-BALANCER

Service

Service

Eu

reka

Service

Service

Eu

reka

ServiceService

Load Balacner

Page 31: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

@Servicepublic class Service { @Autowired @LoadBalanced RestTemplate restTemplate; public String callService() { return restTemplate.getForObject("http://CUSTOMERS/{id}", String.class,"23"); }}

Page 32: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

ZUULEDGE-SERVICE

Service

Eu

reka

Edge Proxy

Service

Eu

reka

ServiceService

Load Balacner

Web Browser

Web Browser

Page 33: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

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

Page 34: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Web ServerLoad Balancer

Service Discovery

EurekaCustomers Stores

Config Server

Circuit Breaker Dashboard

Browser

Page 35: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers
Page 36: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

SPRING CLOUDAMAZON WEBSERVICES

Page 37: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

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; }

Page 38: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Amazon RDS

Schema Design

Query construction / tuning

Availability

Backup & Recovery

Patch Management

Storage Upgrades

Page 39: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Amazon RDS

@EnableRdsInstance( dbInstanceIdentifier = “test", password = “secret", readReplicaSupport = true) public static class AppConfig {}

Page 40: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

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 …”); }}

Page 41: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Amazon SQS

HTTP Messaging

Only String payload

No Transactions

Visibility Rules

Page 42: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Message Listeners

@Componentpublic class SqsController { @MessageMapping("myQueue") @SendTo("replyQueue") private String receiveMessage(MessageToProcess message, @Header(“ApproximateFirstReceiveTimestamp”) String timeStamp) { return "someReply"; }}

Page 43: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Application Instance

Application Instance

Application Instance

Page 44: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

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) { }}

Page 45: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Elasticache

Application Instance

Application Instance

Application Instance

Application Instance

Page 46: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Caching Service

@Servicepublic class ExpensiveService { @Cacheable("CacheCluster") public String calculateExpensiveValue(String key){ return …; }}

Page 47: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers
Page 48: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

{ "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", } } }

Page 49: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

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

Page 50: Spring Cloud - Meetupfiles.meetup.com/4939632/Spring_Cloud.pdf · grails full stack, web xd streams, taps, jobs boot bootable, minimal, ops-ready batch jobs, steps, readers, writers

Agim Emruli - mimacom

@aemruli