We closed the previous module with a warning: the Rutaverde platform is designed to scale and designed to be secure, but both things are true only on paper. Nobody has verified that one instance of the monolith handles fifteen shipment creations per second, still less now that every internal connection is encrypted. Nobody looks at the logs we decided to keep or gets an alert when a queue fills up. The certificates, the secrets, the guardrails, and rolling deployment depend on automation that does not exist. And nobody has added up what the new pieces cost against the two cents per shipment of NFR-12. This module is about the other half of the job: operating what has been designed. That is why Íñigo, the head of operations, moves to the foreground. We start with the most basic question he asks of any diagram: how many resources does each piece really need, and how do we know? In this lesson you will learn to optimize methodically, to size with sound criteria, and to plan capacity, and together with Íñigo we will review the size of every component of the target architecture.

Contents

  1. Effectiveness and efficiency
  2. The resources we optimize and how their saturation shows
  3. The method: measure, locate, optimize, and measure again
  4. Rightsizing and target utilization
  5. Optimization by layer: application, data, and compute
  6. Capacity planning
  7. The cost of encryption: a hypothesis to measure
  8. Application to Rutaverde

  1. Effectiveness and efficiency

These two words are often confused, and it is worth separating them from the start:

Concept What it means Question Example
Effectiveness Achieving the result Does it meet the requirements? The API responds with a p95 below 300 ms
Efficiency Achieving it with just the resources needed How much does meeting them cost? It does so with 3 instances rather than 12

A system can be effective and inefficient: RouteManager had two 16-vCPU machines and only one of them did any work. And it can be efficient and ineffective: a server running at 95% utilization that goes down at every peak. The order matters, and it is the order of the priorities the business set when the requirements were defined: first you meet them, then you make it cheaper. Optimizing resources is never an excuse for missing an availability or performance requirement.

Efficiency also has three sides that will keep coming up throughout the module: the technical side (making good use of CPU, memory, or disk), which is the subject of this lesson; the economic side (what it costs in euros), which we will see when we discuss cost management; and the operational side (people's time), which we will address with automation.

  1. The resources we optimize and how their saturation shows

Every component consumes five basic resources. Each one runs out in a different way, and recognizing the symptom is the first step of the diagnosis:

Resource What consumes it How saturation shows Example at Rutaverde
CPU Computation: logic, serialization, encryption, compression Latency grows progressively; request queues build up Route planning at 05:00
Memory Data in use, caches, sessions, connections Pauses, disk used as memory, and in the end the process dies abruptly A report that loads a year of shipments into memory
Storage Data, indexes, logs, backups The disk fills up and writes fail: a total, sudden failure The 20 TB NAS with the delivery photos
Network Bandwidth, number of connections Packet loss, retries, timeouts The link between the data center and the cloud
Input/output (I/O) Disk reads and writes The CPU looks idle, but everything is waiting on the disk db-01 when a report scans entire tables

Two useful observations:

  • Saturation does not give the same warning everywhere. CPU degrades little by little; memory and disk fail all at once. That is why they are given more headroom.
  • There are logical resources that run out too: the database connection pool, execution threads, file descriptors, a provider's quotas. A server can have its CPU at 20% and serve nobody because its 40 database connections are busy.

For each resource, three measurements matter: how much is being used (utilization), how much work is waiting (saturation), and how many failures it produces (errors). We will give them a name and a method in the lesson on monitoring.

  1. The method: measure, locate, optimize, and measure again

Optimizing without a method means changing things at random. The method has four steps and is a cycle:

flowchart LR
    M["1. Measure: how it behaves today"] --> C["2. Locate the bottleneck"]
    C --> O["3. Optimize only that point"]
    O --> V["4. Measure again"]
    V -->|"target not met"| C
    V -->|"target met"| F["Stop"]
  1. Measure. Without a starting measurement, there is no way to know whether a change improves anything. The measurement must cover what matters to the user (latency, requests served) and the resources.
  2. Locate the bottleneck. Every chain has one link that limits the whole. We already saw this when we studied scalability: improving something that is not the bottleneck achieves nothing.
  3. Optimize that point, and only that point. One change at a time, so that its effect can be attributed to it.
  4. Measure again. If things improved, the bottleneck will have moved somewhere else. Repeat until the target is met, and then stop: optimizing beyond the requirement means spending effort on something nobody asked for.

The danger of premature optimization

Premature optimization means complicating a design to gain performance that nobody has shown to be necessary. It has three costs: the code is harder to understand; the effort goes to the wrong place, because intuition about where the problem lies is usually wrong; and the design becomes rigid.

This does not mean ignoring performance. The useful distinction is this one:

Yes, from the start Only when a measurement calls for it
Architecture decisions that are hard to change: what is synchronous and what is asynchronous, where each piece of data lives, what can be distributed across instances Fine-tuning: parameters, specific algorithms, additional caches
Avoiding well-known mistakes that are cheap to avoid: queries with no index, no pagination Rewriting components that work

This is principle P3, simple first, applied to performance. At Rutaverde we have followed it without saying so: we ruled out sharding and the service mesh because no figure justified them.

  1. Rightsizing and target utilization

Rightsizing means giving each component the size its real load needs, no more and no less. There are two ways of getting it wrong:

Overprovisioning Underprovisioning
What it is More resources than needed Fewer resources than needed
Symptom Permanently very low utilization Saturation at peaks, high latency, outages
Cost Money tied up; visible on the bill Missed targets, lost customers; visible in the incidents
Why it happens "Just in case"; it was sized for a yearly peak It was sized for the average; the business grew

RouteManager makes both mistakes at once, which makes it a good example. The only data available comes from the hypervisor over the last year:

Server Size Average CPU CPU at the daily peak CPU in the last peak season
app-01 16 vCPU / 64 GB 18% 45% 97%
app-02 16 vCPU / 64 GB 0%, powered off 0% 0%
db-01 32 cores / 256 GB 12% 35% 88%

For eleven months more than half of the installed capacity goes unused, and during peak season there is not enough. This is the consequence of fixed capacity facing a load that varies by a factor of 5. The solution is not to buy a bigger server, but what we already decided: smaller instances that are added and removed.

Target utilization

At what percentage of use should a component operate? Not at 100%, because there is no headroom left, and not at 10%, because it is wasted. You set a target utilization that leaves headroom for three things: the peaks within the peak, the loss of an instance, and the time it takes for new capacity to arrive.

Type of component Target utilization at peak Why
Stateless services with autoscaling 60% CPU A new instance takes minutes; the headroom covers the wait
Stateless services with fixed capacity 50% to 60% CPU, with N+1 There is nothing to fall back on if the load rises
Primary database 50% CPU It cannot be distributed; saturation affects everything
Memory 75% It runs out suddenly
Disk 70% Filling it stops the service; expanding it takes time

With the target utilization and the N+1 rule you can calculate the number of instances. If one instance handles c operations per second while meeting the latency requirement, and the peak is P:

instances = round_up(P / c) + 1

The + 1 is the instance that can fail without saturating the rest. It is the same calculation that gave us five instances of the monolith in peak season: 50 / 15 = 3.3, that is, 4, plus one.

Three practical sizing rules:

  • Size with data from at least one complete business cycle: a week for day-to-day activity, and the peak season for the peak.
  • Look at the high percentile, not the average. An average CPU of 18% hides a peak of 97%.
  • Review it periodically. The load changes, the code changes, and the available sizes change. Today's right size will not be the right size a year from now.

  1. Optimization by layer: application, data, and compute

Not all optimizations are worth the same. As a general rule, the higher up, the bigger the payoff: fixing a badly written query can divide the load by fifty; changing the size of a server adjusts it by a percentage.

Application layer

N+1 queries. This is the most common performance defect. The code fetches a list with one query and then runs one more query for each item:

# Inefficient version: 1 + N queries
shipments = query("SELECT * FROM shipments.shipment WHERE merchant_id = ? LIMIT 50")
for each shipment in shipments:
    shipment.events = query(
        "SELECT * FROM shipments.shipment_event WHERE shipment_id = ?", shipment.id)

# Efficient version: 2 queries
shipments = query("SELECT * FROM shipments.shipment WHERE merchant_id = ? LIMIT 50")
ids = [shipment.id for each shipment in shipments]
events = query(
    "SELECT * FROM shipments.shipment_event WHERE shipment_id IN (?)", ids)
group events by shipment_id and assign them to each shipment
  • The first version makes 51 round trips to the database to render a page of 50 shipments. Each trip is fast, which is why the defect goes unnoticed in tests with little data.
  • The second makes 2 round trips, whatever the page size. The grouping work moves to the application, which scales better than the database.
  • The shipment list in RouteManager's merchant portal has exactly this defect: it is one of the reasons for its p95 of 900 ms.

Indexes. An index lets the database find rows without scanning the entire table. Without one, a search by merchant_id in a table with millions of rows reads all of them. With one, it reads a few pages. They are not free: every index takes up space and makes writes more expensive, so they are created for the queries that exist, not "just in case."

Batching. Doing a hundred operations in one trip instead of a hundred trips of one operation each. It works for inserts, for publishing messages, and for calls between services. The cost is that the whole batch waits until it is complete.

Compression. Compressing responses reduces network traffic in exchange for CPU. It pays off handsomely with text, such as JSON and HTML, and not at all with content that is already compressed, such as JPEG photos.

Connection reuse. Opening a connection is expensive: network handshake, TLS handshake, authentication. Connections are opened a few times and reused many times, through database connection pools and persistent connections between services. With all internal traffic encrypted, this optimization stops being optional, as we will see below.

Data layer

Storage tiers (tiering). Not all data is used in the same way. Object storage providers offer tiers at different prices:

Tier Access Storage cost Read cost What for
Frequent Immediate High Low Data in daily use
Infrequent Immediate Medium Medium Data that is looked up once in a while
Archive Minutes or hours Very low High Data that is kept because it has to be

Object lifecycle. A policy that moves each object from tier to tier according to its age and deletes it at the end of its retention period, with no human intervention. It is also a data protection control: what is deleted on time cannot be leaked.

Compression and format. Historical data that is only read is stored compressed and, if it is going to be analyzed, in columnar formats. A compressed monthly partition of events takes up a fraction of its size in the database.

On top of this comes what we have already decided: date-based partitioning, which makes it possible to archive an entire month in one go, and the retention periods, which limit growth.

Compute layer

  • Instance sizes. Choosing the CPU-to-memory ratio the load needs. A service that only routes requests needs little memory; a database needs a lot.
  • Density with containers. Several small services share one machine and make better use of its resources than one virtual machine per service. We will decide whether this suits Tracking and Notifications in the lesson on automation.
  • Turning off what is not in use. Test environments outside working hours, peak-season instances outside peak season, orphaned resources nobody remembers creating.
  • Elasticity. Adjusting capacity to the load at each moment with autoscaling. It is the most powerful compute optimization, and it is only available where there is capacity to draw on.

  1. Capacity planning

Capacity planning answers a question with a date attached: when will what we have stop being enough? It combines two components:

  • The trend: the organic growth of the business, month by month.
  • The events: peaks known in advance, such as a peak season or the launch of a new city.

Rutaverde handles 40,000 shipments a day today and wants to reach 200,000 in two years, with the expansion to twenty cities. That amounts to a fivefold increase in 24 months, a monthly growth of around 6.94%. And every year there is a peak season that multiplies the daily volume by five. A simple calculation projects the load and the instances needed:

import math

shipments_per_day_today = 40_000
monthly_growth = 0.0694           # 6.94% per month: x5 in 24 months
peak_season_factor = 5            # peak season multiplies the normal day
peak_factor = 4                   # the peak versus the daily average
capacity_per_instance = 15        # creations/s: UNVALIDATED HYPOTHESIS


def peak_creations(shipments_per_day):
    return shipments_per_day / 86_400 * peak_factor


def instances(creations_per_s, capacity):
    return math.ceil(creations_per_s / capacity) + 1    # N+1 rule


for month in (0, 6, 12, 18, 24):
    normal = shipments_per_day_today * (1 + monthly_growth) ** month
    peak_season = normal * peak_season_factor
    peak = peak_creations(peak_season)
    n = instances(peak, capacity_per_instance)
    print(f"Month {month:>2}: {normal:>9,.0f} shipments/day | peak season {peak_season:>9,.0f} | "
          f"peak {peak:5.1f} creations/s | {n} instances")

Line by line:

  • The first five variables are the assumptions. Having them at the top, with a name, makes it possible to discuss them and change them. The last one carries a warning: it is a hypothesis.
  • peak_creations applies the conversion we already know: the shipments of one day divided by its 86,400 seconds give the average, and the ×4 peak factor turns it into the peak.
  • instances applies the formula from section 4. math.ceil rounds up, because there is no such thing as half an instance.
  • The loop goes through five points in time. At each one it calculates the volume of a normal day with compound growth, (1 + monthly_growth) ** month, the volume of a peak-season day, the peak, and the instances.

The result:

Month  0:    40,000 shipments/day | peak season   200,000 | peak   9.3 creations/s | 2 instances
Month  6:    59,828 shipments/day | peak season   299,138 | peak  13.8 creations/s | 2 instances
Month 12:    89,483 shipments/day | peak season   447,417 | peak  20.7 creations/s | 3 instances
Month 18:   133,839 shipments/day | peak season   669,196 | peak  31.0 creations/s | 4 instances
Month 24:   200,182 shipments/day | peak season 1,000,908 | peak  46.3 creations/s | 5 instances

Month 24 reproduces the peak of NFR-07: 46 creations per second, which we round to 50, and five instances. But the plan contributes something the final figure did not: the path. The first year's peak season needs three instances, not five. There is no need to have all the capacity from day one.

A good capacity plan also includes a sensitivity analysis: what happens if an assumption is wrong. The most fragile one is the capacity per instance:

for capacity in (15, 14, 13, 12, 11):
    print(f"With {capacity} creations/s per instance: "
          f"{instances(50, capacity)} instances for 50 creations/s")
With 15 creations/s per instance: 5 instances for 50 creations/s
With 14 creations/s per instance: 5 instances for 50 creations/s
With 13 creations/s per instance: 5 instances for 50 creations/s
With 12 creations/s per instance: 6 instances for 50 creations/s
With 11 creations/s per instance: 6 instances for 50 creations/s

The threshold is at 12.5: if the real capacity falls below it, a sixth instance will be needed. This is valuable information before measuring anything, because it tells us how precise the measurement needs to be.

  1. The cost of encryption: a hypothesis to measure

In the previous module we decided to encrypt all internal traffic with TLS and to apply field-level encryption to the phone number, the email address, and the notes of every shipment. Both decisions consume CPU, and the hypothesis of 15 creations per second predates them. How much do they take away? The honest answer is that we do not know. What we do know is where the cost comes from and how to contain it:

Operation Where the cost lies How it is contained
TLS handshake This is the expensive part: asymmetric cryptography every time a connection is opened Persistent connections and connection pools: negotiate once and reuse
Encrypting TLS traffic Symmetric encryption of every byte; cheap on processors with hardware acceleration Not much to do; it is usually a small percentage
Field-level encryption Encrypting and decrypting three columns on every read and write Envelope encryption: the data key is kept in memory and the KMS is not called on every operation
Calls to the KMS A network round trip from the data center to the cloud Only at startup and when renewing the data key, which we already decided to keep in memory for at most 12 hours

The reasonable expectation, with connections reused and the key in memory, is a loss of between 5% and 20% of capacity. Cross-checked against the sensitivity analysis, the conclusion is uncomfortable: the expected range contains the 12.5 threshold. With a 5% loss, 14 creations per second and five instances; with 20%, 12 and six. Only a measurement will settle it. It stands as the first hypothesis to validate in the lesson on performance evaluation.

What is not acceptable is the opposite shortcut: turning off encryption "because it hurts performance." Security is a mandatory constraint; the performance it costs is bought with capacity.

  1. Application to Rutaverde

Sizing review

You and Íñigo go through the target diagram piece by piece. For each one, the same question: does the size come from a data point or from habit?

Component Planned size Expected load Assessment Decision
mono-01 to mono-03 8 vCPU / 32 GB 2 creations/s at peak today; 9 at the sustained target Two would be enough for the load; the third is the N+1. Memory looks oversized Keep; measure CPU and memory in the tests
mono-04, mono-05 8 vCPU / 32 GB Peak season only Outside peak season they contribute nothing Powered off except in peak season; scheduled power-on
mono-batch-01 8 vCPU / 32 GB Planning at 05:00, nightly billing, reports Bursty load; idle for much of the day Keep: planning has a deadline
db-01 32 cores / 256 GB 35% CPU at the daily peak, with reports and tracking included With reports on db-02 and tracking moved out, it has plenty of room Keep: it is owned hardware and must absorb the ×5
db-03 Same as db-01 Standby replica It must be able to take over from the primary Do not shrink: a standby smaller than the primary is not a standby
db-02 16 cores / 128 GB Reports and exports Adequate Keep
redis-dc-01 and 02 2 vCPU / 4 GB A few thousand sessions of a few KB each Less than 1 GB in use Small size; it is enough
Tracking 2 vCPU / 4 GB, from 2 to 8 9 queries/s today; 250 at the peak The minimum of 2 is imposed by having two zones, not by the load Keep; elasticity with a 60% target
Notifications 1 vCPU / 2 GB, from 2 to 6 100 notifications/s at the peak Almost all of its time is spent waiting for the provider: it needs little CPU Small instances
cache-tracking 4 GB, primary and replica One entry of around 1 KB per shipment looked up With 1,000,000 live shipments, around 1 GB Keep; there is headroom to spare
db-tracking 4 vCPU / 16 GB 90 days × 200,000 shipments = 18 million documents of about 2 KB: 36 GB Adequate Keep
NAS 20 TB Old photos and labels New photos go to rv-delivery-photos; the old ones expire Do not expand; it empties itself in 12 months

Three takeaways from the table:

  • In the data center, powering off does not save euros right away, because the hardware is owned. It frees up capacity on the three virtualization servers for the peak-season instances and for pre-production. The savings in money come when it avoids a purchase.
  • Some sizes are not to be optimized. db-03 and the minimum of two instances per zone are redundancy, not waste.
  • Almost every decision is "keep and measure." That is the right call: shrinking without data would be premature optimization in the opposite direction.

Lifecycle of the photos and the archive

The volume of photos deserves a calculation of its own. Each delivery generates a photo of about 200 KB:

Volume New photos per day In the frequent tier, 30 days In the infrequent tier, up to 12 months Steady-state total
40,000 shipments/day 8 GB 0.24 TB 2.68 TB 2.92 TB
200,000 shipments/day 40 GB 1.2 TB 13.4 TB 14.6 TB

Customer support's experience says that almost all claims about a delivery arrive in the first few weeks. Hence the policy:

lifecycle_policy:
  - bucket: rv-delivery-photos
    rules:
      - name: photos-to-infrequent
        after_days: 30
        action: move
        tier: infrequent
      - name: photos-deletion
        after_days: 365
        action: delete
  - bucket: rv-event-archive
    rules:
      - name: events-to-archive
        after_days: 0
        action: move
        tier: archive
  • Each block applies to one object storage bucket.
  • after_days counts from the creation of the object. After 30 days, the photo moves to the infrequent tier: it is still available instantly, with the same 5-minute signed URL, but it costs less to store.
  • After 365 days it is deleted. This is the 12-month period proposed for the photos, which is still pending legal validation; if it changes, one number changes.
  • The monthly partitions of shipments.shipment_event that leave the database after 13 months are exported compressed and go straight to the archive tier: nobody looks at them unless there is a formal request. Their total retention period will be set by the legal validation.
  • The backups in rv-db-backups have their own policy, which we will define when we deal with disaster recovery.

One precaution: cheap tiers usually charge for reads and require a minimum storage duration. Moving something to archive that is looked up every week ends up costing more than leaving it where it was.

Capacity plan for peak season

Item Normal day First-year peak season Target peak season
Shipments per day 40,000 to 90,000 about 450,000 1,000,000
Creations per second at peak 2 to 4 21 50
Monolith instances, with the hypothesis of 15 3 3 5, or 6 if the real capacity falls below 12.5
Tracking instances 2 2 to 3, automatic 4 to 8, automatic
Preparation None Scheduled power-on two weeks ahead; deployment freeze Same

The plan is reviewed every quarter with the real growth data and, on a mandatory basis, eight weeks before each peak season.

The decision

# ADR-014: Sizing criteria, storage lifecycle, and capacity plan

Status: Accepted
Date: 2026-09-17
Participants: Íñigo (operations), Marta (architecture), Clara (security)

## Context
The sizes in the target architecture come from hypotheses. RouteManager
has fixed capacity, idle for eleven months and insufficient in peak
season. The photos would fill the NAS in little more than a year at
200,000 shipments a day.

## Options considered
A. Size everything for the peak-season peak permanently.
B. Size with target utilization and N+1, elasticity where it exists,
   and an automatic data lifecycle.
C. Shrink sizes now, before measuring.

## Decision
We will adopt option B. Target utilization at peak: 60% CPU on
stateless services, 50% on primary databases, 75% memory, and 70%
disk. Instances = peak divided by capacity, rounded up, plus one. The
photos move to the infrequent tier after 30 days and are deleted after
365; the event archive goes to the archive tier. The peak-season
instances stay powered off outside peak season. The capacity plan is
reviewed every quarter and eight weeks before each peak season.
The current sizes are kept until they are measured.

## Security
Data affected: delivery photos (Personal). Automatic deletion
enforces the retention period. It does not require threat modeling: it
changes neither entry points nor boundaries.

## Consequences
Positive: a single, explicit criterion; the NAS stops growing.
Negative: the sizes are provisional until the load tests.
Risks: that encryption reduces the capacity per instance below
12.5 creations per second and a sixth instance is needed.

Common Mistakes and Tips

  • Optimizing without measuring. Intuition about where the problem lies is wrong more often than it is right.
  • Looking at the average. A CPU at 18% on average can be at 97% when it matters.
  • Optimizing what is not the bottleneck. Adding application instances when what is saturated is the connection pool changes nothing.
  • Continuing to optimize after the target has been met. The method has a stop condition.
  • Confusing redundancy with waste. The standby replica and the N+1 instance are idle on purpose.
  • Sizing for the yearly peak permanently when the alternative of powering on and off exists.
  • Forgetting the logical resources: connections, threads, provider quotas.
  • Creating indexes just in case. Each one makes every write more expensive.
  • Cutting security to gain performance. Encryption is paid for with capacity; it is not up for negotiation.
  • Tip: write the assumptions of any capacity calculation at the top and give them names. When reality proves them wrong, you will know which number to change.

Exercises

Exercise 1

Diagnose which resource is saturated in each case and propose the first check:

  1. An instance has its CPU at 25%, but requests take 4 seconds and the logs show waits to obtain a database connection.
  2. A service works fine for six days and, on the seventh, the process disappears and restarts by itself.
  3. The database has its CPU at 30%, but queries slow down every night during the backup.
  4. A service responds more and more slowly as traffic rises, gradually, until it hits its timeouts.

Exercise 2

A label service handles 30 requests per second per instance while meeting its latency requirement. The expected peak is 200 requests per second.

  1. How many instances does it need with the N+1 rule?
  2. With all instances running, at what percentage of its capacity does each one operate at the peak?
  3. If a test shows that the real capacity is 24 requests per second, how many are needed?

Exercise 3

Rutaverde stores shipment labels as PDFs of about 50 KB each. They are accessed a lot on the day they are created, almost never after delivery, and the merchant can request them for 90 days. With 200,000 shipments a day:

  1. How much space do they take up in steady state?
  2. Propose a lifecycle policy.
  3. Is it worth compressing them?

Solutions

Solution 1

  1. A logical resource: the connection pool. The idle CPU gives it away. First check: how many of the pool's connections are in use and how long each query takes. The usual cause is a slow query holding on to connections, not a pool that is too small; enlarging the pool without looking would move the problem to the database.
  2. Memory. A sudden, periodic failure is its signature: something grows without being released until it hits the limit. Check: the memory graph for the week, which will show a ramp.
  3. Disk input/output. The backup competes with the queries for the disk. Check: I/O wait times during the backup. Typical solution: take the backup from a replica.
  4. CPU, probably. Gradual degradation with queues building up is how it behaves. Check: CPU utilization and the length of the request queue at the peak.

Solution 2

  1. 200 / 30 = 6.67, rounded up, 7. Plus one: 8 instances.
  2. 200 / 8 = 25 requests per instance, out of 30: 83% of its usable capacity. Remember that those 30 are already the capacity that meets the requirement, not the absolute maximum. With one instance down, 200 / 7 = 28.6, or 95%: tight, but within limits.
  3. 200 / 24 = 8.33, that is, 9, plus one: 10 instances. A 20% difference in the hypothesis changes the result by two instances. Common mistake: forgetting the + 1 or rounding down.

Solution 3

  1. 200,000 × 50 KB = 10 GB per day. With 90 days of retention, 900 GB.
  2. Frequent tier for the first 7 days, which cover creation, printing, and most deliveries; infrequent tier until day 90; deletion at 90 days. The archive tier is not suitable: the merchant expects the label instantly. Besides, a label can be regenerated from the shipment data, so it does not need the same protection as a photo.
  3. It depends on how they are generated. A PDF with text and a barcode usually compresses well, and many generators already do it internally. The sensible thing is to measure a sample before adding a step: if the gain is 10%, it is not worth the complexity; if it is 60%, it is. This is the method of the lesson applied on a small scale.

Conclusion

Optimizing resources means achieving the same with less, and it only makes sense after achieving what has to be achieved: effectiveness first, efficiency second. We have seen the five basic resources and the different way each one runs out; the method of measuring, locating the bottleneck, optimizing, and measuring again, with its stop condition and its warning against premature optimization; rightsizing, with a target utilization that leaves headroom and the N+1 rule; optimization by layer, which pays off more the closer it is to the application; and capacity planning, which combines the trend with the known events and examines what happens if an assumption fails.

At Rutaverde, ADR-014 sets the criteria: 60% CPU on stateless services, 50% on databases, peak-season instances powered off outside peak season, photos that drop a tier after 30 days and are deleted after 12 months, and a capacity plan reviewed every quarter. It has also exposed a fragility: all the sizing rests on the hypothesis of 15 creations per second, and encryption may have pushed it below the 12.5 threshold that separates five instances from six.

Almost every decision in the review has been "keep and measure." And there lies the problem: today Rutaverde has only the hypervisor graphs. You cannot optimize, size, or plan what you cannot see. In the next lesson we will build the platform's eyes: what to measure, how to turn measurements into alerts that wake someone up only when necessary, and how to keep what is running in good shape.

© Copyright 2026. All rights reserved