Right-Sizing Amazon MWAA and Cloud Composer Environments

Most managed Airflow environments are sized once, on the day someone created them, and never revisited. The tier was a guess. The bill has been paying for that guess ever since.

This post gives a method for sizing an Amazon MWAA or Google Cloud Composer environment from measurements. It does not assume either service is the right home for your estate. It assumes you already run there and want the orchestration bill to match the workload.

Exact limits, class names and prices change between releases. Check the current provider documentation for the numbers. The method below does not depend on them.

Step 1: Separate the three things that can be too small or too large

A managed environment is three workloads sharing one price tag.

  1. Scheduling and DAG parsing. The scheduler and DAG processor read your files, build serialized DAGs and create task instances. Load grows with the number of DAG files and how expensive each is to import. It does not grow with data volume.
  2. Task execution. Workers run your operators. Load grows with concurrent tasks and with what those tasks do in-process.
  3. The metadata database. Every state change is a write. Load grows with task count, retries, XCom size and how often the UI and API are queried.

Most wrong-sizing comes from fixing one of these by scaling another. A larger worker class does nothing for a scheduler that spends its time importing pandas forty times per loop.

Step 2: Collect a week of evidence

Pick a representative week, including the nightly peak and any month-end run. Gather:

  • Parse time. Total DAG processing time and the slowest files. Use airflow dags report or the DAG processing metrics. If a full parse cycle takes longer than your min_file_process_interval, the scheduler is behind.
  • Scheduler heartbeat and loop duration. A scheduler that is busy but not lagging is fine. Lag in task start (queued to running) is the signal.
  • Concurrent running and queued tasks, by hour. Plot the peak, not the average. Estates are usually idle 20 hours a day.
  • Worker CPU and memory at the peak. Look at the maximum across workers, and look for out-of-memory kills in the task logs.
  • Pool usage. Pools that sit at 100 percent with tasks queued mean you have a deliberate limit, not a capacity problem.
  • Database CPU, connections and free memory, where the provider exposes them.

Write the numbers down. Without them, any later change is an opinion.

Step 3: Fix the workload before the tier

Three findings change the answer before you touch sizing.

Slow parsing. If imports at module top level are heavy, or DAG files call APIs or read Variables at parse time, move that work inside tasks. This often lets you drop a scheduler size or avoid adding schedulers. See our post on cutting DAG parsing time.

Polling sensors holding worker slots. A sensor in poke mode occupies a slot for its whole wait. Hundreds of them make peak concurrency look enormous. Deferrable operators or reschedule mode shrink the peak. See replacing polling sensors with deferrable operators. Caveat: deferral moves load onto the triggerer, so confirm it is sized for the number of deferred tasks.

A synchronized midnight. If 300 DAGs share 0 0 * * *, you are buying capacity for one minute of the day. Spreading schedules by even 30 to 60 minutes can lower the peak a long way. Caveat: some downstream consumers genuinely need data by a fixed time. Spread the DAGs that have slack and leave the rest.

Step 4: Size workers from peak concurrency

Both services let workers scale between a minimum and a maximum, in different ways.

  • On MWAA, you choose an environment class, which sets the concurrency per worker, and a minimum and maximum worker count. Autoscaling reacts to queued tasks, and scale-down is not instant.
  • On Cloud Composer 3, you set CPU and memory per worker and a minimum and maximum worker count. Per-task memory is the number to get right, because workers are shared.

A working procedure:

  1. Take peak concurrent tasks from Step 2.
  2. Divide by the task slots per worker to get the worker count you need at peak.
  3. Set the maximum slightly above that, and set the minimum to what the quiet hours need. The minimum is the number that drives most of your bill.
  4. If tasks are killed for memory, raise per-worker memory or move those tasks to something that suits them. Do not raise the class for every task because three of them are heavy.

Caveat: if your tasks mostly wait on a warehouse or an external API, CPU on the worker is not the constraint. Concurrency limits in the warehouse usually are. Adding workers then increases queue pressure downstream without finishing work earlier. Use pools to cap it.

Step 5: Size the scheduler last

Only after parsing is reasonable should you decide on scheduler capacity.

  • If queued-to-running delay is small at peak and parse cycles finish inside the interval, do not add schedulers.
  • If parse cycles are long after cleanup, add scheduler or DAG processor capacity one step at a time and re-measure.
  • Keep an eye on the metadata database. More schedulers means more database load, and on a small database tier that can make things slower.

On Composer, the size of the environment's database tier is a separate setting from worker sizing. If the UI is slow while workers are idle, look there. On MWAA the database is managed for you, so the lever is mostly reducing load: fewer DAGs, smaller XComs, and less history retained.

Step 6: Trim what the database carries

Old run history costs you query time. Set a retention policy and clean it with airflow db clean or the managed equivalent. Test on a copy first. Large XCom values, such as DataFrames passed between tasks, belong in object storage with a path passed instead. This is a reliability fix as much as a cost one.

Step 7: Change one dial at a time

Make one change, run for several nightly cycles, and compare with your Week 0 numbers. Record the change, the date and the result in a short document. When something regresses, you will know which change did it.

Resist doing all of it in one maintenance window. It feels efficient and it removes your ability to attribute cause.

When the problem is not sizing

  • The bill is mostly the minimum floor. If you run a large environment for a 90-minute nightly batch, the issue is the always-on baseline. Consider whether a smaller class with a higher maximum works. If not, a different hosting arrangement may be cheaper. That is a legitimate outcome, and it includes self-managing on Kubernetes. It also moves operational work onto your team, so count that cost.
  • Dozens of DAGs nobody reads. Some DAGs produce tables no one queries. Retiring them is the cheapest optimization there is. Check downstream usage before you pause anything.
  • A planned version move. If you are about to migrate from Airflow 2 to 3, size after cutover, not before. Resource profiles change, and the dual-run period will cost extra. See building a dual-run harness.

The real-estate caveat

These steps assume you can see per-task resource use and that your DAGs are not hiding a single enormous job. On estates where the original author left and nobody knows which tasks are heavy, step 2 can take longer than the tuning itself. Budget for that. Also, a managed subscription that is correctly sized is still not the same thing as a working estate: failing retries, unowned DAGs and stale providers cost money in any tier.