Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Building Cloud Native Architectures with
Spring
Kenny Bas...
Kenny Bastani
@kennybastani
Spring Developer Advocate
Agenda
Agenda
1 Microservices & Cloud Native
2 Reference Architecture
3 Spring Boot
4 Spring Cloud
5 Dealing with Legacy
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Microservices
How did we get there?
4
We started with the monolith…
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Cultural problems with monoliths
6
Slows our velocity get...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Operational problems with monoliths
7
Coordinated release...
We then moved towards SOA…
@kennybastani
We have now arrived at microservices…
Each team provisions self-service infrastructure, like a database, and...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Online Store Example
Cloud native application as microser...
@kennybastani
Open Source Example
http://online-store-web.cfapps.io
https://github.com/kbastani/spring-cloud-event-sourcing-example
Demo...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Eventual consistency
Handling the guarantees of an eventu...
Eventual consistency
Microservice architectures provide no guarantees about the correctness
of your data
So how can we gua...
Transaction logs
Event Sourcing
Aggregates can be used to generate the consistent state of any object
It provides an audit trail that can b...
Event Types
Event Log
Event logs are transaction logs
Use event sourcing in your microservices to ensure consistency of your
distributed system
...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
The Cloud Native Stack
What are the components of a cloud...
What is a cloud-native application?
The cloud provides resources
The platform provides services
The application provides v...
Platform
Services
What is a cloud service?
The platform provides services
The developer provisions services
The application uses services
Microservices != Cloud Native
Microservices are an architectural practice
Cloud native is a style of application developme...
Monolith to Microservice
Splitting the Monolith: User Service Migration
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Spring Boot
A JVM micro-framework for building microservi...
What is Spring Boot?
@kennybastani
spring boot
Spring Initializr for boostraping your applications
supports rapid development of
production-rea...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Cloud Native Platforms
Shipping applications in container...
@kennybastani
Application Server Deployment: Monolith
Load balancing requires provisioning
of new VMs and app server
insta...
@kennybastani
Linux Container Deployment: Microservices
Development team drives the
application runtime of a container
Con...
@kennybastani
Microservices: Container Deployment
Each microservice can be containerized with their application dependenci...
@kennybastani
Container scheduling and auto-scaling
Minutes to provision and start a VM, but seconds to schedule and start...
@kennybastani
Distributed Applications
Each microservice will likely need to communicate with other containers
Service dis...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Spring Cloud
A toolset designed for building distributed
...
@kennybastani
What is Spring Cloud?
Spring Cloud provides a way to turn Spring Boot microservices into distributed applica...
@kennybastani
spring cloud
Apache Zookeeper
these logos are all trademark/copyright their respective owners (T-B, L-R): 

...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Spring Cloud Demos
Applying the patterns of cloud-native ...
@kennybastani
Spring Cloud: Cloud Native Patterns
Service Discovery
API Gateway
Config Server
Circuit Breakers
Distributed...
Service Discovery
Allows applications to find each other in an environment
An essential component when using dynamic conta...
Discovery Service
Service Registry
@kennybastani
Client-side Load Balancing
• Create discovery service
• Register user service
• Register user client
• Scale...
@kennybastani
Client-side Load Balancing
• Create discovery service
• Register user service
• Register user client
• Scale...
@kennybastani
Client-side Load Balancing
• Create discovery service
• Register user service
• Register user client
• Scale...
@kennybastani
Client-side Load Balancing
• Create discovery service
• Register user service
• Register user client
• Scale...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Config Server
Centralizing config management for microser...
Config Server
Allows applications to source configuration from central service
Application configuration can be changed wi...
Configuration Server
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
API Gateway
Building edge services that route requests to...
Edge Service
API gateway pattern using Spring Cloud Netflix Zuul starter project
Embeds relative routes from other service...
Benefits
Provides a secure gateway to compose together REST APIs
exposed by backend microservices
Front-end developers can...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Distributed Tracing
Tracing the Online Store
66
Spring Cloud Sleuth
Spring Cloud Sleuth is a project that adds distributed tracing
capabilities to your distributed Spring...
Zipkin Dashboard
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Strangling Legacy with Microservices
How do I build micro...
Going Cloud Native
Legacy migration challenges

“How do I change the engine of the aircraft while it’s still in flight?”
A...
Problems with lift-and-shift
Brings your tech debt into the cloud
Rolling maintenance windows until migration is complete
Strangler Pattern
“Gradually create a new system around the edges
of the old, letting it grow slowly over several years
un...
Strangler vines—seed in the upper branches of a fig tree and gradually work their
way down to the soil—strangling and even...
Strangling legacy using microservices
How can we take advantage of building microservices that also
strangle data from the...
The problem with data
The most common pain point that companies experience when
building microservices is handling domain ...
Fetching data from the legacy system
Microservices can reach into the legacy system and fetch data
in the same way that fr...
Extending Domain Data
Agile benefits of extending domain data
We gain the benefit of agility in microservices by extending base
domain objects r...
Legacy Indirection Layer
Advantages
The legacy system does not need to be altered to support the
development of new microservices
New features can ...
Disadvantages
Scalability may be a concern in the case that the base legacy
service is not cloud-native
Availability will ...
Point-to-point Connections
Point-to-point Connections
If your architecture has brittle point-to-point connections, code
changes may be required to cr...
Centralized ESB
ESB Indirection Layer
Data Acquisition
We can use the Legacy Edge service to adapt responses from
microservices into the native formats expected...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Reference application
Open source example of strangling l...
Let’s talk about theory and practice
The first law of microservices.
It depends.
In the end..
Do what makes sense for your architecture
Worry deeply about who cleans up after you
Building software is mor...
Full open source examples on my blog
http://www.kennybastani.com
Wrapping up…
Cloud native applications
“If you have to implement the same functionality in each
application, it should instead be provi...
The two road blocks of cloud native
Legacy culture
Legacy culture
Before you can even begin to address the handling of legacy in a
new microservice architecture, you’ll need...
Legacy applications
This is what dropping a legacy application in a Docker
container and calling it a microservice looks like..
Legacy applications
Not all legacy needs to be destroyed right away
Make sure to take an iterative approach to go cloud-na...
© 2016 Pivotal Software, Inc. All rights reserved.
@kennybastani
Thank you.
Reach out if you have any questions!
105
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Building Cloud Native Architectures with Spring
Nächste SlideShare
Wird geladen in …5
×

Building Cloud Native Architectures with Spring

7.324 Aufrufe

Veröffentlicht am

Cloud-native architectures are an emerging practice of software development and delivery. This deck was presented at the Pivotal Cloud Native roadshow and teaches developers how to build modern cloud-native applications using the popular JVM-based application framework: Spring Boot. You'll be provided with a walk through from the monolith application architecture into the more modern microservices architecture. Two open source reference architectures are introduced for building cloud-native microservices. Learn the basics of cloud native platforms and also the approaches for integrating and strangling legacy systems.

https://pivotal.io/event/pivotal-cloud-native-roadshow

Veröffentlicht in: Software
  • Als Erste(r) kommentieren

Building Cloud Native Architectures with Spring

  1. 1. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Building Cloud Native Architectures with Spring Kenny Bastani Spring Developer Advocate 
 Pivotal Cloud Native Roadshow 2016 1
  2. 2. Kenny Bastani @kennybastani Spring Developer Advocate
  3. 3. Agenda Agenda 1 Microservices & Cloud Native 2 Reference Architecture 3 Spring Boot 4 Spring Cloud 5 Dealing with Legacy
  4. 4. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Microservices How did we get there? 4
  5. 5. We started with the monolith…
  6. 6. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Cultural problems with monoliths 6 Slows our velocity getting into production It takes too long to ramp up new engineers The code base is just too large for anyone one person to fully comprehend Centralized authority and change management slows progress (DBA, Ops)
  7. 7. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Operational problems with monoliths 7 Coordinated releases batch many changes together from different teams Operations drives the runtime environment of applications Operators take on all operational responsibility (including VM upgrades) Deploy everything at once or nothing at all
  8. 8. We then moved towards SOA…
  9. 9. @kennybastani We have now arrived at microservices… Each team provisions self-service infrastructure, like a database, and builds a single application Centralized resources are provided as backing services that are shared for data consistency, caching
  10. 10. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Online Store Example Cloud native application as microservices 10
  11. 11. @kennybastani
  12. 12. Open Source Example http://online-store-web.cfapps.io https://github.com/kbastani/spring-cloud-event-sourcing-example Demo Username: user Password: password
  13. 13. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Eventual consistency Handling the guarantees of an eventually consistent microservices architecture 18
  14. 14. Eventual consistency Microservice architectures provide no guarantees about the correctness of your data So how can we guarantee high availability while also guaranteeing data consistency?
  15. 15. Transaction logs
  16. 16. Event Sourcing Aggregates can be used to generate the consistent state of any object It provides an audit trail that can be replayed to generate the state of an object from any point in time It provides the many inputs necessary for analyzing data using event stream processing It enables the use of compensating transactions to rollback events leading to an inconsistent application state It also avoids complex synchronization between microservices, paving the way for asynchronous non-blocking operations between microservices
  17. 17. Event Types
  18. 18. Event Log
  19. 19. Event logs are transaction logs Use event sourcing in your microservices to ensure consistency of your distributed system Don’t store state with microservices, store events Use event stream processing to observe the active usage of your cloud native application in real-time
  20. 20. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani The Cloud Native Stack What are the components of a cloud-native architecture? 25
  21. 21. What is a cloud-native application? The cloud provides resources The platform provides services The application provides value
  22. 22. Platform Services
  23. 23. What is a cloud service? The platform provides services The developer provisions services The application uses services
  24. 24. Microservices != Cloud Native Microservices are an architectural practice Cloud native is a style of application development Monoliths can equally be cloud native apps
  25. 25. Monolith to Microservice
  26. 26. Splitting the Monolith: User Service Migration
  27. 27. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Spring Boot A JVM micro-framework for building microservices 33
  28. 28. What is Spring Boot?
  29. 29. @kennybastani spring boot Spring Initializr for boostraping your applications supports rapid development of production-ready applications and services
  30. 30. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Cloud Native Platforms Shipping applications in containers instead of shared application servers 36
  31. 31. @kennybastani Application Server Deployment: Monolith Load balancing requires provisioning of new VMs and app server installations Poor resource isolation; memory leaks can cause other applications to become unavailable Runtime environment is driven by the operator Virtual Machine
 App Linux Kernel App App Hardware Infrastructure
  32. 32. @kennybastani Linux Container Deployment: Microservices Development team drives the application runtime of a container Containers are resource isolated, allowing efficient scheduling onto a grid of VMs Containers take seconds to start, VMs take minutesVirtual Machine
 Container Linux Kernel App App App App Container App App App App Container App App App App Hardware Infrastructure
  33. 33. @kennybastani Microservices: Container Deployment Each microservice can be containerized with their application dependencies Containers get scheduled on virtual machines with an allotted resource policy
  34. 34. @kennybastani Container scheduling and auto-scaling Minutes to provision and start a VM, but seconds to schedule and start a container Auto-scaling becomes a feature of the cloud platform by scheduling on pool of VMs
  35. 35. @kennybastani Distributed Applications Each microservice will likely need to communicate with other containers Service discovery automates how distributed apps find service dependencies
  36. 36. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Spring Cloud A toolset designed for building distributed systems 42
  37. 37. @kennybastani What is Spring Cloud? Spring Cloud provides a way to turn Spring Boot microservices into distributed applications
  38. 38. @kennybastani spring cloud Apache Zookeeper these logos are all trademark/copyright their respective owners (T-B, L-R): 
 
 Netflix, amazon.com, Apache Software Foundation, Cloud Foundry, Hashicorp they are ALL great organizations and we love their open-source and their APIs!! *
  39. 39. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Spring Cloud Demos Applying the patterns of cloud-native architectures with Spring Boot and Spring Cloud 45
  40. 40. @kennybastani Spring Cloud: Cloud Native Patterns Service Discovery API Gateway Config Server Circuit Breakers Distributed Tracing
  41. 41. Service Discovery Allows applications to find each other in an environment An essential component when using dynamic container scheduling Each application handles its own routing Developers only need the name of a dependency, not the URL A service registry is distributed to all subscriber applications
  42. 42. Discovery Service
  43. 43. Service Registry
  44. 44. @kennybastani Client-side Load Balancing • Create discovery service • Register user service • Register user client • Scale user service • Reverse proxy from user client to user service User
 Service User
 Service User
 Client
  45. 45. @kennybastani Client-side Load Balancing • Create discovery service • Register user service • Register user client • Scale user service • Reverse proxy from user client to user service User
 Service User
 Service User
 Client
  46. 46. @kennybastani Client-side Load Balancing • Create discovery service • Register user service • Register user client • Scale user service • Reverse proxy from user client to user service User
 Service User
 Service User
 Client
  47. 47. @kennybastani Client-side Load Balancing • Create discovery service • Register user service • Register user client • Scale user service • Reverse proxy from user client to user service User
 Service User
 Service User
 Client
  48. 48. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Config Server Centralizing config management for microservices with Spring Cloud Config Server 56
  49. 49. Config Server Allows applications to source configuration from central service Application configuration can be changed without deployment Cascading configuration files for all apps and individual apps Uses Git repository as file system, providing audit log of changes Add Spring Cloud Bus to automate config refresh for many instances
  50. 50. Configuration Server
  51. 51. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani API Gateway Building edge services that route requests to backend microservices 60
  52. 52. Edge Service API gateway pattern using Spring Cloud Netflix Zuul starter project Embeds relative routes from other services registered with Eureka Automatic method for reverse proxying to other services Routes are displayed at /routes of the Spring Boot app
  53. 53. Benefits Provides a secure gateway to compose together REST APIs exposed by backend microservices Front-end developers can integrate with a single API over HTTP to communicate with potentially many microservices Front-end applications can further embed an edge service to avoid the need to manage CORS and authentication concerns
  54. 54. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Distributed Tracing Tracing the Online Store 66
  55. 55. Spring Cloud Sleuth Spring Cloud Sleuth is a project that adds distributed tracing capabilities to your distributed Spring Boot applications https://cloud.spring.io/spring-cloud-sleuth/ http://zipkin.io/
  56. 56. Zipkin Dashboard
  57. 57. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Strangling Legacy with Microservices How do I build microservices that are cloud-native without doing a big bang refactor? 70
  58. 58. Going Cloud Native Legacy migration challenges “How do I change the engine of the aircraft while it’s still in flight?” Approaches Lift-and-shift Big bang refactor and migration Iterative legacy modernization
  59. 59. Problems with lift-and-shift Brings your tech debt into the cloud Rolling maintenance windows until migration is complete
  60. 60. Strangler Pattern “Gradually create a new system around the edges of the old, letting it grow slowly over several years until the old system is strangled.” — Martin Fowler
  61. 61. Strangler vines—seed in the upper branches of a fig tree and gradually work their way down to the soil—strangling and eventually and killing the tree
  62. 62. Strangling legacy using microservices How can we take advantage of building microservices that also strangle data from the edge of legacy systems?
  63. 63. The problem with data The most common pain point that companies experience when building microservices is handling domain data Your domain data is likely going to be trapped inside a large shared database—probably being of the Oracle or IBM variety Because of this, your new microservices will be dependent on retrieving data from a large shared database
  64. 64. Fetching data from the legacy system Microservices can reach into the legacy system and fetch data in the same way that front-end applications do While this isn’t a good long-term strategy, it can be an intermediate step in gaining control over the legacy backend
  65. 65. Extending Domain Data
  66. 66. Agile benefits of extending domain data We gain the benefit of agility in microservices by extending base domain objects retrieved from a legacy system New feature changes are moved out to the new microservice, using an indirection layer to maintain backward compatibility with the legacy system
  67. 67. Legacy Indirection Layer
  68. 68. Advantages The legacy system does not need to be altered to support the development of new microservices New features can be deployed independently without being tightly coupled to the legacy system It ensures that any existing calls to a legacy web service are unaltered for other apps
  69. 69. Disadvantages Scalability may be a concern in the case that the base legacy service is not cloud-native Availability will be impacted if the base legacy service’s shared database suffers an outage The dependency on the legacy system’s shared database is increased, making it harder to decompose
  70. 70. Point-to-point Connections
  71. 71. Point-to-point Connections If your architecture has brittle point-to-point connections, code changes may be required to create a legacy indirection layer If you’re building microservices on top of an SOA and are using an ESB, an indirection layer already exists
  72. 72. Centralized ESB
  73. 73. ESB Indirection Layer
  74. 74. Data Acquisition We can use the Legacy Edge service to adapt responses from microservices into the native formats expected by legacy applications We can also acquire data from the legacy system and migrate the system of record to a microservice, without refactoring the current database
  75. 75. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Reference application Open source example of strangling legacy 88
  76. 76. Let’s talk about theory and practice
  77. 77. The first law of microservices. It depends.
  78. 78. In the end.. Do what makes sense for your architecture Worry deeply about who cleans up after you Building software is more about people than it is tools
  79. 79. Full open source examples on my blog http://www.kennybastani.com
  80. 80. Wrapping up…
  81. 81. Cloud native applications “If you have to implement the same functionality in each application, it should instead be provided as a service using the platform” – Matt Curry @ Allstate Do this well, and the only thing you’ll be left with is the valuable business logic in your applications
  82. 82. The two road blocks of cloud native
  83. 83. Legacy culture
  84. 84. Legacy culture Before you can even begin to address the handling of legacy in a new microservice architecture, you’ll need to address a legacy culture Some developers may believe a piece of legacy code is beautiful, and has done its job without change for many years Handling the culture shift is a delicate matter. Get people on board before imposing changes
  85. 85. Legacy applications
  86. 86. This is what dropping a legacy application in a Docker container and calling it a microservice looks like..
  87. 87. Legacy applications Not all legacy needs to be destroyed right away Make sure to take an iterative approach to go cloud-native that promises backwards compatibility with legacy applications The goal is to lessen the impact to users over time before making a decision to phase out legacy applications and infrastructure Developers dream of strangling legacy, but it likely still generates revenue for the business
  88. 88. © 2016 Pivotal Software, Inc. All rights reserved. @kennybastani Thank you. Reach out if you have any questions! 105

×