Auto Scaling for Multi-Tier
Containers Topology
The Problem
Not
Expected
Load
Your app
becomes
slow
Your app
is down
Solution
Scale 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
apps
faster!
Application Container
Use Docker for packing applications into
containers
MultiplicityofGoodsMultiplicityofmethodsfor
transporting/storing
DoIworryabouthow
goodsinteract?
CanItransportquickly
andsmoothly?
…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 frontendUser DB Queue Analytics DB
Development
VM
QA server Public Cloud Contributor’s
laptop
MultiplicityofStacks
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
Multiplicityofhardware
environments
Doservicesandapps
interactappropriately?
CanImigratesmoothly
andquickly?
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
THANKS
Register for free
jelastic.cloud
info@jelastic.com

Auto Scaling for Multi-Tier Containers Topology