KAHIBARO Bookshelves
Discord Login Register

11.2. Vertical scaling

Concept of Vertical Scaling in OpenShift

Vertical scaling in OpenShift means changing the resources available to a pod (and therefore its containers), rather than changing the number of pod replicas. Instead of adding more pods, you give more CPU, memory, or other resources to the existing pods.

In Kubernetes/OpenShift terms, this is about adjusting:

  • requests – what a pod is guaranteed to get.
  • limits – the maximum a pod is allowed to use.

Vertical scaling is especially relevant for:

  • Stateful or legacy applications that cannot scale out horizontally.
  • Workloads with strong single-threaded bottlenecks.
  • Applications with strict licensing per node/core.

Horizontal Pod Autoscaling (HPA) and cluster-autoscaling focus on more pods and more nodes; vertical scaling focuses on bigger pods.

Resource Requests and Limits

Vertical scaling is implemented primarily by adjusting CPU and memory requests/limits in pod specs (via Deployment, StatefulSet, DeploymentConfig, etc.).

Example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-app
spec:
  replicas: 1
  template:
    spec:
      containers:
      - name: app
        image: myorg/example:latest
        resources:
          requests:
            cpu: "250m"
            memory: "512Mi"
          limits:
            cpu: "2"
            memory: "4Gi"

Typical vertical scaling actions:

  • Scale up: increase requests and/or limits (e.g. from 512Mi to 2Gi memory).
  • Scale down: decrease requests and/or limits.

Implications:

  • If requests are increased, the pod may need to be rescheduled to a node that has enough free capacity.
  • If limits are too low, the pod may throttle on CPU or get OOMKilled on memory.
  • If requests are too high, scheduling options shrink, and overall cluster utilization gets worse.

Manual Vertical Scaling Workflow

Vertical scaling can be done manually by editing the workload spec and letting OpenShift roll out new pods.

Typical workflow:

  1. Observe metrics:
    • Pod CPU usage, throttling, memory usage, OOM kills.
  2. Update the workload definition:
    • oc edit deployment my-app or
    • oc set resources deployment/my-app --limits=cpu=2,memory=4Gi --requests=cpu=1,memory=2Gi
  3. Apply new configuration:
    • OpenShift triggers a rollout (new pods with new resources).
  4. Verify:
    • oc get pods to see new pods.
    • Re-check metrics to ensure the new size is sufficient.

Example with oc:

# Increase CPU and memory for a deployment
oc set resources deployment/my-app \
  --requests=cpu=500m,memory=1Gi \
  --limits=cpu=2,memory=4Gi

Manual scaling is simple but:

  • Depends on human analysis and intervention.
  • May be too slow for rapid workload changes.
  • Can be error-prone in large environments.

Vertical Pod Autoscaling Concepts

Kubernetes has the concept of Vertical Pod Autoscaling (VPA), and similar functionality can be used within OpenShift depending on version, installed Operators, or custom tooling.

The idea:

  • Continuously observe pod resource usage.
  • Recommend or apply new CPU/memory requests/limits.
  • Trigger pod restarts with updated resource settings.

Typical VPA components (conceptual):

  • Recommender – analyzes historical metrics (CPU, memory usage).
  • Updater – decides which pods should be updated and when.
  • Admission controller/webhook – mutates pod specs at creation time to include recommended resources.

Modes you may encounter:

  • Off / Recommendation-only: produces suggestions but doesn’t change pods.
  • Initial: sets resources only when a pod is created.
  • Auto: can evict and recreate pods with updated resources.

Use cases:

  • Batch workloads with unpredictable size.
  • Long-running services where it’s hard to tune requests manually.
  • Environments where you want to gradually converge on right-sizing.

Trade-offs:

  • VPA may evict pods, causing restarts.
  • Works best with robust applications that can handle restarts and short downtimes.
  • Needs properly configured metrics and retention to make good decisions.

Vertical Scaling and Scheduling

Vertical scaling affects how pods fit onto nodes:

  • Increasing requests makes pods “bigger” from the scheduler’s perspective.
  • Larger pods may only fit on a few nodes, impacting placement.
  • If no node can satisfy the increased request, the pod stays in Pending state.

Considerations:

  • Node size vs pod size:
    • If nodes are small and pods are huge, fragmentation increases, and scheduling becomes difficult.
  • Overcommitment:
    • limits > requests allow overcommit; many pods can ask for more peak than guaranteed.
    • High overcommit needs careful monitoring; otherwise pods may experience contention and throttling.

In OpenShift clusters with cluster autoscaling, vertical scaling can:

  • Trigger node scale-out if pods with larger requests cannot be placed.
  • Cause scale-in delays, as large pods may pin nodes from being emptied.

Vertical vs Horizontal Scaling in OpenShift

Vertical scaling and horizontal scaling often complement each other.

Typical patterns:

  • Step 1: Right-size vertically:
    • Make sure each pod has a reasonable amount of resources.
    • Avoid tiny pods that constantly OOM or huge pods that waste resources.
  • Step 2: Scale horizontally:
    • Use HPA or manual replica adjustments to handle varying load.

When vertical scaling is more appropriate:

  • Apps that must maintain strong session locality or in-memory state that does not easily shard.
  • Licensed software limited by number of instances or cores.
  • Workloads benefiting from high per-pod memory (e.g. large in-memory caches, some JVM apps).

When horizontal scaling is preferred:

  • Stateless microservices.
  • Web frontends where adding pods is cheap.
  • Workloads designed around distributed parallelism.

In some scenarios, you may need both:

  • Start with large-enough pods to be efficient.
  • Then use HPA to increase/decrease replica count.

Vertical Scaling Strategies and Best Practices

Start with requests, not limits

  • Requests drive scheduling and capacity planning.
  • Set requests to a reasonable baseline (e.g. 50–70% of typical usage).
  • Use limits to prevent extreme outliers, but keep them above normal peaks to reduce throttling.

Use data, not guesses

Base vertical scaling decisions on:

  • Historical metrics from OpenShift monitoring (CPU, memory).
  • OOM kill events and restart reasons.
  • Response time / throughput metrics when saturation is suspected.

Example steps:

  1. Observe pods running at >80% memory with occasional OOMKilled events.
  2. Increase memory request/limit by a small factor (e.g. +25–50%).
  3. Watch for stability over several peak cycles.

Beware of JVM and managed runtimes

Java, .NET, and other managed runtimes may:

  • Size their heap based on available memory, not just requests.
  • Hit limits and cause OutOfMemoryError if limits are too low.
  • Need tuning flags (e.g. heap size) aligned with container memory limits.

For these workloads, vertical scaling is tightly coupled with runtime tuning.

Plan for restarts

Changing pod resources typically implies recreating pods:

  • For stateless workloads with multiple replicas, this is usually fine.
  • For single-instance or stateful apps, plan:
    • Maintenance windows.
    • Readiness/liveness probes to ensure healthy rollouts.
    • Use of PodDisruptionBudget to limit concurrent disruptions.

Interactions with quotas and limits

Projects/namespaces may have:

  • ResourceQuotas that cap cumulative CPU/memory usage.
  • LimitRanges that define default and maximum requests/limits.

When vertically scaling:

  • Check that new pod sizes fit within quotas.
  • Ensure they do not exceed project-level max limits.
  • Coordinate with cluster administrators when higher resources are needed.

Typical Vertical Scaling Scenarios in OpenShift

Scenario 1: Single-pod legacy application

  • Old monolithic app, difficult to run multiple replicas safely.
  • Approach:
    • Start with conservative resources.
    • Increase memory/CPU stepwise while observing metrics.
    • Add a second replica only if the app can handle basic HA.

Scenario 2: Memory-heavy analytics job

  • Batch job using in-memory datasets.
  • Approach:
    • Request a large amount of memory per pod.
    • Use vertical scaling based on job success/failure and runtime.
    • Optionally combine with multiple pods if the algorithm supports partitioning.

Scenario 3: Bursty but low-concurrency workload

  • Internal tool used heavily in short bursts.
  • Horizontal scaling might not help much if concurrent sessions are limited.
  • Approach:
    • Provide more CPU per pod so bursts are absorbed quickly.
    • Possibly use vertical autoscaling to adapt between quiet and busy periods.

Summary

Vertical scaling in OpenShift focuses on changing pod size (CPU/memory) instead of pod count. It relies on careful configuration of requests and limits, observation of real resource usage, and understanding of scheduling and application behavior.

When used thoughtfully and often in combination with horizontal scaling, vertical scaling helps:

  • Avoid resource starvation and OOM kills.
  • Improve performance of workloads that cannot easily scale out.
  • Increase overall cluster efficiency by right-sizing workloads to their actual needs.

Views: 0

Comments

Please login to add a comment.

Don't have an account? Register now!

Where to Move

Move chapter:

  • ☰ 1. Course Overview
    • ☰ 1.1. What is OpenShift
      • ☰ 1.2. Why OpenShift is used in modern IT and cloud environments
        • ☰ 1.3. OpenShift vs Kubernetes
          • ☰ 1.4. Typical OpenShift use cases
            • ☰ 1.5. Structure and goals of the course
            • ☰ 2. Containers and Cloud-Native Fundamentals
              • ☰ 2.1. What is a container
                • ☰ 2.2. Containers vs virtual machines
                  • ☰ 2.3. Introduction to Docker and container images
                    • ☰ 2.4. Container registries
                      • ☰ 2.5. Basics of cloud-native applications
                      • ☰ 3. Kubernetes Fundamentals
                        • ☰ 3.1. What is Kubernetes
                          • ☰ 3.2. Kubernetes architecture
                            • ☰ 3.3. Control plane components
                              • ☰ 3.4. Worker node components
                                • ☰ 3.5. Kubernetes objects and resources
                                  • ☰ 3.6. Declarative configuration model
                                  • ☰ 4. OpenShift Architecture
                                    • ☰ 4.1. Overview of OpenShift architecture
                                      • ☰ 4.2. Control plane in OpenShift
                                        • ☰ 4.3. Nodes and machine roles
                                          • ☰ 4.4. OpenShift Operators
                                            • ☰ 4.5. OpenShift networking model
                                              • ☰ 4.6. OpenShift storage model
                                              • ☰ 5. OpenShift Installation and Deployment Models
                                                • ☰ 5.1. OpenShift deployment options
                                                  • ☰ 5.2. Installer-Provisioned Infrastructure
                                                    • ☰ 5.3. User-Provisioned Infrastructure
                                                      • ☰ 5.4. Managed OpenShift services
                                                        • ☰ 5.5. Single-node OpenShift
                                                          • ☰ 5.6. Cluster lifecycle management
                                                          • ☰ 6. Accessing and Using OpenShift
                                                            • ☰ 6.1. OpenShift web console
                                                              • ☰ 6.2. OpenShift CLI (oc)
                                                                • ☰ 6.3. Authentication and authorization
                                                                  • ☰ 6.4. Projects and namespaces
                                                                    • ☰ 6.5. Resource quotas and limits
                                                                    • ☰ 7. Building and Deploying Applications
                                                                      • ☰ 7.1. Application deployment concepts
                                                                        • ☰ 7.2. Source-to-Image (S2I)
                                                                          • ☰ 7.3. Container-based deployments
                                                                            • ☰ 7.4. DeploymentConfigs and Deployments
                                                                              • ☰ 7.5. Rolling updates and rollbacks
                                                                              • ☰ 8. Networking in OpenShift
                                                                                • ☰ 8.1. Services and service discovery
                                                                                  • ☰ 8.2. Routes and ingress
                                                                                    • ☰ 8.3. Network policies
                                                                                      • ☰ 8.4. Load balancing
                                                                                        • ☰ 8.5. External access to applications
                                                                                        • ☰ 9. Storage in OpenShift
                                                                                          • ☰ 9.1. Persistent storage concepts
                                                                                            • ☰ 9.2. Persistent Volumes
                                                                                              • ☰ 9.3. Persistent Volume Claims
                                                                                                • ☰ 9.4. StorageClasses
                                                                                                  • ☰ 9.5. Dynamic provisioning
                                                                                                    • ☰ 9.6. Stateful applications
                                                                                                    • ☰ 10. Configuration and Secrets Management
                                                                                                      • ☰ 10.1. ConfigMaps
                                                                                                        • ☰ 10.2. Secrets
                                                                                                          • ☰ 10.3. Environment variables
                                                                                                            • ☰ 10.4. Managing sensitive data
                                                                                                              • ☰ 10.5. Best practices for configuration
                                                                                                              • ☰ 11. Scaling and High Availability
                                                                                                                • ☰ 11.1. Horizontal pod autoscaling
                                                                                                                  • ☰ 11.2. Vertical scaling
                                                                                                                    • ☰ 11.3. Self-healing and pod restarts
                                                                                                                      • ☰ 11.4. High availability concepts
                                                                                                                        • ☰ 11.5. Multi-zone and multi-region clusters
                                                                                                                        • ☰ 12. Monitoring, Logging, and Observability
                                                                                                                          • ☰ 12.1. Built-in monitoring stack
                                                                                                                            • ☰ 12.2. Metrics and alerts
                                                                                                                              • ☰ 12.3. Logging architecture
                                                                                                                                • ☰ 12.4. Distributed tracing
                                                                                                                                  • ☰ 12.5. Troubleshooting applications
                                                                                                                                  • ☰ 13. Security in OpenShift
                                                                                                                                    • ☰ 13.1. Security model overview
                                                                                                                                      • ☰ 13.2. Role-Based Access Control
                                                                                                                                        • ☰ 13.3. Security Context Constraints
                                                                                                                                          • ☰ 13.4. Image security and scanning
                                                                                                                                            • ☰ 13.5. Network security
                                                                                                                                              • ☰ 13.6. Compliance and auditing
                                                                                                                                              • ☰ 14. CI/CD and DevOps with OpenShift
                                                                                                                                                • ☰ 14.1. DevOps concepts
                                                                                                                                                  • ☰ 14.2. CI/CD pipelines overview
                                                                                                                                                    • ☰ 14.3. OpenShift Pipelines (Tekton)
                                                                                                                                                      • ☰ 14.4. GitOps with Argo CD
                                                                                                                                                        • ☰ 14.5. Integrating OpenShift with external CI tools
                                                                                                                                                        • ☰ 15. Operators and Platform Services
                                                                                                                                                          • ☰ 15.1. What are Operators
                                                                                                                                                            • ☰ 15.2. Operator Lifecycle Manager
                                                                                                                                                              • ☰ 15.3. Installing and managing Operators
                                                                                                                                                                • ☰ 15.4. Common platform Operators
                                                                                                                                                                  • ☰ 15.5. Custom Operators
                                                                                                                                                                  • ☰ 16. Upgrades, Maintenance, and Operations
                                                                                                                                                                    • ☰ 16.1. OpenShift upgrade process
                                                                                                                                                                      • ☰ 16.2. Backup and restore
                                                                                                                                                                        • ☰ 16.3. Node maintenance
                                                                                                                                                                          • ☰ 16.4. Cluster troubleshooting
                                                                                                                                                                            • ☰ 16.5. Capacity planning
                                                                                                                                                                            • ☰ 17. OpenShift on HPC and Specialized Workloads
                                                                                                                                                                              • ☰ 17.1. Running batch workloads on OpenShift
                                                                                                                                                                                • ☰ 17.2. OpenShift and GPUs
                                                                                                                                                                                  • ☰ 17.3. MPI and parallel workloads in containers
                                                                                                                                                                                    • ☰ 17.4. Hybrid HPC and cloud workflows
                                                                                                                                                                                    • ☰ 18. OpenShift in Practice
                                                                                                                                                                                      • ☰ 18.1. Typical OpenShift workflows
                                                                                                                                                                                        • ☰ 18.2. Development to production lifecycle
                                                                                                                                                                                          • ☰ 18.3. Case studies from industry
                                                                                                                                                                                            • ☰ 18.4. Common pitfalls and best practices
                                                                                                                                                                                            • ☰ 19. Future Directions and Ecosystem
                                                                                                                                                                                              • ☰ 19.1. Kubernetes ecosystem overview
                                                                                                                                                                                                • ☰ 19.2. OpenShift roadmap
                                                                                                                                                                                                  • ☰ 19.3. Serverless and event-driven workloads
                                                                                                                                                                                                    • ☰ 19.4. AI and data platforms on OpenShift
                                                                                                                                                                                                    • ☰ 20. Final Project and Hands-On Exercises
                                                                                                                                                                                                      • ☰ 20.1. Deploying a containerized application
                                                                                                                                                                                                        • ☰ 20.2. Implementing CI/CD with OpenShift
                                                                                                                                                                                                          • ☰ 20.3. Securing and scaling an application
                                                                                                                                                                                                            • ☰ 20.4. Monitoring and troubleshooting report