Heat Optimization
Rico Lin
Chief OpenStack Technologist, inwinSTACK
IRC: ricolin
rico.l@inwinstack.com
@ricolintw
Placeholder Footer Copy / BU Logo or Name Goes Here
Why NOT
> 80%
adoption rates
Orchestrates multiple composite cloud applications by using either the
native HOT template format or the AWS CloudFormation template
format, through both an OpenStack-native REST API and a
CloudFormation-compatible Query API.
• Was not parallel excution
• Database monster
• Memory monster
• Don’t know how we can use it?
Because!
Convergence :
Truly using every power we have
Template Heat-API AMQP
Heat-engine
AMQP
(engine_w
orker)
Worker
DB
B
A
Template Heat-API AMQP
Heat-engine
DB stackA
stackA
stackA
stackA
?
• Start Newton, `convergence_engine` default
to `True`
• (CLI)Migrate your old stack
to convergence_stack
convergence_engine = True
Template Heat-API AMQP
Heat-engine
AMQP
(engine_w
orker)
Worker
DB
num_engine_workers =
max(4, multiprocessing.cpu_count())
• What your node been used for?
• How many socket/process/core?
How many workers you needs
Worker 1
...
...
Worker N
More Database comsume
when we change to Convergence
Eager and Lazy Fetch
• What always been query right next to each
other?(Eager fetch it!)
– raw_template always after stack
• What we can took a chance and read if
required(Lazy fetch it!)
– stack_tag not always after stack
Contexts Cache(WIP)
• Only apply when `refresh = False`
• Replace database access
Task
Cache
DB
(WIP)Batch Schedule Task
• Accept Queue to process tasks in batch
Template Heat-API AMQP
Heat-engineAMQP
(engine_worker)
Worker
DB
TaskTask
Task
Task
Task
Task
Task
Task
Task
Task
Task
Optimize Sync Table
C
D
B
A
SyncPoint
leaves
• Resolving back to back retry
– Random retry
• max_wait=conflict_count*0.01
• wait=random(0, max_wait)
– (WIP)Exponential backoff
• wait=random(max_wait)*2^N+jitter
(WIP)Resolving Update Cancel
• How to handle with ½ instances created and
½ are not.
• API for handle_%s_cancel
Reduce dramatically (Witout WIP)
Placeholder Footer Copy / BU Logo or Name Goes Here
Optimize
your script
More operate = More mistake
1 Operation
<20 Min.
> 100 Operations
>100 Min. VS
Stack
Stack = Parameters + Resources
parameters:
flavor:
type: string
network:
type: string
resources:
service_server_group:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: num_servers}
resource_def:
type: OS::Nova::Server
properties:
image: { get_param: image_id }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
networks: [{network: {get_param: network} }]
Functions
Easy Constraint, Easy life
Parameters:
flavor:
type: string
description: Flavor for the server to be
created
constraints:
- custom_constraint: nova.flavor
volume_size:
type: number
description: Size of volume to attach to
instance
default: 2
constraints:
- range: { min: 1, max: 10 }
A good way to monitor your
resources
Making Good Use of Old Resources
resources:
cinder_volume:
type: OS::Cinder::Volume
properties:
size: { get_param: volume_size }
image: { get_param: image }
service_server_group:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: num_servers }
resource_def:
type: OS::Nova::Server
properties:
image: { get_param: image_id }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
networks: [{network: {get_param: network} }]
Nothing change!
Nested Stack -> type: stack.yaml
resources:
cinder_volume_attach:
type: cinder_volume_attach.yaml
properties:
size: { get_param: volume_size }
...
service_server_groups:
type: server_group.yaml
properties:
...
cinder_volume:
type: OS::Cinder::Volume
properties:
size: { get_param: volume_size }
image: { get_param: image }
service_server_group:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: num_servers }
resource_def:
type: OS::Nova::Server
properties:
image: { get_param: image_id }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
networks: [{network: {get_param: network} }]
my_res_group
type: OS::Heat::ResourceGroup
properties:
count: 100
resource_def:
type: OS::Nova::Server
…
Resource Group
scale_up_policy:
type: OS::Heat::ScalingPolicy
properties:
auto_scaling_group_id: { get_resource: group }
...
group:
type: OS::Heat::AutoScalingGroup
...
type: OS::Nova::Server
...
outputs:
server_list:
value: [{get_attr: [my_res_group, name]}]
Software Config
my_deps:
type: OS::Heat::SoftwareDeploymentGroup
properties:
config: {get_resource: config}
servers: {{get_attr: [servers, name]}}
signal_transport: NO_SIGNAL
config:
type: OS::Heat::SoftwareConfig
properties:
group: ansible
inputs:
- name: cluster-one
outputs:
- name: result
config:
get_file: config-scripts/cluster-ansible.ansible
---
- name: Mysql Cluster -
connection: local
hosts: localhost
tasks:
- name: Hello touch_file
shell: echo {{ foo }} >> /tmp/{{ bar }}
- name: Hello echo
shell: echo "The file /tmp/{{ bar }} contains {{ foo }}"
>> {{ heat_outputs_path }}.result
Multi layer services
Another_SoftwareDeploymentGroup
config: {get_resource: another_config}
servers: {{get_attr: [servers, name]}}
signal_transport: NO_SIGNAL
Another_config:
type: OS::Heat::SoftwareConfig
properties:
group: ansible
inputs:
- name: {get_attr: [config, result]}
outputs:
- name: result
config:
get_file: cluster_db-ansible.ansible
...
shell: ... >> {{ heat_outputs_path }}.result
Use case
DB DB DB Storage Storage Storage
Load Balancer
Auto Scaling
Web Server Web ServerWeb Server
Stack
Heat Optimization
Rico Lin
Chief OpenStack Technologist, inwinSTACK
IRC: ricolin
rico.l@inwinstack.com
@ricolintw
Demo
Heat Optimization
Rico Lin
Chief OpenStack Technologist, inwinSTACK
IRC: ricolin
rico.l@inwinstack.com
@ricolintw
Q&A

Heat optimization

  • 1.
    Heat Optimization Rico Lin ChiefOpenStack Technologist, inwinSTACK IRC: ricolin rico.l@inwinstack.com @ricolintw
  • 2.
    Placeholder Footer Copy/ BU Logo or Name Goes Here Why NOT > 80% adoption rates Orchestrates multiple composite cloud applications by using either the native HOT template format or the AWS CloudFormation template format, through both an OpenStack-native REST API and a CloudFormation-compatible Query API.
  • 3.
    • Was notparallel excution • Database monster • Memory monster • Don’t know how we can use it? Because!
  • 4.
    Convergence : Truly usingevery power we have Template Heat-API AMQP Heat-engine AMQP (engine_w orker) Worker DB B A Template Heat-API AMQP Heat-engine DB stackA stackA stackA stackA ?
  • 5.
    • Start Newton,`convergence_engine` default to `True` • (CLI)Migrate your old stack to convergence_stack convergence_engine = True Template Heat-API AMQP Heat-engine AMQP (engine_w orker) Worker DB
  • 6.
    num_engine_workers = max(4, multiprocessing.cpu_count()) •What your node been used for? • How many socket/process/core? How many workers you needs Worker 1 ... ... Worker N
  • 7.
    More Database comsume whenwe change to Convergence
  • 8.
    Eager and LazyFetch • What always been query right next to each other?(Eager fetch it!) – raw_template always after stack • What we can took a chance and read if required(Lazy fetch it!) – stack_tag not always after stack
  • 9.
    Contexts Cache(WIP) • Onlyapply when `refresh = False` • Replace database access Task Cache DB
  • 10.
    (WIP)Batch Schedule Task •Accept Queue to process tasks in batch Template Heat-API AMQP Heat-engineAMQP (engine_worker) Worker DB TaskTask Task Task Task Task Task Task Task Task Task
  • 11.
    Optimize Sync Table C D B A SyncPoint leaves •Resolving back to back retry – Random retry • max_wait=conflict_count*0.01 • wait=random(0, max_wait) – (WIP)Exponential backoff • wait=random(max_wait)*2^N+jitter
  • 12.
    (WIP)Resolving Update Cancel •How to handle with ½ instances created and ½ are not. • API for handle_%s_cancel
  • 13.
  • 14.
    Placeholder Footer Copy/ BU Logo or Name Goes Here Optimize your script More operate = More mistake 1 Operation <20 Min. > 100 Operations >100 Min. VS Stack
  • 15.
    Stack = Parameters+ Resources parameters: flavor: type: string network: type: string resources: service_server_group: type: OS::Heat::ResourceGroup properties: count: { get_param: num_servers} resource_def: type: OS::Nova::Server properties: image: { get_param: image_id } flavor: { get_param: flavor } key_name: { get_param: key_name } networks: [{network: {get_param: network} }]
  • 16.
  • 17.
    Easy Constraint, Easylife Parameters: flavor: type: string description: Flavor for the server to be created constraints: - custom_constraint: nova.flavor volume_size: type: number description: Size of volume to attach to instance default: 2 constraints: - range: { min: 1, max: 10 }
  • 18.
    A good wayto monitor your resources
  • 19.
    Making Good Useof Old Resources resources: cinder_volume: type: OS::Cinder::Volume properties: size: { get_param: volume_size } image: { get_param: image } service_server_group: type: OS::Heat::ResourceGroup properties: count: { get_param: num_servers } resource_def: type: OS::Nova::Server properties: image: { get_param: image_id } flavor: { get_param: flavor } key_name: { get_param: key_name } networks: [{network: {get_param: network} }] Nothing change!
  • 20.
    Nested Stack ->type: stack.yaml resources: cinder_volume_attach: type: cinder_volume_attach.yaml properties: size: { get_param: volume_size } ... service_server_groups: type: server_group.yaml properties: ... cinder_volume: type: OS::Cinder::Volume properties: size: { get_param: volume_size } image: { get_param: image } service_server_group: type: OS::Heat::ResourceGroup properties: count: { get_param: num_servers } resource_def: type: OS::Nova::Server properties: image: { get_param: image_id } flavor: { get_param: flavor } key_name: { get_param: key_name } networks: [{network: {get_param: network} }]
  • 21.
    my_res_group type: OS::Heat::ResourceGroup properties: count: 100 resource_def: type:OS::Nova::Server … Resource Group scale_up_policy: type: OS::Heat::ScalingPolicy properties: auto_scaling_group_id: { get_resource: group } ... group: type: OS::Heat::AutoScalingGroup ... type: OS::Nova::Server ... outputs: server_list: value: [{get_attr: [my_res_group, name]}]
  • 22.
    Software Config my_deps: type: OS::Heat::SoftwareDeploymentGroup properties: config:{get_resource: config} servers: {{get_attr: [servers, name]}} signal_transport: NO_SIGNAL config: type: OS::Heat::SoftwareConfig properties: group: ansible inputs: - name: cluster-one outputs: - name: result config: get_file: config-scripts/cluster-ansible.ansible --- - name: Mysql Cluster - connection: local hosts: localhost tasks: - name: Hello touch_file shell: echo {{ foo }} >> /tmp/{{ bar }} - name: Hello echo shell: echo "The file /tmp/{{ bar }} contains {{ foo }}" >> {{ heat_outputs_path }}.result
  • 23.
    Multi layer services Another_SoftwareDeploymentGroup config:{get_resource: another_config} servers: {{get_attr: [servers, name]}} signal_transport: NO_SIGNAL Another_config: type: OS::Heat::SoftwareConfig properties: group: ansible inputs: - name: {get_attr: [config, result]} outputs: - name: result config: get_file: cluster_db-ansible.ansible ... shell: ... >> {{ heat_outputs_path }}.result
  • 24.
    Use case DB DBDB Storage Storage Storage Load Balancer Auto Scaling Web Server Web ServerWeb Server Stack
  • 25.
    Heat Optimization Rico Lin ChiefOpenStack Technologist, inwinSTACK IRC: ricolin rico.l@inwinstack.com @ricolintw Demo
  • 26.
    Heat Optimization Rico Lin ChiefOpenStack Technologist, inwinSTACK IRC: ricolin rico.l@inwinstack.com @ricolintw Q&A