-
Notifications
You must be signed in to change notification settings - Fork 5
W-14455231-ch2-autoscaling-BETA #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
luanamulesoft
wants to merge
24
commits into
latest
Choose a base branch
from
W-14455231-ch2-autoscaling-LDS
base: latest
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3b3f2f2
W-14455231-ch2-autoscaling
luanamulesoft 7780ada
added content
luanamulesoft 834d1b9
added link in nav
luanamulesoft 7be01bd
changed title
luanamulesoft 9c4ead2
Update cloudhub-2/modules/ROOT/pages/ch2-configure-horizontal-autosca…
luanamulesoft 4b9133e
Update cloudhub-2/modules/ROOT/pages/ch2-configure-horizontal-autosca…
luanamulesoft a30965e
Update cloudhub-2/modules/ROOT/pages/ch2-configure-horizontal-autosca…
luanamulesoft 8c484ef
Update ch2-configure-horizontal-autoscaling.adoc
luanamulesoft 6f35725
Update cloudhub-2/modules/ROOT/pages/ch2-configure-horizontal-autosca…
luanamulesoft 03587c1
Update ch2-configure-horizontal-autoscaling.adoc
luanamulesoft 0e88d3a
Update cloudhub-2/modules/ROOT/pages/ch2-configure-horizontal-autosca…
luanamulesoft f0912a6
applied reviews3
luanamulesoft f9ee9e3
applied reviews-image
luanamulesoft 6f69e23
applied reviews-add-policy
luanamulesoft 11d41c8
applied add apps examples
luanamulesoft a1cdb4d
applied reviews3
luanamulesoft c655860
applied image
luanamulesoft 77e07aa
applied image3
luanamulesoft f3631e2
added audit logs
luanamulesoft e153844
Update ch2-configure-horizontal-autoscaling.adoc
kevintroller 9f62290
chaged image
luanamulesoft fa131b0
reviews 4
luanamulesoft 6930602
reviews 5
luanamulesoft e3fcaaa
Update cloudhub-2/modules/ROOT/pages/ch2-configure-horizontal-autosca…
luanamulesoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+311 KB
cloudhub-2/modules/ROOT/assets/image-source-files/ch2-config-autoscaling.graffle
Binary file not shown.
Binary file added
BIN
+746 KB
cloudhub-2/modules/ROOT/assets/image-source-files/ch2-status-autoscaling.graffle
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
cloudhub-2/modules/ROOT/pages/ch2-configure-horizontal-autoscaling.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| = Configuring Horizontal Autoscaling (HPA) for CloudHub 2.0 Deployments | ||
| ifndef::env-site,env-github[] | ||
| include::_attributes.adoc[] | ||
| endif::[] | ||
|
|
||
| You can configure CPU-based horizontal scaling for Mule applications to make them responsive to CPU usage by automatically scaling up or down the deployment replicas as needed. | ||
|
|
||
| In Kubernetes, a Horizontal Pod Autoscaler (HPA) automatically updates a workload resource, with the aim of automatically scaling the workload to match demand. Horizontal scaling means that the response to increased load is to deploy more pods. For more information, visit the https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale[Kubernetes documentaton^]. | ||
|
|
||
| == Configure Horizontal Pod Autoscaling | ||
|
|
||
| To configure horizontal autoscaling for Mule apps deployed to CloudHub 2.0, follow these steps: | ||
|
|
||
| . From Anypoint Platform, select *Runtime Manager* > *Applications*. | ||
| . Click *Deploy application*. | ||
| . In the *Runtime* tab, check the *Enable Autoscaling* box. | ||
| . Set the minimum and maximum *Replica Count* limits. | ||
| . Click *Deploy Application*. | ||
|
|
||
| image::ch2-config-autoscaling.png[Configure horizontal autoscaling] | ||
|
|
||
| == Autoscaling Status and Logs | ||
|
|
||
| When an autoscaling event occurs and your Mule application with horizontal autoscaling scales up, you can check the *Scaling* status by clicking *View status* in your application's details window. You can also see the *Scaling* status of your application in the *Applications* list. | ||
|
|
||
| image::ch2-status-autoscaling.png[Check the application's scaling status.] | ||
|
|
||
| You can track the scaled-up replicas startup and the number of replicas your application scaled from and to by checking the application's logs: | ||
|
|
||
| . From Anypoint Platform, select *Runtime Manager* > *Applications*. | ||
| . Click the row of the application with autoscaling. | ||
| . Click *Manage application*. | ||
| . Select the *Logs* tab. | ||
|
|
||
| [source,console,linenums] | ||
| ---- | ||
| Info 8 minutes ago - 2023-11-08 14:35:01.466 PST - Runtime Manager | ||
| Application id:<app-ID> scaled UP from 1 to 2 replicas. | ||
| Info a minute ago - 2023-11-08 14:41:24.819 PST - Runtime Manager | ||
| Application id:<app-ID> scaled DOWN from 2 to 1 replicas. : | ||
| ---- | ||
|
|
||
| You can also track when autoscaling events occur through xref:access-management::audit-logging.adoc[Audit Logs] in Access Management. Each time an application deployment scales, there is an audit log published under the product *Runtime Manager*, by the *Anypoint Staff* user. The log has *Action* set to `Scaling` with the *Object* as the application ID. | ||
|
|
||
|
|
||
| The following is an example log payload: | ||
|
|
||
| [source,console,linenums] | ||
| ---- | ||
| {"properties":{"organizationId":"my-orgID-abc","environmentId":"my-envID-xyz","response":{"message":{"message":"Application id:my-appID-123 scaled DOWN from 3 to 2 replicas.","logLevel":"INFO","context":{"logger":"Runtime Manager"},"timestamp":1700234556678}},"deploymentId":"my-appID-123","initialRequest":"/organizations/my-orgID-abc/environments/my-envID-xyz/deployments/my-appID-123/specs/my-specID-456"},"subaction":"Scaling"} | ||
| ---- | ||
|
|
||
|
|
||
| == Understand CPU-based Autoscaling Policy | ||
|
|
||
| MuleSoft owns and applies the https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/[autoscaling^] policy for your Mule application deployments. | ||
|
|
||
| The CPU-based HPA policy used for all Mule apps deployed to CloudHub 2.0 is as follows: | ||
|
|
||
| ---- | ||
| apiVersion: autoscaling/v2 | ||
| kind: HorizontalPodAutoscaler | ||
| metadata: | ||
| name: my-app | ||
| namespace: app-namespace | ||
| spec: | ||
| behavior: | ||
| scaleDown: | ||
| policies: | ||
| - periodSeconds: 15 | ||
| type: Percent | ||
| value: 100 | ||
| selectPolicy: Max | ||
| stabilizationWindowSeconds: 300 | ||
| scaleUp: | ||
| policies: | ||
| - periodSeconds: 180 | ||
| type: Percent | ||
| value: 100 | ||
| selectPolicy: Max | ||
| stabilizationWindowSeconds: 0 | ||
| maxReplicas: 3 | ||
| metrics: | ||
| - resource: | ||
| name: cpu | ||
| target: | ||
| averageUtilization: 70 | ||
| type: Utilization | ||
| type: Resource | ||
| minReplicas: 1 | ||
| scaleTargetRef: | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| name: my-app | ||
| ---- | ||
|
|
||
| Some points to consider: | ||
|
|
||
| Scale up can occur at most every 180 seconds. Each period, up to 100% of the currently running replicas may be added until the maximum configured replicas is reached. For scaling up there is no stabilization window. When the metrics indicate that the target should be scaled up, the target is scaled up immediately. | ||
|
|
||
| Scale down can occur at most every 15 seconds. Each Period, up to 100% of the currently running replicas may be removed which means the scaling target can be scaled down to the minimum allowed replicas. The number of replicas removed is based on the aggregated calculations over the past 300 seconds of the stabilization window. | ||
|
|
||
| Min replicas + | ||
|
|
||
| * The minimum number of replicas that would be guaranteed to run at any given point of time. | ||
| * Scale down policy would never remove replicas below this number. | ||
|
|
||
| Max replicas + | ||
|
|
||
| * The maximum number of replicas that are capped, beyond which no more replicas can be added for scale up. | ||
| * Scale up policy would never add replicas above this number. | ||
|
|
||
|
|
||
| == Performance Considerations and Limitations | ||
|
|
||
| For a successful horizontal autoscaling of your Mule apps, review the following performance considerations: | ||
|
|
||
| * Mule apps that scale based on CPU usage are a good fit with CPU based HPA. For example: | ||
| ** HTTP/HTTPS applications with async requests. | ||
| ** Reverse Proxies. | ||
| ** Low latency+High throughput applications. | ||
| ** Dataweave Transformations. | ||
| ** APIKit Routing. | ||
| ** API Gateways with policies. | ||
| * Non-reentrant applications that do not have built-in parallel processing such as batch jobs, scheduler applications without re-entrancy and duplicate scheduling across applications, and low-throughput, high-latency applications with large requests are not a good fit with CPU-based HPA. | ||
|
|
||
| === Limitations | ||
|
|
||
| There are some limitations to consider: | ||
|
|
||
| * CPU-based HPA does not work with clustering and rate limiting. | ||
| * CPU-based HPA works with 0.1 vCores replica size only. | ||
|
|
||
|
|
||
| == See Also | ||
|
|
||
| * xref:runtime-fabric::configure-horizontal-autoscaling.adoc[] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.