back your app with mysql and redis on cloud foundry
TRANSCRIPT
Unless otherwise indicated, these slides are © 2016 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Back your App with MySQL & Redis, the Cloud Foundry Way
Kenny Bastani, Spring Developer Advocate, Pivotal @kennybastani
Speaker Intro - Kenny Bastani
2
What are we talking about today?
! Spring Data Redis
! Spring Boot
! We’re going to build a Spring Boot web service with MySQL storage
! Add in Redis caching with Spring Data Redis
! Deploy to the cloud! (Cloud Foundry)
! Stream metrics and compare caching vs. no caching
3
But first…
A database joke
4
Why did the database have problems ingesting data?
5
Because it had ACID indigestion
6
Why did the database have problems ingesting data?
Ok let’s get serious
Let’s talk about architecture
7
Microservices & Polyglot PersistenceIf you’re into that kind of thing
8
Polyglot Persistence
9
Spring Data Redis
10
What is Spring Data Redis?
! Easy access to Redis from your Spring applications
! Provides a variety of abstractions for you to interact with Redis
• Spring Data Repositories (NEW!)
• RedisTemplate
• CacheManager
! Available as a Spring Boot starter project from http://start.spring.io
! Provides a CacheManager implementation so you can use annotation-driven caching on methods
11
+
How does Spring Data work?
Abstractions…
12
Cloud Native Application with Redis Caching
13
Spring BootA JVM micro-framework for building microservices
14
What is Spring Boot?
15
Spring Initializr
16
supports rapid development of production-ready applications and services
Bootstrap your application
17
Add Redis CachingConfigure Redis connection and Spring Data cache manager
18
Redis Cache Config
19
Configure Redis Connection
20
Configure Redis Template
21
Configure Redis Cache Manager
22
Annotation-driven Caching
23
Manage Users REST API Contract
24
Create a UserService
25
@Cacheable - Get or put
26
@CachePut - Update
27
@CacheEvict - Invalidate record
28
Deploy to the cloud!Using Cloud Foundry
29
Cloud Foundry
! Open-source platform as a service (PaaS)
! Supports multiple cloud providers
! Supports build packs for multiple application frameworks
! Supports Linux container deployments using Diego
! Supports Docker container registries
30
Application Server vs Linux Container deployments
31
Application Server Deployment
! 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
32
Virtual Machine
App
Linux Kernel
App App
Hardware Infrastructure
Linux Container Deployment
! 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 minutes
! It’s not a rule that there is one microservice per container
33
Virtual Machine
Container
Linux Kernel
App App
App App
ContainerApp App
App App
ContainerApp App
App App
Hardware Infrastructure
Microservices - Container Deployment
! Each microservice can be containerized with their application dependencies
! Containers get scheduled on virtual machines with an allotted resource policy
34
Auto-scaling
! Minutes to start a VM, but seconds to start a container
! An elastic runtime handles auto-scaling of VMs with cloud providers
35
Demo CF deployment
run.pivotal.io
36
37
38
Learn More. Stay Connected.
! Twitter: @kennybastani
! Spring: spring.io/team/kbastani
! Blog: kennybastani.com
! GitHub: github.com/kbastani
Twitter: twitter.com/springcentral
YouTube: spring.io/video
LinkedIn: spring.io/linkedin
Google Plus: spring.io/gplus