Share
Embed
Microservices in Google App Engine
How Google App Engine can help you to build Microservices.
JBClion
October 26, 2016
Transcript
86 slides
-
Microservices in Google App Engine A Journey to resilience Jean-Baptiste
Clion Google Developer Expert -
App Engine Blog, April 7th, 2008 The goal is to
make easy to get started with a new app, and then make it easy to scale when that app reaches the point where it receiving significant traffic and has millions of users. -
Feature (2008) Behavior (Dynamic only) Deadlines 60-second deadline requests |10-minute
for tasks Background threads Not allowed Residence Evicted from memory Startup and shutdown Instances created on demand | Turned down on idle Instance addressability Instances are anonymous Scaling Scales the number of instances automatically Free daily usage quota 28 instance-hours -
App Engine ecosystem services • Datastore • Task queue •
Cron tasks • User authentication • Messaging (XMPP + Email) • URL Fetch -
1. Split big problems into small pieces 2. Fault-tolerance 3.
Horizontal scaling 4. NoSQL scalable store (With namespaces) 5. Web serving (Use HTTP protocol) App Engine Philosophy [BACKEND INTRODUCED] Justin Haugh, Google I/O 2011 -
Feature (2011) Behavior (Backend Residents) Deadlines Requests to backends can
run indefinitely. Background threads Allowed Residence Possible resident instances, state is preserved. Startup and shutdown Evicted on usage patterns or manually stopped Instance addressability Instances are individually addressable via URL Scaling Configure number or maximum number of instances Free daily usage quota 28 instance-hours -
1. Split application in different logical components. 2. Isolated settings,
deployments & versions. 3. Adjust instances performances & optimize costs. Modules - Replacing backends - Freedom -
Overview 1. Split big problems into small pieces 2. Autoscaling
& Fault Tolerant 3. Rely on simple HTTP(S) communication. 4. NoSQL scalable & isolable storage 5. Use automated deployment processes. -
Split big problems, fault-tolerance, data isolation, communicating via HTTP…. Hey!
Sounds like... Never mind... -
Microservices Breaking down an application into smaller composable pieces which
work together. Each component is developed separately, and the application is then the sum of its constituent components. -
Stateless instances Data isolation Scaling on Y axis API Gateway
Consistent Code Maturity Async HTTP communication Divide & Conquer with microservices -
Code maturity level consistency Your services will follow the same
set of coding practices. Updating your practices implies to update your source code. This will keep cohesion across your solution. -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Different code maturity level V1. Product ID -> Long -
Different code maturity level Frontend Products Frontend Carts Frontend Orders
products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 V1. Product ID -> Long V2. Product ID -> String -
Different code maturity level V1. Product ID -> Long V2.
Product ID -> String Frontend Products Frontend Carts Frontend Orders products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Same code maturity level V2. Product ID -> String V2. Product ID -> String -
Scaling on Y axis You code will have a functional
decomposition by following your business logic [Services]. Your solution will then scale on services instead of entire application. This will have a drastic positive impact on resources. -
Y Axis Functional decomposition Scale by splitting different things X
Axis Horizontal duplication Scale by cloning Z Axis Data partitioning Scale by splitting similar things The Scale cube -
Frontend Products Frontend Orders products existing? Products data Orders data
proceed order Frontend Carts cart valid? Carts data X Scaling - Scale entire application -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Frontend Products products existing? Products data Frontend Carts cart valid? Carts data X Scaling - Scale entire application Frontend Orders Orders data proceed order -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Frontend Products products existing? Products data Frontend Carts cart valid? Carts data Frontend Orders Orders data proceed order X Scaling - Scale entire application -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Products data Orders data proceed order Y Scaling - Scale service only -
products existing? Frontend Products Frontend Carts Frontend Orders products existing?
Products data cart valid? Products data Orders data proceed order Y Scaling - Scale service only -
products existing? products existing? Frontend Products Frontend Carts Frontend Orders
products existing? Products data cart valid? Products data Orders data proceed order Y Scaling - Scale service only -
Async HTTP communication Synchronous communications via REST or asynchron via
message broker. Simple HTTP communications allow flexibility and interoperability between services. -
Stateless instances Do not persist information between requests. This will
allow your instances to scale and increase the amount of worked produced without data inconsistencies. -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Stateful servers -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $30 Caching Stateful servers -
products existing? Frontend Products Frontend Carts Frontend Orders products existing?
Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $10 Product $30 Caching Stateful servers -
products existing? products existing? Frontend Products Frontend Carts Frontend Orders
products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 3 4 10 11 6 7 2 9 0 13 Product $20 Product $10 Product $30 Caching Stateful servers -
products existing? products existing? Frontend Products Frontend Carts Frontend Orders
products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $20 Product $10 Product $30 Caching Stateful servers -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Stateless servers Product $30 -
products existing? Frontend Products Frontend Carts Frontend Orders products existing?
Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $30 Stateless servers -
products existing? products existing? Frontend Products Frontend Carts Frontend Orders
products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $30 Stateless servers -
Data isolation Each service has an isolated and independent persisted
data set. Isolation globally reduce pressure on a single database and avoid overall collapsing due to data interdependencies. -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Have access to unnecessary data Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Have access to unnecessary data Code will slowly be implemented in other service. Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Have access to unnecessary data Code will slowly be implemented in other service. Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order Non isolated datasets -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Isolated data -
API Gateway System single entry point, the gateway will control
and execute the different services required by your client. It will simplify communications and avoid arbitrary API calls. -
Frontend Products Frontend Carts Frontend Orders products existing? Products data
cart valid? Carts data Orders data proceed order No Api Gateway -
Frontend Products Frontend Carts Frontend Orders Check product Products data
Check cart Carts data Orders data proceed order No Api Gateway 1. Call - Check product 2. Call - Check cart 3. Call - proceed order -
Frontend Products Frontend Carts Frontend Orders Check product Products data
Check cart Carts data Orders data proceed order Api Gateway 1. Call - Check product 2. Call - Check cart 3. Call - proceed order Check out Proxy -
Overview 1. Split large problem in small dedicated modules. 2.
Modules are low coupled to ease maintenance. 3. Rely on simple HTTP(S) communication. 4. Data isolation as best practice. 5. Use automated deployment processes. -
Lightweight Event-based Microservices Google Cloud Functions is a lightweight, event-based,
asynchronous compute solution that allows you to create small, single-purpose functions that respond to cloud events without the need to manage a server or a runtime environment. CLOUD FUNCTIONS ALPHA -
Jean-Baptiste Clion Founder @Bercly | GDG Basel Founder | GDE
GCP jbclion +JeanBaptisteClionBasel @JBaptisteClion