Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
AGIM EMRULI, ALAIN SAHLI
MICROSERVICES MIT SPRING CLOUD
AGIM
EMRULI
AGIM.EMRULI@
MIMACOM.COM
ALAIN
SAHLI
ALAIN.SAHLI@
MIMACOM.COM
CLOUD
SERVICE REGISTRY,

CIRCUIT BREAKER, METRICS
CORE
FRAMEWORK SECURITY GROOVY REACTOR
IOEXECUTIONIOFOUNDATION GRAILS
FU...
TOOLBOX
FOR DISTRIBUTED SYSTEMS
DISTRIBUTED SYSTEM DEPLOYMENTS
@GITHUB
175 DEPLOYMENTS / DAY
NETFLIX
SERVICE ORIENTED ARCHITECTURE
SPRING CLOUD
INTRODUCTION
Spring
Cloud
BusConfig Netflix
AWS
Cloud
FoundryCLIConnectors
Starters
Application
CONFIGURATION MANAGEMENT
MONOLITHIC VS. DISTRIBUTED
Application
JNDI
Service
Service
Service
Service
Service
Spring Cloud Config
Spring Cloud
Config Server
GIT
SVN
File
Config Server
@Configuration

@EnableAutoConfiguration

@EnableConfigServer

public class ConfigServerApplication {



pub...
Spring Cloud
Config Server
Application
Spring Cloud
Config Client
Application
Spring Cloud
Config Client
Application
Sprin...
Application
Spring Cloud
Config Client
@SpringBootApplication

public class CustomerApp {



public static void main(Strin...
Spring Cloud Bus
Spring Cloud
Config Server
Application
Application
/bus/refresh
AMQP
PATTERNS
STABILITY
CAPACITY
TRANSPARENCY
SPRING CLOUD
NETFLIX
Hystrix
Feign
Zuul
Eureka
Turbine
Ribbon
Service Registry
Circuit Breaker
Stream Aggregator
Load Bala...
HYSTRIX
CIRCUIT BREAKER
Execute
Command
Queue
Pool
available
Run
Fallback
HYSTRIX
BULKHEADS
Tomcat Thread Pool
Thread-1
Service
Service
Service Service
Thread-2
Thread-3
XThread-4
Thread-5
Thread-...
HYSTRIX
BULKHEADS
Execute
Command
Queue
Pool
available
Execute
Command
Queue
Pool
available
Execute
Command
Queue
Pool
ava...
HYSTRIX EXAMPLE
SERVICE CONSUMER
public class SearchGateway {

@HystrixCommand(fallbackMethod = "fallback")

public List<S...
HYSTRIX
TRANSPARENCY
HYSTRIX DASHBOARD
EXAMPLE
@EnableCircuitBreaker

@EnableHystrixDashboard

public class HystrixApp {



public static void ...
TURBINE
AGGREGATOR
Dashboard
Service
Service
Dashboard
Turbine
Service Service
EUREKA
SERVICE DISCOVERY
Service
Service
Service
Service
X
Service
Service
Service
Service
Eureka
EUREKA REGISTRATION
EXAMPLE
@SpringBootApplication

@EnableDiscoveryClient

public class CustomerApp {



public static vo...
EUREKA REGISTRATION
EXAMPLE
Discovery
Client
Application
Host
Port
URI
RIBBON
LOAD-BALANCER
Service
Service
Eureka
Service
Service
Eureka
ServiceService
Load
Balancer
RIBBON
RESTTEMPLATE INTEGRATION
@Service

public class Service {



@Autowired

@LoadBalanced

RestTemplate restTemplate;
...
ZUUL
EDGE-SERVICE
Service
Eureka
Edge Proxy
Service
Eureka
ServiceService
Load
Balancer
Web
Browser
Web
Browser
ZUUL
REVERSE PROXY SETUP
@EnableAutoConfiguration

@EnableZuulProxy

public class SimpleZuulServerApplication {



public ...
Web Server

Load Balancer
Service
Discovery

Eureka
Customers Stores
Config
Server
Circuit Breaker
Dashboard
Browser
SPRING CLOUD
AMAZON WEBSERVICES
Instance Meta-data
@Component

public class ApplicationInfoBean {



@Value("${ami-id}")

private String amiId;



@Value(...
Amazon RDS
Schema Design
Query construction /
tuning
Availability
Backup & Recovery
Patch Management
Storage Upgrades
Amazon RDS
@EnableRdsInstance(
dbInstanceIdentifier = “test",
password = “secret",
readReplicaSupport = true)
public stati...
RDS Instance Support
@Service

public class JdbcPersonService implements PersonService {



private final JdbcTemplate jdb...
Amazon SQS
HTTP Messaging
Only String payload
No Transactions
Visibility Rules
Message Listeners
@Component

public class SqsController {



@MessageMapping("myQueue")

@SendTo("replyQueue")

private S...
Application
Instance
Application
Instance
Application
Instance
SNS Controllers
@RestController

@RequestMapping("/sns/receive")

public class SnsEndpointController {



@NotificationSub...
Elasticache
Application
Instance
Application
Instance
Application
Instance
Application
Instance
Caching Service
@Service

public class ExpensiveService {



@Cacheable("CacheCluster")

public String calculateExpensiveV...
{
"Resources": {
"ec2instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-6a56b81d",
"InstanceType":...
FRAGEN?
Spring Cloud JUG Switzerland
Spring Cloud JUG Switzerland
Spring Cloud JUG Switzerland
Spring Cloud JUG Switzerland
Spring Cloud JUG Switzerland
Spring Cloud JUG Switzerland
Spring Cloud JUG Switzerland
Upcoming SlideShare
Loading in …5
×

Spring Cloud JUG Switzerland

901 views

Published on

Introduction into the Spring Cloud Framework

Published in: Software
  • Be the first to comment

Spring Cloud JUG Switzerland

  1. 1. AGIM EMRULI, ALAIN SAHLI MICROSERVICES MIT SPRING CLOUD
  2. 2. AGIM EMRULI AGIM.EMRULI@ MIMACOM.COM ALAIN SAHLI ALAIN.SAHLI@ MIMACOM.COM
  3. 3. CLOUD SERVICE REGISTRY,
 CIRCUIT BREAKER, METRICS CORE FRAMEWORK SECURITY GROOVY REACTOR IOEXECUTIONIOFOUNDATION GRAILS 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 IOCOORDINATION
  4. 4. TOOLBOX FOR DISTRIBUTED SYSTEMS
  5. 5. DISTRIBUTED SYSTEM DEPLOYMENTS @GITHUB 175 DEPLOYMENTS / DAY
  6. 6. NETFLIX SERVICE ORIENTED ARCHITECTURE
  7. 7. SPRING CLOUD INTRODUCTION Spring Cloud BusConfig Netflix AWS Cloud FoundryCLIConnectors Starters
  8. 8. Application CONFIGURATION MANAGEMENT MONOLITHIC VS. DISTRIBUTED Application JNDI Service Service Service Service Service
  9. 9. Spring Cloud Config Spring Cloud Config Server GIT SVN File
  10. 10. Config Server @Configuration
 @EnableAutoConfiguration
 @EnableConfigServer
 public class ConfigServerApplication {
 
 public static void main(String[] args) {
 SpringApplication.run(ConfigServerApplication.class, args);
 }
 }
  11. 11. Spring Cloud Config Server Application Spring Cloud Config Client Application Spring Cloud Config Client Application Spring Cloud Config Client
  12. 12. Application Spring Cloud Config Client @SpringBootApplication
 public class CustomerApp {
 
 public static void main(String[] args) {
 SpringApplication.run(CustomerApp.class, args);
 }
 }
 Bootstrap
  13. 13. Spring Cloud Bus Spring Cloud Config Server Application Application /bus/refresh AMQP
  14. 14. PATTERNS STABILITY CAPACITY TRANSPARENCY
  15. 15. SPRING CLOUD NETFLIX Hystrix Feign Zuul Eureka Turbine Ribbon Service Registry Circuit Breaker Stream Aggregator Load Balancer Edge Service HTTP Communication
  16. 16. HYSTRIX CIRCUIT BREAKER Execute Command Queue Pool available Run Fallback
  17. 17. HYSTRIX BULKHEADS Tomcat Thread Pool Thread-1 Service Service Service Service Thread-2 Thread-3 XThread-4 Thread-5 Thread-6 Thread-7 Thread-8
  18. 18. HYSTRIX BULKHEADS Execute Command Queue Pool available Execute Command Queue Pool available Execute Command Queue Pool available
  19. 19. HYSTRIX EXAMPLE SERVICE CONSUMER public class SearchGateway {
 @HystrixCommand(fallbackMethod = "fallback")
 public List<SearchHit> search(String query) {
 return …;
 }
 public List<SearchHit> fallback() {
 return Collections.emptyList();
 }
 }
  20. 20. HYSTRIX TRANSPARENCY
  21. 21. HYSTRIX DASHBOARD EXAMPLE @EnableCircuitBreaker
 @EnableHystrixDashboard
 public class HystrixApp {
 
 public static void main(String[] args) {
 SpringApplication.run(HystrixApp.class, args);
 }
 }
  22. 22. TURBINE AGGREGATOR Dashboard Service Service Dashboard Turbine Service Service
  23. 23. EUREKA SERVICE DISCOVERY Service Service Service Service X Service Service Service Service Eureka
  24. 24. EUREKA REGISTRATION EXAMPLE @SpringBootApplication
 @EnableDiscoveryClient
 public class CustomerApp {
 
 public static void main(String[] args) {
 SpringApplication.run(CustomerApp.class, args);
 }
 
 } spring.application.name=customers
  25. 25. EUREKA REGISTRATION EXAMPLE Discovery Client Application Host Port URI
  26. 26. RIBBON LOAD-BALANCER Service Service Eureka Service Service Eureka ServiceService Load Balancer
  27. 27. RIBBON RESTTEMPLATE INTEGRATION @Service
 public class Service {
 
 @Autowired
 @LoadBalanced
 RestTemplate restTemplate;
 
 public String callService() {
 return restTemplate.getForObject("http://CUSTOMERS/{id}", String.class,"23");
 }
 }
  28. 28. ZUUL EDGE-SERVICE Service Eureka Edge Proxy Service Eureka ServiceService Load Balancer Web Browser Web Browser
  29. 29. ZUUL REVERSE PROXY SETUP @EnableAutoConfiguration
 @EnableZuulProxy
 public class SimpleZuulServerApplication {
 
 public static void main(String[] args) {
 SpringApplication.run(SampleZuulProxyApplication.class, args);
 }
 
 } http://localhost:9090/customers http://localhost:9090/stores
  30. 30. Web Server Load Balancer Service Discovery Eureka Customers Stores Config Server Circuit Breaker Dashboard Browser
  31. 31. SPRING CLOUD AMAZON WEBSERVICES
  32. 32. Instance Meta-data @Component
 public 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;
 }

  33. 33. Amazon RDS Schema Design Query construction / tuning Availability Backup & Recovery Patch Management Storage Upgrades
  34. 34. Amazon RDS @EnableRdsInstance( dbInstanceIdentifier = “test", password = “secret", readReplicaSupport = true) public static class AppConfig {}
  35. 35. RDS Instance Support @Service
 public 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 …”);
 }
 }
  36. 36. Amazon SQS HTTP Messaging Only String payload No Transactions Visibility Rules
  37. 37. Message Listeners @Component
 public class SqsController {
 
 @MessageMapping("myQueue")
 @SendTo("replyQueue")
 private String receiveMessage(MessageToProcess message, 
 @Header(“ApproximateFirstReceiveTimestamp”) String timeStamp) {
 return "someReply";
 }
 }
  38. 38. Application Instance Application Instance Application Instance
  39. 39. 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) {
 }
 }
  40. 40. Elasticache Application Instance Application Instance Application Instance Application Instance
  41. 41. Caching Service @Service
 public class ExpensiveService {
 
 @Cacheable("CacheCluster")
 public String calculateExpensiveValue(String key){
 return …;
 }
 }
  42. 42. { "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", } } }
  43. 43. FRAGEN?

×