Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 14: EC2 Operations — Elastic IP, AMI, Snapshots and Vertical Scaling

AWS Cloud

14.4 Vertical scaling: changing the instance type

Scale up vs scale out

Friends, first measure what is limiting the application. For a compatible EBS-backed instance, an approved in-place change follows stop, change type and start. Verify the service after it comes back.

Vertical scaling (scale up/down) Horizontal scaling (scale out/in)
What Make one server bigger/smaller (more vCPU/RAM) Add or remove workers that can share the workload
AWS way Change instance type (e.g. t3.micro → t3.medium) Auto Scaling group (ASG) behind an Elastic Load Balancer (ELB)
Downtime Yes — stop/start needed Can stay available when healthy capacity and request draining are maintained
Limit Largest instance size available Limited by quotas, capacity and downstream bottlenecks
Best for Single servers, databases, quick fixes, labs Stateless web/app tiers, high availability, variable traffic

Think of a busy dosa stall: vertical scaling is buying a bigger tawa for the same cook; horizontal scaling is opening two more counters with more cooks. A compatible EBS-backed type change adjusts one host’s capacity. Scaling out lets several suitable instances share work when the deployment supports it.

Steps to change the instance type

On an approved standalone EBS-backed lab, collect the intended instance, current type, resource measurements and required data before choosing a compatible target. Confirm access and recovery before any interruption.

  1. Stop the intended instance and wait for the stopped state.
  2. Change the compatible instance type and check the selected settings.
  3. Start the instance and verify EC2 status, guest resources, actual network endpoint, data mount and an application response.
  4. Repeat the same workload and compare correctness, errors and timing. Use the documented reversal if the approved criteria fail.

The expanded lesson shows the scoped CLI sequence and a local rehearsal that uses fabricated observations.

What changes and what stays

Check after an ordinary compatible in-place changeExpected scope
Capacity and rateThe target changes the effective resources, limits and compute price according to its exact settings.
Instance and storage identityVerify the same instance ID, network interfaces and attached EBS volumes.
Public client pathA retained Elastic IP can keep its value. An automatically assigned public IPv4 can change during stop/start.
Transient stateOrdinary stop loses data on instance store and ends running connections and memory state.

Compatibility cautions

  • Architecture must match: an x86_64 instance (t3, m7i) cannot simply become an Arm/Graviton type (t4g, m7g). The AMI/OS is compiled for one architecture — for Graviton, launch a new instance from an arm64 AMI and migrate.
  • Guest drivers and mounts: verify the required network and storage drivers for the selected platform. A move to Nitro can change guest storage device naming. Check the actual identified volume and mounting policy before starting.
  • Availability: verify the type is offered in the existing AZ. An offering does not guarantee available start capacity during the change.
  • Other features: check maximum EBS attachments, network and boot support, applicable instance settings and any Auto Scaling ownership before stopping.
  • Downtime: plan the full stop, start and verified recovery window. Include a fallback if the selected type or app does not become ready.

Free tier caution

Free Tier eligibility depends on account creation date, active plan, usage and published rules. Some newer eligible account plans list t3.small. Check current EC2 Free Tier details and the account’s actual credits and associated charges before selecting a target.

Ravindra Bagale's Tip

Compare application timings with CPU, guest memory and storage delay during the same workload. Check burstable credit mode when it applies. Select a compatible size and verify the actual data and performance rather than changing by family name alone.

Lab

खालील offline lab मध्ये before आणि after चे एकाच workload चे परिणाम तपासा. आधी compatible type, योग्य mount आणि app data पाहा. मग p95 आणि errors तुलना करा. Real EC2 resize साठी स्वतंत्र lab आणि recovery plan वापरा.

Measure the slow work before choosing a larger server

At 09:00 the warehouse staff open their inventory dashboard. Some requests finish quickly and others take nearly half a second. A teammate suggests selecting an EC2 type with more CPU. Before reserving a maintenance window, determine what the requests are waiting for. The application could be competing for memory, waiting on a database query, or running one CPU-bound worker. Changing the processor count would affect those cases differently. A slower experience is a useful observation. It is not by itself a diagnosis of instance capacity.

An EC2 instance type is a bundle of compute and platform characteristics, including virtual CPUs, memory and limits or capabilities relevant to networking and storage. A virtual CPU is the processing capacity the guest operating system sees in its virtual machine. Vertical scaling means changing the capacity of one instance or replacing it with a differently sized instance. Scaling up increases an appropriate capacity, and scaling down reduces it after you verify the service can still handle its workload. A different family can have a different balance of resources. Compare the precise capabilities your application will rely on, including storage and network performance.

Horizontal scaling adds appropriately configured instances and lets a larger set share work. It requires a design that directs the work and handles connection state, shared files, sessions or database limits. An Auto Scaling group and a load balancer can be part of that design. Horizontal scaling is not automatic protection against a database bottleneck or a substitute for maintaining healthy target availability. Workload shape and state ownership determine whether one better-sized host or several workers will help. The current lesson focuses on planning a compatible in-place change to a single EBS-backed instance.

Assume the staff needs at least nineteen out of twenty representative dashboard reads to finish within 300 milliseconds in the practice test, with a valid response from each. Record the workload, application release and data size. Test the same request mix before and after the change. In production, use a repeatable time window, sufficient sample size and representative concurrency. Avoid comparing a quiet minute after the change with a busy peak before it. The exercise uses fabricated observations to teach those evidence choices without generating traffic against a hosted service.

Connect resource signals to application behavior

Start with the user's outcome, such as latency, completed work and error rate. Then compare resource use during the same period. High ongoing CPU can mean the application has runnable work waiting for processor time. Memory pressure can appear through small available memory, increased reclaim or swapping, and processes being killed due to insufficient usable memory. Storage delay can appear as longer I/O latency or queueing when a volume or instance limit is reached. An external database pause can leave application CPU mostly idle while request time increases. Categorize your evidence by the actual dependency involved.

ObservationEvidence to comparePossible experiment
High CPU during repeated busy intervalsPer-process and per-core use, throughput, app delay and credit mode if applicableTest whether more compute or adjusted concurrency improves the same work
Low available memory and increasing swap activityGuest memory metrics, process footprint and performance during those same intervalsTry an appropriate memory size or address unexpected memory growth
Requests wait on storageVolume type and provisioning, observed latency and I/O queue, host EBS limitsTest the actual storage or instance constraint without changing unrelated settings
Low resource use with high backend request timeApplication trace, database response or network delayInvestigate the shared dependency before assuming another application CPU helps

EC2 publishes standard CloudWatch instance metrics such as CPU utilization, with documented behavior for monitoring periods and selected types. Guest memory and operating system filesystem details normally require a configured agent or another guest telemetry method. Compare like with like. A missing time series for available memory doesn't prove that there is plenty. On an authorized Linux lab, free -h helps inspect memory including the available estimate, while nproc reports processors available to the calling process. Operating system controls can affect what a process can use. Compare guest values with the actual instance type and service settings.

A burstable instance has a baseline and CPU credits. Credits allow CPU use above the baseline according to the instance's rules and configured mode. Compare the actual credit balance and mode with sustained workload. When an eligible instance uses Standard mode and its supply is exhausted, its CPU capacity changes according to the baseline behavior. Unlimited can allow further sustained activity with possible surplus credit charges under the documented pricing conditions. Do not assume every T-family latency problem is credit exhaustion or that changing the family is always the right fix. Review the metrics and actual goal.

Take the class fixture: CPU remains near 35 percent while available memory drops into a small range and swap activity increases during the slow period. The two types chosen for illustration could have the same virtual CPU count but different memory and other characteristics. More memory is a hypothesis worth testing. Don't claim the change isolates only one physical property. Compare memory signals, the workload and application outcomes afterward, and keep outside changes small during the measurement. If network or database time dominates, extra memory may change little.

One measure you will compute is the 95th percentile for response times. In the exercise, use the nearest-rank method: sort twenty successful measurements and look at the nineteenth. Selecting the nineteenth does not hide the need to account for errors or an extreme last sample. In a real service choose percentile tooling and sample size appropriate to the request distribution. Record which method and traffic window you used. A faster median can coexist with worse latency for the slowest ordinary requests.

Check whether the existing instance can use the proposed type

Find the current instance, root volume type, system architecture, virtualization mode, active boot mode and required platform features. In the compatible in-place change procedure EC2 supports changing an instance with an EBS root volume when the current configuration and selected type are compatible. If the instance cannot use that type, use an appropriate migration route. An instance-store-backed root or a switch between x86_64 and arm64 requires a different plan. The application also needs compatible native dependencies when you create a new image for another architecture. A larger memory number in a catalog says nothing about those compatibility checks.

Check that the target has the networking and storage capabilities the operating system needs. A move to some Nitro-based types can require the appropriate ENA network and NVMe storage drivers. The guest device names may differ from older types. Check how the app's filesystems are identified and mounted. A hard-coded enumerated disk path can refer to the wrong device after startup. Newer vendor images commonly include supported drivers according to their release; verify the actual guest instead of assuming a label guarantees it. ENIs, storage support, placement constraints, hibernation settings or other features can restrict particular in-place changes.

Ask whether the type is offered in the instance's current AZ and account environment. An offering says the type is listed for that location. Available placement capacity at the actual start can still vary. Choose a recovery path in case the planned type does not start or the original type cannot immediately be obtained again. Consider how the service would route around the interruption if other healthy capacity exists. The console list and read-only descriptions help establish the available options. They cannot guarantee a successful launch at a future time.

A cross-architecture move is an example of a replacement rather than that in-place workflow. If the app currently runs x86-64 native packages, build and validate a suitable arm64 AMI and application distribution for the intended type. Move the app and intended data separately using approved procedures. Run a representative test on the candidate before switching any customer endpoint. The AMI lesson's separate architecture, boot and data checks are useful inputs to that decision.

Plan the stop, type change, start and return of service

Begin with an approved scope and a realistic maintenance window. Record the exact instance ID and Region, old type and intended target, relevant network attachment, volume IDs, application release, current endpoint and expected data. Save or verify an appropriate recovery point for the data you actually need. Copy any required instance store data into persistent storage before stopping. Instance store is storage tied to supported underlying hosts and its data is lost on an ordinary stop. RAM and active connections are also affected by shutdown. Plan a real application restart, rather than assuming all runtime state stays in memory.

If the instance is managed by an Auto Scaling group, a stopped instance may be marked unhealthy and could be terminated and replaced by the group. Use the fleet's appropriate supported maintenance or replacement procedure. Changing just one running member would not update the launch template or combined fleet settings. Where customers must stay served, prepare healthy remaining capacity, drain the target and verify the fleet health before and after the change. The console recipe here is for a compatible standalone EBS-backed instance with an accepted interruption. It is not a generic fleet rollout recipe.

Read-only AWS CLI examples help collect the target facts before a live maintenance decision. Substitute only the identifiers from the approved test run. Record the exact instance description and match the proposed type's supported architecture, boot mode, root storage and device limits. Query the offering for the existing AZ, not merely any location in the Region. These commands make observations and do not establish a reservation of target capacity.

aws --profile "$lab_profile" --region "$lab_region" ec2 describe-instances \
  --instance-ids "$lab_instance" --output json --no-cli-pager
aws --profile "$lab_profile" --region "$lab_region" ec2 describe-instance-types \
  --instance-types "$target_type" --output json --no-cli-pager
aws --profile "$lab_profile" --region "$lab_region" ec2 describe-instance-type-offerings \
  --location-type availability-zone \
  --filters "Name=location,Values=$instance_az" "Name=instance-type,Values=$target_type" \
  --output json --no-cli-pager
  1. Prepare the running service. Check recovery and access paths while it is still reachable. Quiesce planned writes and drain known traffic where applicable. Confirm your operator can return even if a public address changes.
  2. Stop the chosen instance. Use the intended EC2 action and allow the normal guest shutdown attempt. Wait for the management state to become stopped before changing the type. Investigate an unexpected failure instead of immediately switching to a forced stop.
  3. Modify the stopped instance. In the EC2 instance settings, choose the compatible, previously reviewed type. Confirm the operation selects the same instance and check the resulting type and CPU options before starting.
  4. Start and revalidate the host. Wait for running and the relevant status checks, verify guest resource visibility and mounts, then reconnect using the intended current address or managed access.
  5. Prove the application and workload. Check the appropriate process, listener and real data route. Repeat the same workload and compare the service objective. Note when normal availability returned.

In an ordinary compatible in-place type change, the EC2 instance keeps its ID and EBS volumes. The attached network interfaces and private addresses normally remain. A retained Elastic IP can keep the public IPv4 address stable. A different automatically assigned public IPv4 is possible after stop/start under the documented address conditions. Check what actually happened and ensure the intended DNS or access path uses the right value. Compare the expected boot and EBS attachments separately from the networking evidence. An HTTPS application with an unchanged address still has to start and serve requests.

The operation changes capacity and may shift network or storage performance, maximum attachments, burst behavior and pricing. Read the specifications for the exact source and target. Preserve the old capacity options you would need for rollback. If the larger instance becomes unhealthy, a valid reversal for the compatible standalone case involves another deliberate stop, restoring the old type and starting again. Confirm the original type is still available and that any intervening application state is safe. Rollback can also require recovering network access, data or startup configuration. Set a clear time or evidence limit before provoking unnecessary repeated interruptions.

Prove the resize improved useful service, not just the instance label

Think of a record with four separate results. The EC2 result says the existing instance is running as the target type. The operating system result shows the expected resources and mount points. The application result shows the intended version and correct response for a known test record. The workload result says that during the planned comparison the response time and errors met their objective. Any one of the earlier results can pass while a later one fails. This is why the runbook needs gates for both readiness and performance.

Take the first possible failure after starting. The new type appears correctly in the console, and guest memory is higher. The inventory request still fails because the expected data mount never appeared. Recording the type change as complete leaves customers with an unusable service. Check the identified guest device and app logs. If boot or connectivity itself fails, use the approved recovery access, stored evidence and rollback choice. The snapshot lesson describes a separate restored-volume inspection if data recovery is needed.

Now take another result. The app and its data reply correctly, but speed has not improved. Compare the workload mix, cache warmth and downstream response times. A fast lightweight health route does not test the slow workload. If a process uses only one thread for this operation, adding many virtual processors can leave its own time mostly unchanged. If the evidence points to a database query or I/O bottleneck, use a separate change to address it. Preserve the before and after results so the team learns which capacity hypothesis actually failed.

Finally, confirm the price and target for the length of time the change will be used. The new instance type carries its own rate subject to the applicable AWS plan, discounts and credit terms. EC2 Free Tier and credit eligibility varies by account creation date, selected plan, usage and current published rules. Check the actual account rather than assuming that a named type is always free or always outside the program. Include relevant storage, public IPv4 and optional burst charges where applicable. Select a deliberate return or retention condition for a lab resize.

Lab: judge a resize with comparable workload evidence

Use Python 3 and Bash. This offline rehearsal uses fabricated measurements and selected compatibility fields, and performs no cloud operations. The plan presents two test windows of twenty reads of the same inventory route. The baseline and candidate use the same application release, record, dataset revision and offered traffic. In the class example the t3.micro and t3.small entries model an increase in memory while both retain two default virtual CPUs. Check current published type capabilities for any real plan. The code judges a narrow named case and doesn't stand in for AWS eligibility and placement checks.

Step 1. Create the scope, symptoms and before-and-after observations

set -eu
command -v python3 >/dev/null
umask 077
resize_lab=$(mktemp -d /tmp/rb-ec2-resize.XXXXXX)
cleanup_resize() {
  case "$resize_lab" in
    /tmp/rb-ec2-resize.??????) rm -rf -- "$resize_lab" ;;
  esac
}
trap cleanup_resize EXIT
cat > "$resize_lab/observations.json" <<'JSON'
{
  "expected_instance": "i-00000000000001614",
  "availability_zone": "ap-south-1a",
  "old_type": "t3.micro",
  "target_type": "t3.small",
  "required_release": "inventory-4.2",
  "required_stock": 8,
  "latency_target_ms": 300,
  "root": "ebs",
  "image_architecture": "x86_64",
  "selected_architectures": ["x86_64"],
  "location_offered": true,
  "standalone": true,
  "platform_reviewed": true,
  "before": {
    "instance": "i-00000000000001614",
    "type": "t3.micro",
    "availability_zone": "ap-south-1a",
    "state": "running",
    "mount_verified": true,
    "route": "/inventory/A-17",
    "load": "inventory-20-concurrency-4",
    "dataset": "warehouse-fixture-12",
    "release": "inventory-4.2",
    "stock": 8,
    "request_errors": 0,
    "cpu_pct": 35,
    "available_mem_mib": 95,
    "swap_growth_mib": 40,
    "latency_ms": [210,230,240,245,260,270,280,300,315,320,330,340,350,360,390,410,420,450,470,520]
  },
  "after": {
    "instance": "i-00000000000001614",
    "type": "t3.small",
    "availability_zone": "ap-south-1a",
    "state": "running",
    "mount_verified": true,
    "route": "/inventory/A-17",
    "load": "inventory-20-concurrency-4",
    "dataset": "warehouse-fixture-12",
    "release": "inventory-4.2",
    "stock": 8,
    "request_errors": 0,
    "cpu_pct": 31,
    "available_mem_mib": 570,
    "swap_growth_mib": 0,
    "latency_ms": [115,120,125,130,136,140,148,154,158,161,172,176,183,194,210,221,230,239,245,360]
  }
}
JSON

Read the baseline values aloud. Low measured available memory and growing swap accompany slow tail responses while average CPU is far from its maximum. These observations warrant testing memory pressure as a contributing issue. They don't indicate what every process waited for. The candidate profile records the same app and data path because changing all of them at once would weaken the comparison. A string label declares the selected offered mix and concurrency. In a real test, record the actual test configuration, accepted requests and measured window.

Step 2. Reject an incompatible plan and validate the real acceptance conditions

cat > "$resize_lab/judge.py" <<'PY'
from math import ceil
from pathlib import Path
import json
import sys

plan = json.loads(Path(sys.argv[1]).read_text())
before, after = plan["before"], plan["after"]

def require(ok, reason):
    if not ok:
        raise ValueError(reason)

def check_possible(candidate):
    require(candidate["root"] == "ebs", "requires EBS-backed root for this workflow")
    require(candidate["image_architecture"] in candidate["selected_architectures"],
            "processor architecture mismatch")
    require(candidate["location_offered"], "selected type not offered in this AZ")
    require(candidate["standalone"], "requires a separate fleet maintenance plan")
    require(candidate["platform_reviewed"], "platform evidence incomplete")

def percentile_95(samples):
    require(len(samples) == 20 and all(value > 0 for value in samples), "invalid request sample")
    ordered = sorted(samples)
    return ordered[ceil(0.95 * len(ordered)) - 1]

def accept(result):
    require(result["instance"] == plan["expected_instance"] and
            result["availability_zone"] == plan["availability_zone"] and
            result["state"] == "running" and result["type"] == plan["target_type"],
            "unexpected instance state or type")
    require(result["mount_verified"], "data mount not verified")
    for field in ("route", "load", "dataset"):
        require(result[field] == before[field], "workload evidence not comparable")
    require(result["release"] == plan["required_release"] and
            type(result["stock"]) is int and result["stock"] == plan["required_stock"],
            "application record mismatch")
    require(result["request_errors"] == 0, "request errors exceeded target")
    measured = percentile_95(result["latency_ms"])
    require(measured <= plan["latency_target_ms"], "latency target not met")
    return measured

def reject(check, expected):
    try:
        check()
    except ValueError as error:
        require(str(error) == expected, f"wrong rejection: {error}")
        print("Rejected:", error)
    else:
        raise AssertionError("unexpected acceptance")

require(before["type"] == plan["old_type"], "invalid baseline type")
check_possible(plan)
reject(lambda: check_possible({**plan, "selected_architectures": ["arm64"]}),
       "processor architecture mismatch")
reject(lambda: check_possible({**plan, "location_offered": False}),
       "selected type not offered in this AZ")
reject(lambda: check_possible({**plan, "standalone": False}),
       "requires a separate fleet maintenance plan")
print(f"Baseline p95: {percentile_95(before['latency_ms'])} ms.")
reject(lambda: accept({**after, "load": "quiet-check"}), "workload evidence not comparable")
reject(lambda: accept({**after, "stock": 0}), "application record mismatch")
reject(lambda: accept({**after, "mount_verified": False}), "data mount not verified")
reject(lambda: accept({**after, "latency_ms": before["latency_ms"]}), "latency target not met")
print(f"Accepted candidate p95: {accept(after)} ms.")
print(f"Available memory: {before['available_mem_mib']} to {after['available_mem_mib']} MiB.")
PY
python3 "$resize_lab/judge.py" "$resize_lab/observations.json"

The baseline p95 is 470 milliseconds by the exercise's nearest-rank rule. The candidate p95 is 245 milliseconds. It meets the 300-millisecond objective despite one measurement at 360 milliseconds. The exercise separately requires zero request errors, so reporting a percentile alone cannot hide failures. Replaying the baseline delays after the change would fail the target even if you selected the correct larger type. Changing the workload label to a quieter test rejects the comparison before interpreting the lower times.

Find the case with correct instance state and wrong data. The script checks the candidate's exact live identity, type, environment assumptions and data path before it accepts performance. It also rejects a theoretically faster Arm instance for this x86 image. In a cloud environment you would collect true results rather than substituting sample values. Compare what was observed with the intended plan, preserving original measurement details. A low 95th percentile for responses containing the wrong data is still a failure for this app.

Step 3. Remove the sample records

cleanup_resize
trap - EXIT
test ! -e "$resize_lab"
printf 'Local resize rehearsal files removed.\n'

Only the local scratch directory is removed. If you separately make an approved change to a disposable AWS instance, check which type actually remains, how long you will keep it, and what other resources still incur charges. Any rollback or cleanup of an AWS test machine uses the correct recorded account, instance ID and named resources. This script gives you a set of tests to think through. It does not modify the EC2 state.

Map the AWS commands to the evidence you need at each stage

The shell commands below describe the documented method for a specifically authorized disposable standalone EC2 lab. They will change that EC2 instance if you set the variables and run them. Keep them separate from the offline exercise. Identify its account and Region, compare the exact instance ID against the lab inventory, confirm recovery and approved interruption, and run the commands one stage at a time. Read the result of each before running the next. A finished update plan includes the actual state observed on the target, not just a record of commands sent.

# Authorized cloud lab only, after its pre-change checks
aws --profile "$lab_profile" --region "$lab_region" ec2 stop-instances \
  --instance-ids "$lab_instance"
aws --profile "$lab_profile" --region "$lab_region" ec2 wait instance-stopped \
  --instance-ids "$lab_instance"
aws --profile "$lab_profile" --region "$lab_region" ec2 modify-instance-attribute \
  --instance-id "$lab_instance" --instance-type "Value=$target_type"

# Start only after confirming this instance and type
aws --profile "$lab_profile" --region "$lab_region" ec2 start-instances \
  --instance-ids "$lab_instance"
aws --profile "$lab_profile" --region "$lab_region" ec2 wait instance-running \
  --instance-ids "$lab_instance"
aws --profile "$lab_profile" --region "$lab_region" ec2 describe-instance-status \
  --instance-ids "$lab_instance" --include-all-instances --output json --no-cli-pager

A waiter checks a service condition repeatedly and completes when its expected condition is observed, or returns an error when it cannot finish. If a waiter or type-change call fails, describe the current instance to learn what actually happened. A request problem can leave the instance in a different state than you expected. Avoid blindly replaying stop and start from the beginning. If you change type but don't start, the stopped management state and new type do not imply the guest has booted or received new resources.

Use a guest-size reading as supporting evidence after startup. For example, after a compatible t3.micro to t3.small exercise the default virtual CPU count could still be two, while the selected memory size is larger. Read the actual type and CPU options as well as nproc, and compare the memory estimate on an authorized Linux shell. EC2 can preserve supported CPU options during a type change or revert to target defaults if they aren't supported. A process can also be limited by the operating system independently of the instance's default. A familiar command returning the same value is informative only after you consider which resource was meant to change.

Keep the last step focused on the real application. If the process manager reports an active service while the site's request fails, inspect its current listener, mounted data and configured endpoint. If the route replies successfully with the old dataset, figure out which environment it uses before measuring speed. After application readiness, repeat the load with the same planned demand, verify all required errors and timings, and connect the result to the final sizing decision. Save both original and resulting observations in the maintenance record.

For rollback retain the original type, activation plan and intended access method before you execute the change. You may have to apply the same supported in-place sequence in the other direction, which causes another interruption. If you approved a separate recovery instance as an alternative, record the compatible image and launch settings required to use it. Returning one setting does not guarantee the fleet assignment or application data has returned. Check the same data-backed outcome and the correct route again before closing the maintenance window.

Keep a comparable record when the result is mixed

Suppose the first candidate has no errors and a p95 of 245 milliseconds, as in the sample, but one request needs 360 milliseconds. The planned percentile target passes. If the business also requires every accepted read within 300 milliseconds, this exact output would fail that different requirement. Record both results and the agreed objective, rather than quietly changing the success rule after measuring. Similarly, decide whether to count startup and cache warm-up periods as part of a recovery measurement or a steady-load comparison. The former helps describe availability during the maintenance, while the latter describes capacity after readiness.

A useful report gives the time window, sample size, distribution method and precise app release as well as the size change. Keep observations for the workload whose users actually reported slow behavior. If the target runs quickly for reads and slows for an important write or batch job, explain that split and investigate the path separately. An averaged metric across both actions can hide which operation improved. The sample's twenty reads are deliberately simple. A real acceptance exercise should include whichever duration, error budget and concurrency the service owners require.

Compare situations where different capacity choices win

Consider four observation sets from the same warehouse service. The first resembles the class exercise: requests slow during a known rush, guest available memory falls to about 95 MiB, and the process moves pages in and out of swap. During an otherwise comparable test the candidate shows 570 MiB available and no observed swap growth, and the slow requests improve. That is useful evidence for a memory-size decision. It does not prove the application uses memory efficiently. If you see growth each hour even when traffic stays constant, investigate whether retained data or a leak eventually consumes any larger limit too. Sizing and correcting the app can both be appropriate actions.

In another incident, the machine reports roughly half CPU use for two virtual processors. One worker is running a long serial calculation and fills one processor while the other has spare time. Those work rates can average to roughly fifty percent across the instance. Increasing the count of available CPUs might help more independent worker tasks proceed together. It may leave the time for one serial calculation mostly unchanged. Collect per-process or per-core evidence and check how much of the user's time lies in that single job. Then choose a candidate that matches parallelism, per-core capability or algorithmic work as appropriate.

A third team has an almost full data filesystem. The storage size does not ordinarily grow just because you change the instance type. Review the existing EBS volume and filesystem requirements. For a supported setup the Elastic Volumes modification process can increase volume size or change performance settings independently, and the guest may need a partition or filesystem extension before the new space is useful. That is its own change with prerequisites and impact. Similarly, increasing provisioned volume performance will not overcome every instance-side cap. Compare both sides of the I/O path. Confirm exactly which metric changed rather than presuming a faster-looking instance family rewrites the storage resource.

The fourth case has a read API waiting on its database during short bursts. The application doesn't use much of its own CPU or memory. More independent app servers can accept additional work and may place still more pressure on the same database. Trace and measure the actual downstream operation before selecting either vertical or horizontal scaling. A query improvement, appropriate caching, a better data design or supported reader capacity may help a different part of the bottleneck, depending on consistency and traffic. This chapter's key decision is asking which resource has to do more work and whether the change actually provides it.

Scale down decisions deserve the same discipline. A server may currently have unneeded headroom because seasonal traffic ended. Measure a representative window and keep enough spare capacity for the demand and failures your service must handle. A smaller instance could support the typical load but miss the first morning rush or increase CPU burst charges. An approved test should exercise expected load, correctness and operational readiness before carrying out that change on a user-facing system. Record what would cause you to restore the earlier size.

Interpret startup and access failures at the correct layer

What you observeUseful next evidenceWhat decision it informs
Target type is missing or rejectedCurrent root, CPU architecture, boot and features, and target offering in the AZSelect a supported in-place option or design a compatible new instance
Target listed but start failsActual EC2 error, AZ capacity and attached resource constraintsUse the planned rollback or another reviewed destination
Instance running but access to the old address failsCurrent address, DNS, ENIs, access method and guest network evidenceRe-establish intended access without assuming the capacity change failed
SSH works but application data is missingEffective mounts, data endpoint, credentials and service logsValidate the intended state before accepting the change
Correct app result but timings unknownA repeated traffic window with the same workload and acceptance criteriaDetermine whether the size change meets the service objective

Here is a common false conclusion. Before stop, the server used an auto-assigned public IPv4. After start, the operator opens their old SSH profile and gets a timeout. The console shows the intended instance is running. First verify whether the assigned public address is different and whether the chosen access path should use it. A static Elastic IP or a planned managed access method can remove one dependency on the automatically assigned value. Also check any network and firewall controls for the real path. Do not broadly change access rules to make an old host address appear to work. The previous Elastic IP lesson explains which association and external response confirm the intended endpoint.

Another possible failure happens after the machine reaches the current address. The data holding yesterday's orders was on temporary storage. The EBS root is still there, but data on instance store was lost during stop. A sizing rollback cannot recreate lost temporary data. The recovery plan should identify that before the operation and put any required data somewhere durable with an appropriate backup. A similar issue arises if a mount points at an empty directory on the root filesystem before the data disk is attached or mounted. Verify expected devices and actual mounted paths when the new capacity is up.

For a type that can boot with very old drivers but fails a network interface check, choose the approved recovery path. Some compatibility work can be performed before shutdown under the documented OS procedure. An authorized separate candidate launch may make it easier to test drivers and initialization without disturbing the running host. Document which image architecture and virtualization the candidate uses. If you return to the original type, keep track of any guest settings changed during troubleshooting, since capacity reversal will not automatically reverse an edit you made to the operating system.

For a fleet, a measured transition can change a launch template and replace members under controlled availability settings. That is different from manually stopping the only healthy member. Consider the maximum acceptable disruption, health checks and app readiness in that workflow. A stopped instance can trigger replacement behavior if the fleet still treats it as an active member. The lesson's in-place scenario deliberately assumes a named standalone instance. The processing and data metrics remain valuable no matter how a fleet promotes a different type.

Record the price window, success condition and rollback cost

Compare cost over the time the selected size is expected to run. In a fictional practice estimate, eight hours at two accounting units per hour are sixteen units. Eight hours at three units are twenty-four. If you also retain a recovery volume during the maintenance, account for it separately under the relevant storage rates. These figures illustrate the arithmetic rather than published AWS prices. A larger server that has higher hourly cost may finish a job sooner, or it may run all day with unused capacity. Estimate the evaluated workload and effective configuration.

When choosing a burstable type, compare its actual baseline and mode in the context of the app. CPU rates and memory sizes can change at the same time when you resize. In a real report distinguish compute cost, any provisioned EBS performance changes, billed public address, snapshots and other retained resources. A stopped instance can still leave resources that incur charges. Check the current plan rather than assuming the instance type's free-eligible label applies to every part of the environment. The approved trial should include a clear owner and finish condition.

Rollback can require a second interruption and a capacity choice. State what will trigger it: for example, failure to open the correct data route by the end of an allotted readiness window, or performance below the agreed target on a controlled comparison with no approved fix. Verify which size and configuration to return to, and what to do if it cannot start immediately. Recheck the new access path, status and records after reversal. A sizing experiment can fail safely and still be useful if it leaves clear evidence about the capacity hypothesis and restores service.

Check your sizing decision from the user's point of view

Interview questions

What is vertical scaling in this EC2 lesson?

It changes the capacity of one workload host. For a compatible EBS-backed standalone instance, stop it, select the supported type and start it. Verify the actual type, guest resources, data and application result. The action requires a maintenance window or alternate healthy service if the app must remain available.

Why can an x86_64 EC2 instance fail a planned move to a Graviton type?

The image and native software require the processor architecture they were built for. A compatible in-place move keeps to supported architecture and other platform choices. Prepare and validate a separate supported arm64 instance and data migration if changing architecture.

What would be your first checks for a slow app with low instance CPU?

Compare the actual slow interval and the user operation with guest memory, per-worker data and dependency times. The app may be swapping, may have one busy processor, or may wait on storage or a remote database. Choose a capacity or application test based on measured evidence.

What proves the resizing decision worked?

Check the real app and data first, then repeat the comparable request window and measure the latency, errors and throughput that define success. A higher memory number in the guest or a running instance demonstrates only part of the intended result.

What should you review before scaling a managed fleet member in place?

Check Auto Scaling ownership, ongoing launch settings, desired healthy capacity and the supported maintenance or rollout procedure. A stopped member can trigger replacement. The standalone stop/change/start path and a controlled fleet rollout have different effects.

Quick quiz

A t3 example gains memory with the same default virtual CPU count. Can you still call it vertical scaling?

Yes. Increasing an appropriate resource on a workload host changes its capacity. Compare instance type attributes and measure the workload. Every dimension need not increase together.

Can you attach new significance to a better p95 measured when nobody is using the app?

Compare the same offered workload first. A quiet window can be faster without a capacity improvement. The sample rejects the unmatched load, then checks the known data and latency objective on a comparable request window.

Which data requires separate protection before an ordinary instance stop?

Any required data on instance store and unfinished in-memory state. Persistent EBS volumes ordinarily remain attached through the supported workflow. Do not expect temporary host storage or process memory to survive it.

Practice tasks

  1. Change the sample after observations so the intended type is running but the request errors are nonzero. Explain why a lower p95 still fails.
  2. Write the first three checks for a change that lost administrative access but still shows a running EC2 state. Use the actual current endpoint, intended access rules and guest evidence.
  3. Propose one decision each for sustained memory pressure, too-small volume capacity and a slow remote query. Name the evidence you would collect before choosing a type change.

Match work to resources

Use app timing and guest observations to decide which capacity actually needs to change.

Verify compatibility first

Check EBS root, processor architecture, boot, drivers and location before stopping the existing instance.

Prove readiness and performance

Confirm mounted data and real request behavior, then repeat a comparable workload.

Keep a rollback route

Record original capacity and access, preserve supported data and plan the extra interruption if needed.

Official references