July 28, 2021

Vertical Scaling and Horizontal Scaling

    Scaling an on-premise infrastructure is hard. You need to plan for peak capacity, wait for equipment to arrive, configure the hardware and software, and hope you get everything right the first time. But deploying your application in the cloud can address these headaches.


    Vertical scaling means that you scale by adding more power (CPU, RAM) to an existing machine. AWS provides instances up to 488 GB of RAM or 128 virtual cores.


    Horizontal scaling essentially involves adding machines in the pool of existing resources. When users grow up to 1000 or more, vertical scaling can’t handle requests and horizontal scaling is required. Horizontal scalability can be achieved with the help of clustering, distributed file system, and load balancing.


Example for horizontal scaling:


{{- if ne <value_check> "\"false\"" -}}

{{- if <value_check }}

apiVersion: autoscaling/v2beta1

kind: HorizontalPodAutoscaler

metadata:

  name: xxxx

spec:

  scaleTargetRef:

    apiVersion: apps/v1

    kind: Deployment

    name: xxxx

  minReplicas: 1 <replica_count>

  maxReplicas: 10 <max_replicas>

  metrics:

  - type: Resource

    resource:

      name: cpu

      targetAverageUtilization: 90

  - type: Resource

    resource:

      name: memory

      targetAverageUtilization: 90

{{- end }}

{{- end }}



Example for vertical scalling:


apiVersion: v1

kind: Pod

metadata:

  name: xxx-demo

  namespace: xxx-example

spec:

  containers:

  - name: xxx

    image: vish/stress

    resources:

      limits:

        memory: "2Gi"

        cpu: "2"

      requests:

        memory: "1.5Gi"

        cpu: "1.5"

    args:

    - -cpus

    - "2"


Reference:

https://devblog.axway.com/apis/helm-and-kubernetes-adoption/

https://github.com/ramanujadasu/apigw-helm-charts

https://dzone.com/articles/vertical-scaling-and-horizontal-scaling-in-aws

https://stackoverflow.com/questions/11707879/difference-between-scaling-horizontally-and-vertically-for-databases

https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/

AWS Code optimization techniques:

https://www.whizlabs.com/blog/aws-cost-optimization-best-practices/




No comments:

Post a Comment

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

My Favorite Site's List

#update below script more than 500 posts