Scaling policy examples

Metrics and thresholds are used to manage scaling.

WebSphere Application Server scaling policy

There are several types of WebSphere® Application Server scaling, which are based on specific thresholds and metrics.
CPU Based
Scaling is based on a processor usage threshold range, a minimum time to trigger an add or remove, and a specified scaling action type.
Memory based
Scaling is based on a memory usage threshold range, a minimum time to trigger an add or remove, and a specified scaling action type.
Response Time Based
Scaling is based on a web response time threshold range and a minimum time to trigger an add or remove.
Database connection based
Scaling is based on the JDBC connection wait time range or JDBC connection pools usage threshold range, and a minimum time to trigger an add or remove.
In the appmodel/metadata.json file in the WebSphere Application Server plug-in, the widget "group" is used to present scaling types. The following JSON snippet shows the usage of "group" for scaling policy metadata.
"groups": [  
            {
                "id" : "CPUBased",
                "label": "SCALE_POLICY_TYPE_CPU",
                "defaultValue" : false,
                "attributes": [
                    "CPU.Used" ,
                    "triggerTime.CPUBased",
                    "actionType.CPUBased"
                ],
				"description":"SCALE_POLICY_TYPE_CPU_DESCRIPTION" 
            } ,
             {
                "id" : "MemoryBased",
                "label": "SCALE_POLICY_TYPE_MEMORY",
                "defaultValue" : false,
                "attributes": [
                    "Memory.Used" ,
                    "triggerTime.MemoryBased",
                    "actionType.MemoryBased"
                ],
				"description":"SCALE_POLICY_TYPE_MEMORY_DESCRIPTION" 
            } ,
            {
                "id" : "ResponseBased",
                "label": "SCALE_POLICY_TYPE_RESPONSE",
                "defaultValue" : false,
                "attributes": [
                    "WAS_WebApplications.max_service_time",
                    "triggerTime.ResponseBased" 
                ],
				"description":"SCALE_POLICY_TYPE_RESPONSE_DESCRIPTION" 
            } ,
            {              
                "id" : "DBConnectBased",
                "label": "SCALE_POLICY_TYPE_DBCONNECTION",
                "defaultValue" : false,
                "attributes": [              
                    "WAS_JDBCConnectionPools.wait_time",
                    "WAS_JDBCConnectionPools.percent_used" ,
                    "triggerTime.DBConnectBased" 
                ],
				"description":"SCALE_POLICY_TYPE_DBCONNECTION_DESCRIPTION" 
            } 
        ],
        
        ……  
The scaling policy that is attached on the WAS component with the DBConnectBased policy type selected would look like following example in the application model.
{
    "attributes": {
        "version": "1",
        "cachingEnable": true,
        "cachingCap": "-1",
        "scaleInstanceRange": [
            1,
            10
        ],
        "scaleMaxvCPU": "1",
        "scaleMaxMemory": "1024",
        "WAS_JDBCConnectionPools.wait_time": [
            1000,
            5000
        ],
        "WAS_JDBCConnectionPools.percent_used": [
            20,
            80
        ],
        "triggerTime.DBConnectBased": 300
    },
    "id": "Scaling Policy",
    "type": "ScalingPolicyofWAS",
    "groups": {
        "CPUBased": false,
        "MemoryBased": false,
        "ResponseBased": false,
        "DBConnectBased": true
    }
}
The WAS transformer generates the following JSON snippet in the topology document from the DBConnectBased type of scaling policy.
{
    "triggerEvents": [
      {
            "metric": "WAS_WebApplications.max_service_time",
            "triggerTime": 300,
            "conjunction": "OR",
            "scaleOutThreshold": {
                "value": 5000,
                "type": "CONSTANT",
                "relation": ">="
            },
            "scaleInThreshold": {
                "value": 1000,
                "type": "CONSTANT",
                "relation": "<="
            }
        },
        {
            "metric": "WAS_JDBCConnectionPools.wait_time",
            "triggerTime": 300,
            "conjunction": "OR",
            "scaleOutThreshold": {
                "value": 5000,
                "type": "CONSTANT",
                "relation": ">="
            },
            "scaleInThreshold": {
                "value": 1000,
                "type": "CONSTANT",
                "relation": "<="
            }
        },
        {
            "metric": "WAS_JDBCConnectionPools.percent_used",
            "triggerTime": 300,
            "conjunction": "OR",
            "scaleOutThreshold": {
                "value": 80,
                "type": "CONSTANT",
                "relation": ">="
            },
            "scaleInThreshold": {
                "value": 20,
                "type": "CONSTANT",
                "relation": "<="
            }
        }
    ],
    "min": 1,
    "max": 10,
    "minmemory": 0,
    "maxmemory": 1024,
    "mincpucount": 0,
    "maxcpucount": 1,
    "memoryDownDecrement": 1024,
    "memoryUpIncrement": 1024,
    "cpucountDownDecrement": 1,
    "cpucountUpIncrement": 1,
    "role": "WAS"
}

Topology for horizontal scaling

This example shows how to enable horizontal scaling.

{
    "triggerEvents": [
        {
            "metric": "CPU.Used",
            "triggerTime": 300,
            "conjunction": "OR",
            "scaleOutThreshold": {
                "value": 80,
                "type": "CONSTANT",
                "relation": ">="
            },
            "scaleInThreshold": {
                "value": 20,
                "type": "CONSTANT",
                "relation": "<="
            }
        }
    ],
    "min": 1,
    "max": 10,
    "mincpucount": 2,
    "maxcpucount": 2,
    "minmemory": 4096,
    "maxmemory": 4096,
    "memoryDownDecrement": 1024,
    "memoryUpIncrement": 1024,
    "cpucountDownDecrement": 1,
    "cpucountUpIncrement": 1,
    "role": "WAS"
}

Topology for processor vertical scaling

This example shows how to enable vertical scaling of the processor.

{
    "triggerEvents": [
        {
            "metric": "CPU.Used",
            "triggerTime": 300,
            "conjunction": "OR",
            "scaleUpCPUThreshold": {
                "value": 80,
                "type": "CONSTANT",
                "relation": ">="
            }            
        }
    ],
    "min": 1,
    "max": 10,
    "maxcpucount": 2,
    "cpucountUpIncrement": 1,
"role": "WAS"
}

Topology for memory vertical scaling

This example shows how to enable vertical scaling of the memory.

{
    "triggerEvents": [
        {
            "metric": "MEMORY.Used",
            "triggerTime": 300,
            "conjunction": "OR",
            "scaleUpMemoryThreshold": {
                "value": 80,
                "type": "CONSTANT",
                "relation": ">="
            }            
        }
    ],
    "min": 1,
    "max": 10,
    "maxmemory": 2,
    "memoryUpIncrement": 1,
"role": "WAS"
}

Topology for horizontal and vertical scaling

This example shows how to enable horizontal and vertical scaling.

{
    "triggerEvents": [
        {
            "metric": "CPU.Used",
            "triggerTime": 300,
            "conjunction": "OR",
            "scaleOutThreshold": {
                "value": 80,
                "type": "CONSTANT",
                "relation": ">="
            },
            "scaleInThreshold": {
                "value": 20,
                "type": "CONSTANT",
                "relation": "<="
            }
        },
  {
       "metric": "MEMORY.Used",
       "triggerTime": 300,
       "scaleUpCPUThreshold": {
             "value": 80,
              "type": "CONSTANT",
              "relation": ">="
            },
         "conjunction": "OR"
        }
    ],
    "min": 1,
    "max": 10,
    "maxmemory": 4096,
    "maxcpucount": 2,
    "memoryUpIncrement": 1024,
    "cpucountUpIncrement": 1,
    "role": "WAS"
  },
        {
            "metric": "MEMORY.Used",
            "triggerTime": 300,
            "scaleUpMemoryThreshold": {
                "value": 80,
                "type": "CONSTANT",
                "relation": ">="
            },
            "conjunction": "OR"
        }
    ],
    "min": 1,
    "max": 10,
    "maxmemory": 4096,
    "maxcpucount": 2,
    "memoryUpIncrement": 1024,
    "cpucountUpIncrement": 1,
    "role": "WAS"
}