2. Mikrodienste: Patrone and Anti-Patrone
Argitektuele Patrone and Anti-patrone om in ag te
neem met die onwerp van Mikrodienste en die
gebruik van Spring Boot en Spring Cloud.
Corneil du Plessis
3. Microservices: Patterns and Anti-Patterns
Architectural Patterns and Anti-patterns to
consider with Microservices,
and using Spring Boot and Spring Cloud to build
Microservices
Corneil du Plessis
4. Introduction
● Programmer since 1985
● Smallest to very large systems.
● Cobol, Pascal, Algol, C/C++, Java, Scala, Groovy and
other JVM languages.
● Scientific instrumentation, Sports event management,
Mining, Banking, Treasury and Insurance.
● Software Architect (coding included)
12. Pattern: Immutable service
● Created by build process.
● Managed in Binary repository
● Deployed / Launched as a unit
● Simple externalised configuration
20. Service calls
● Synchronous
– JSON or XML over Rest / HTTP
– SOAP over HTTP
● Asynchronous
– SOAP over Message Queue
– XML or JSON over Message Queue
23. Size of Microservices
● Questions
– How big is a Microservice?
– What about data?
● Best practice
– Start with a single application
– Only split when it will benefit runtime or development.
– Don't split prematurely
24. Microservices with Spring
● What is Spring?
– The Spring Framework is aimed at improving developer
productivity by providing best-practice patterns for
implementing Dependency Injection, Transaction
Management, Data-Access Messaging, Aspect-
Oriented-Programming and more...
● Projects that support Microservices
– Spring Boot
– Spring Cloud
25. Spring Boot
● Opinionated auto configuration
● Simple configuration
● Single package
● A long list of starters
26. Spring Cloud
● Abstraction of many cloud native tools / services
● Distributed/versioned configuration
● Service registration and discovery
● Routing
● Service-to-service calls
● Load balancing
● Circuit Breakers
● Global locks
● Leadership election and cluster state
● Distributed messaging
27. Spring Cloud Projects
● Spring Cloud Config
– Centralised config server backed by git
● Spring Cloud Netflix
– Netflix OSS projects
– Eureka, Hystrix, Zuul, Archais
● Spring Cloud Bus
– State and Configuration changes over AMQP
28. Spring Cloud Projects
● Spring Cloud for Cloud Foundry
– Cloud Foundry
– Service Discover
– Security
– Service Broker Foundation
● Spring Cloud Cluster
– Leadership election and common stateful patterns with
an abstraction and implementation for Zookeeper,
Redis, Hazelcast, Consul
29. Spring Cloud Projects
● Spring Cloud Consul
– Service Discovery
– Configuration Management
● Spring Cloud Security
– OAuth2
– Common Patterns for SSO
– Token Relay and Token Exchange
30. Spring Cloud Projects
● Spring Cloud Contract
– Consumer driven contracts
– Contract Verification
– Contract Definition Language (DSL)
– Stubs and Tests
● Spring Cloud Sleuth
– Distributed Tracing
– Zipkin, HTrace
– Log based like ELK
31. Spring Cloud Projects
● Spring Cloud Data Flow
– Redesign of Spring XD
– Orchestrate across Cloud Foundry, Yarn, Mesos,
Kubernetes
– Stream and Batch
– Develop using DSL, Shell, REST APIs, Dashboard or
Flo
– Manage and scale without interruption
32. Spring Cloud Projects
● Spring Cloud Stream
– Messaging with Kafka, Redis or Rabbit
– Binder Abstraction
– Persistent Publish and Subscribe
– Consumer Groups
– Durability
33. Spring Cloud Projects
● Spring Cloud Stream Modules
– Spring Boot based Spring Integration applications
– Compose with Spring Data Flow
– Source – file, ftp, http, jdbc, jms, rabbit and more
– Sink – file, ftp, cassandra, redis, websocket, hdfs
– Processor – groovy-transform, groovy-filter, httpclient,
splitter, scriptable-transform
– Task – timestamp
34. Spring Cloud Projects
● Spring Cloud Task
– Spring Boot Application as a Task in Spring Data Flow
– Spring Cloud Task Starters provide a base and samples
show how to start a Spark Application locally or in a
cluster.
35. Spring Cloud Projects
● Spring Cloud Zookeeper
– Service Discovery and Configuration Management
– Service Discovery: instances can be registered with
Zookeeper and clients can discover the instances using
Spring-managed beans
– Supports Ribbon, the client side load-balancer via Spring
Cloud Netflix
– Supports Zuul, a dynamic router and filter via Spring Cloud
Netflix
– Distributed Configuration: using Zookeeper as a data store
36. Spring Cloud Projects
● Spring Cloud for Amazon Web Services
– Spring Messaging API implementation for SQS.
– Spring Cache API implementation for ElastiCache.
– Annotation-based mapping of SNS endpoints (HTTP).
– Access the resources by their logical name defined in a
CloudFormation stack.
– Automatic JDBC DataSource creation based on the logical
name of an RDS instance.
– Ant-style path matching ResourceLoader for S3 buckets.
37. Spring Cloud Projects
● Spring Cloud Connectors
– Spring XML and Java Configuration to bind to services and resources
– Extensible Connectors for various Cloud Platforms
– Cloud Foundry and Heroku in the box
– Community projects:
● Pivotal Cloud Fountry
● IBM Bluemix
● SAP HANA Cloud Platform
● Amazon S3
● Pivotal Gemfire
● Spring Cloud CLI
– Spring Boot CLI plugin for Spring Cloud projects
– Build quick projects with Groovy for Spring Cloud