auto scaling for multi-tier containers topology
TRANSCRIPT
Auto Scaling for Multi-Tier Containers Topology
The Problem
NotExpected Load
Your app becomes slow
Your app is down
SolutionScale your application
Issues that prevent us to do scaling
• Application is not designed for scaling
• We cannot predict our spikes
• The provisioning of each new instance takes
much time
• We never know what bottlenecks to expect
Let’s try to eliminate these issues
Design your application for multiple instances support
Containers can help you provision appsfaster!
Application Container
Use Docker for packing applications into containers
Mul
tiplic
ity o
f Goo
dsM
ultip
licity
of m
etho
ds fo
r tr
ansp
ortin
g/st
orin
g
Do I w
orry about how
goods interact? C
an I transport quickly and sm
oothly?
…in between, can be loaded and unloaded, stacked, transported efficiently over long distances, and transferred from one mode of transport to another
A standard container that is loaded with virtually any goods, and stays sealed until it reaches final delivery.
Shipping container for goods
Static website
Web frontend
User DB
Queue
Analytics DB
Development VM
QA server
Public Cloud Contributor’s
laptop
Mul
tiplic
ity o
f Sta
cks
Production Cluster
Customer Data Center
…that can be manipulated using standard operations and run consistently on virtually any hardware platform
An engine that enables any payload to be encapsulated as a lightweight, portable, self-sufficient container…
Docker is a shipping container system for code
Mul
tiplic
ity o
f har
dwar
e en
viro
nmen
ts
Do services and apps
interact appropriately?C
an I migrate sm
oothly and quickly?
Why Docker containers are better for scaling than VMs?
Designed for High Availability
Lets Scale
Using Docker
Simple WordPress application
The Goal
• You must use load balancer once you scale an app horizontally
• Keep look at sticky load balancing
• Load balancer can be scaled horizontally
• Dynamic scaling in and out is also possible!
Load balancing consideration
Scaling of the web layer
• Should be done just in time
• Load balancer should be aware of resizing at the web layer
• Requires additional actions for stateful applications:
• Use of storage replication
• Use of shared persistent storage
Database scaling consideration
• Relational databases usually scale good only vertically
• Relational database usually can’t be scaled horizontally in a runtime
• We have to prepare a database cluster of a fixed size
The topology that we try to create
{ "extip": true, "cloudlets": 8, "count": 2, "nodeType": "docker", "nodeGroup": "bl", "docker": { "image": "jelastic/wp-nginxlb" }, "displayName": "Load balancer"}
Load balancer layer declaration
{ "cloudlets": 8, "count": 2, "nodeType": "docker", "nodeGroup": "cp", "docker": { "image": "jelastic/wp-nginxphp", "links": "sqldb:db", "volumes": ["/var/www/webroot/ROOT"], "volumeMounts": { "/var/www/webroot/ROOT": { "readOnly": false, "sourcePath": "/data", "sourceNodeGroup": "storage" } } }, "displayName": "AppServer"}
Web layer declaration
{ "cloudlets": 8, "nodeGroup": "storage", "nodeType": "docker", "docker": { "image": "jelastic/storage" }, "displayName": "Storage"}, { "cloudlets": 8, "count": 2, "nodeType": "docker", "nodeGroup": "sqldb", "docker": { "image": "jelastic/wp-db" }, "displayName": "Database"}
DB & Storage layer declaration
Set your triggers for each layer
"onAfterScaleIn[nodeGroup:cp]": { "call": "ScaleNodes" }, "onAfterScaleOut[nodeGroup:cp]": { "call": "ScaleNodes" }, "onInit": { "call": [ "configureDBReplication","setupWP", "ScaleNodes", "enableAutoScaling" ] }}
Scaling Triggers declaration
{ "id": "ScaleNodes", "onCall": [{ "execCmd": [{ "commands": ["echo \"\" > /etc/nginx/upstreams/common"], "nodeGroup": "bl" }] }, { "forEach(node:nodes.cp)": { "execCmd": { "commands": ["echo \"${@node.intIP}\" >> /etc/nginx/upstreams/common"], "nodeGroup": "bl" } } }, { "execCmd": { "commands": ["jem balancer rebuildCommon", "/etc/init.d/nginx reload"], "nodeGroup": "bl" } } ]}
Scaling Triggers Body
Use stress tools to simulate load
Analyze metrics in each individual microservice
THANKSRegister for free