# BTP runtimes compared: Cloud Foundry, Kyma and ABAP

> Decide which SAP BTP runtime each workload belongs on, from the skills, operating effort, billing floor and limits of Cloud Foundry, Kyma and ABAP.

- Course: Orchestrate, Unit 21 · SAP BTP as a platform
- Page: https://erpfde.com/topics/btp-runtimes-compared/
- Updated: 2026-11-26
- Reading time: Foundational 8 min, Deep 38 min

Independent learning resource. Not affiliated with, sponsored by or endorsed by SAP SE. SAP and other SAP products mentioned are trademarks of SAP SE in Germany and other countries.

## Foundational layer

### The 60-second version

SAP Business Technology Platform (BTP) gives you three places to run your own code. Each suits a different kind of team and workload:

- **Cloud Foundry** is the simplest. Developers hand over their code, and the platform runs it. You pay for the memory your apps reserve.
- **Kyma** is a managed Kubernetes cluster. It gives more control over networking and containers. You pay for the cluster's machines, so there is a minimum size even when nothing runs.
- **The ABAP environment** is an ABAP system in the cloud. ABAP teams build with the same model they use inside S/4HANA. You pay for ABAP and database capacity.

Two more options sit beside these. Some ABAP logic belongs inside S/4HANA itself, not on BTP. And SAP's own SaaS services on BTP, such as Integration Suite, need no runtime from you at all.

SAP's own comparison guide says the choice between Cloud Foundry and Kyma doesn't have to be made once for everything. You can use both, workload by workload. This topic gives a rule for each workload and checks one partner's proposal against it.

### Why it matters to the business

The runtime decides three things a leader cares about.

- **Who you need.** Cloud Foundry needs developers. Kyma also needs people who can run Kubernetes workloads. The ABAP environment needs ABAP developers who know ABAP Cloud.
- **What it costs when idle.** Cloud Foundry bills memory, so a small app costs little. A Kyma cluster has a floor: SAP's sizing table names three nodes as the minimum. An ABAP system has a minimum size too, though non-production systems can be hibernated.
- **What you run yourself.** SAP runs all three platforms, but not your apps. In Kyma your team also keeps container images and cluster modules up to date.

> **Example:** Calder Pumpworks, the course's fictional pump maker, has seven workloads heading for BTP: two AI agents, an AI gateway, a distributor portal, a shop-floor listener, a pricing job and a certificate archive. A partner proposed one Kyma cluster for the non-ABAP ones and the ABAP environment for the pricing job. The deep layer shows that six of the seven placements change when you apply a rule per workload. One cluster is still needed, for the shop-floor listener, because Cloud Foundry on BTP can't accept plain TCP traffic.

### How SAP does it

As of 26 November 2026, SAP's documentation describes the three runtimes as environments you enable in a subaccount:

| | Cloud Foundry | Kyma | ABAP environment |
| --- | --- | --- | --- |
| What you get | A platform that runs apps from code (buildpacks) or container images | A Kubernetes cluster managed by SAP, with Kyma modules you choose | An ABAP system with its own SAP HANA Cloud database |
| Languages | Java, Node.js, Python and others | Any that runs in a container | ABAP (ABAP Cloud) |
| How it's billed | Runtime memory reserved, per GB | Capacity units for nodes and storage | ABAP Compute Units and HANA Compute Units, in 16 GB blocks per hour |
| Smallest size | 1 GB of memory with a quarter CPU core | 3 nodes of 2 vCPU and 8 GB | 1 ABAP Compute Unit and 2 HANA Compute Units |
| Try it free | Trial and free tier plan | Trial on request, or the free plan once per global account for 30 days | Free plan in an enterprise account, stopped every night |

Sources: SAP's [runtime comparison guide](https://github.com/SAP-docs/btp-runtime-comparison-guide/blob/main/docs/comparison-sap-btp-kyma-runtime-and-sap-btp-cloud-foundry-runtime-de5c964.md), the metering pages for [Cloud Foundry](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/service-plans-and-metering-for-cloud-foundry-runtime-8d41fa4.md), [Kyma](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/service-plans-and-metering-for-kyma-runtime-c33bb11.md) and the [ABAP environment](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/service-plans-and-metering-for-sap-business-ai-platform-abap-environment-b7f5a93.md), and [Available Plans in the Kyma Environment](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/50-administration-and-ops/available-plans-in-the-kyma-environment-befe01d.md).

The comparison guide says Cloud Foundry and Kyma have the same service level agreement and both run across availability zones. So the decision rests on architecture and skills, not on reliability.

Names are shifting. SAP's documentation, updated in November 2026, calls the third option **SAP Business AI Platform, ABAP environment**, while the comparison guide and many SAP pages still say SAP BTP ABAP environment. The older **Neo** environment is for existing customers only, and SAP documents how to migrate away from it.

### Choosing for a workload

Ask these questions in order for each workload. Stop at the first "yes".

| Question | If yes | Why |
| --- | --- | --- |
| Is it ABAP logic that changes data inside one S/4HANA system? | Build it in S/4HANA with ABAP Cloud, not on BTP | It runs in the same system and transaction as the data it changes |
| Is it ABAP code or ABAP skills serving several systems, or kept apart from S/4HANA? | ABAP environment | Same development model as S/4HANA, on its own system |
| Does it need something Cloud Foundry on BTP doesn't offer? Plain TCP, container-to-container networking, a service mesh, video streaming, more than 16 GB per instance | Kyma | These are documented limits of Cloud Foundry on BTP |
| Anything else | Cloud Foundry | It bills only the memory reserved and has the least to run |

Then ask one more question. If a Kyma cluster exists anyway, should other container workloads share it? That is a cost and skills decision to record, not a rule.

> **Note** **For functional consultants:** the runtime rarely changes your configuration, but it changes testing and release. A Cloud Foundry app can move through SAP Cloud Transport Management, which SAP lists for Cloud Foundry only; a Kyma app moves through a deployment pipeline. Logic built inside S/4HANA follows that system's transports and test cycles. Ask which path a change takes before you plan test cases.

### Questions to ask

Ask your architect or partner:

- For each workload, which runtime, and which of the questions above sent it there?
- Who on our team operates Kubernetes if we choose Kyma, and who patches the container images?
- What does the Kyma cluster cost per month when idle, and which workloads share it?
- Which ABAP logic stays inside S/4HANA, and which goes to the ABAP environment?
- Which non-production ABAP systems will be hibernated, and when?

Ask SAP or your account team:

- Which runtimes and plans are in our contract, and in which regions?
- Do we have a consumption-based or subscription-based contract? Kyma has no subscription-based model.

### Common misconceptions

- **"Kyma is the modern one, Cloud Foundry is legacy."** SAP's comparison guide calls both part of SAP's long-term strategy, with CAP supported on both.
- **"Containers mean Kubernetes."** Cloud Foundry on BTP runs container images too. Kyma is needed for specific needs, not for every image.
- **"Kyma is more reliable."** SAP states the same service level agreement for both.
- **"All ABAP goes to the ABAP environment."** Logic that changes data inside one S/4HANA system usually belongs in that system.
- **"An idle app costs nothing."** In Cloud Foundry, reserved memory is billed whether or not requests arrive. In Kyma, the cluster floor is billed.
- **"Hibernation makes a stopped ABAP system free."** SAP says stopped systems still incur some cost, for the database.

### Key terms

- **Runtime (environment):** where your code runs on BTP: Cloud Foundry, Kyma or the ABAP environment, enabled per subaccount.
- **Buildpack:** a Cloud Foundry component that turns source code into a running app.
- **Kyma cluster:** a Kubernetes cluster that SAP provisions and manages in your subaccount.
- **Capacity unit:** Kyma's billing unit, counted per hour for nodes and storage.
- **ABAP Compute Unit (ACU):** the ABAP environment's runtime size, 16 GB of memory and about four virtual CPUs.
- **HANA Compute Unit (HCU):** the ABAP environment's database size, billed in 16 GB blocks.
- **System hibernation:** stopping an ABAP environment system to save cost without deleting its database.
- **Billing floor:** what a runtime costs at its smallest size, even with no load.

### Check yourself

1. According to SAP's comparison guide, what should drive the choice between Cloud Foundry and Kyma?
   - A. Which of the two has the higher service level agreement
   - B. The application's architecture and the skills of the team
   - C. Which one SAP plans to keep after the other retires
   - D. Which one supports the SAP Cloud Application Programming Model

   Answer: B. SAP says both have the same service level agreement, both are long-term, and both support CAP. What differs is the control over infrastructure an architecture needs, and the skills to use it.

2. A partner proposes one Kyma cluster for all of Calder's small apps. What is the main cost question to raise?
   - A. Whether Kyma adds a charge for every user who signs in to the apps
   - B. Whether Kyma bills memory more cheaply than Cloud Foundry
   - C. The cluster's minimum size is billed even when the apps are idle
   - D. Whether a Kyma cluster needs its own global account

   Answer: C. A Kyma cluster starts at three nodes, billed as capacity units each hour. Cloud Foundry bills the memory apps reserve, which is small for small apps.

3. Calder needs a job that sets a monthly price inside its S/4HANA system. Where does it usually belong?
   - A. In the ABAP environment, since it is written in ABAP
   - B. Inside S/4HANA, built with ABAP Cloud
   - C. In Cloud Foundry, as a scheduled task
   - D. In Kyma, as a serverless Function

   Answer: B. Logic that changes data inside one S/4HANA system runs best in that system. The ABAP environment suits ABAP that serves several systems or stays apart from S/4HANA.

4. Calder's shop-floor system can only push messages over plain TCP. What follows for the runtime?
   - A. Cloud Foundry, because it supports MQTT
   - B. The ABAP environment, because it speaks RFC
   - C. Any of the three, because all of them accept plain TCP traffic
   - D. Kyma, because Cloud Foundry on BTP has no TCP routing

   Answer: D. SAP lists TCP routing among the Cloud Foundry features not supported on BTP. Kyma can accept that traffic, so this one workload sends Calder to Kyma.

5. Which statement about operating effort is right?
   - A. In Kyma, the customer patches container images and module settings
   - B. In Kyma, SAP patches the container images that customers deploy
   - C. In Cloud Foundry, customers patch the operating system of buildpack apps
   - D. In all three runtimes, SAP monitors and scales the customer's apps

   Answer: A. SAP's operating model puts images and module configuration on the customer in Kyma. For buildpack apps SAP patches the stack, and in both runtimes the customer owns its apps' scaling and monitoring.

6. What should a leader know about hibernating ABAP environment systems?
   - A. It deletes the database, so it only suits systems you will throw away
   - B. It cuts idle cost, though a stopped system still costs a little
   - C. It is meant for production systems over weekends
   - D. It is free only on subscription-based contracts

   Answer: B. SAP says stopped systems use no ABAP Compute Units and minimal database units, so costs can fall below 5%. It suits development and test systems that sit idle.

## Deep layer

### Mental model

Each runtime hands you a different **unit of responsibility**, and bills you for that unit:

- **Cloud Foundry hands you an app instance.** You give code and a memory size. The platform builds, places, restarts and routes it. You pay per GB of memory reserved.
- **Kyma hands you a cluster.** You get Kubernetes nodes and decide what runs on them: deployments, services, modules, sidecars. You pay for the nodes, whether full or empty.
- **The ABAP environment hands you an ABAP system.** You get application servers and a database, with ABAP Cloud's rules and released APIs. You pay for runtime and database capacity.

The smaller the unit, the less you run and the lower the floor. The larger the unit, the more you control and the more you operate. Choosing a runtime means choosing the smallest unit that still meets the workload's hard needs.

### How it works

```mermaid
flowchart TB
  subgraph SA[One BTP subaccount]
    subgraph CFO[Cloud Foundry org]
      SP[space: apps and service instances]
      ABAPI[ABAP environment instance<br/>created in a space]
    end
    subgraph K[Kyma cluster]
      NS[namespaces: pods, modules]
    end
  end
  ABAPI --> AS[ABAP system<br/>application servers + HANA Cloud]
  SP --> SVC[BTP services<br/>XSUAA, destination, HANA Cloud]
  NS --> SVC
```

SAP's [environments page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/environments-15547f7.md) says environments are anchored at subaccount level, and one subaccount can hold several. Users, authorizations and entitlements are then managed once for all of them. An ABAP system is created as a service instance in a Cloud Foundry space, so a subaccount with the ABAP environment has a Cloud Foundry org too.

#### Cloud Foundry: you push code

You push code or an image, and Cloud Foundry stages it with a **buildpack** (or takes the image as is), then runs instances. SAP's [BTP-specific configuration page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/sap-btp-specific-configurations-9809fa4.md) sets the limits an architect designs against:

| Limit | Value on SAP BTP |
| --- | --- |
| Memory per app instance | 16 GB, with a guaranteed quarter CPU core per GB (so up to 4 cores) |
| Disk per instance | Up to 10 GB |
| Application package | 1.5 GB |
| First health check | 60 seconds by default, raisable to 10 minutes |
| Concurrent HTTP connections | 3,000 per container |
| Log rate | 4,000 lines per second per instance by default |
| Audit events | Kept 14 days |
| SSH into apps | Off by default |

SAP's [supported features page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/supported-and-unsupported-cloud-foundry-features-f8a351c.md) adds what isn't there on BTP: container-to-container networking, isolation segments, TCP routing and CredHub credential delivery. Docker images, tasks, WebSockets and HTTP/2 are supported.

**Billing.** SAP's Cloud Foundry metering page says creating an org is free; runtime memory is billable. The monthly figure is the hourly memory reserved across all spaces of the global account, divided by 730 and rounded up to a full GB. Memory counts while it is reserved, so an idle instance costs the same as a busy one. A task that runs 20 minutes a night reserves memory only for those minutes.

#### Kyma: you get a cluster

Kyma provisions a Kubernetes cluster through the open-source project Gardener on AWS, Google Cloud, Azure or Alibaba Cloud, in the region you choose. You add **modules**: Istio, API Gateway and the SAP BTP Operator by default, and optional ones such as Eventing, Serverless, Telemetry, Keda and the Connectivity Proxy, listed on SAP's [Kyma modules page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/kyma-modules-0dda141.md). Access uses Kubernetes role-based access control and namespaces.

What Kyma has that Cloud Foundry on BTP lacks, per SAP's comparison guide: a service mesh, internal networking between workloads, streaming endpoints (RTMP, RTSP, WebRTC), and the full Kubernetes API for operators, custom resources and Helm charts. What it lacks: multitarget application (MTA) deployment and SAP Cloud Transport Management, for which SAP points Kyma users to Helm charts and a CI/CD pipeline.

**Sizing and billing.** SAP's comparison guide gives the minimum as three nodes of 2 CPU and 8 GB, with roughly 40% reserved to run the infrastructure. The provisioning parameters show three as the default and minimum *Auto Scaler Min* on the standard plans, and a default machine type of 2 vCPU and 8 GB. Billing is in **capacity units** per hour: SAP's [Kyma metering page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/service-plans-and-metering-for-kyma-runtime-c33bb11.md) gives 0.24 × 1.5 units per hour for a 2 vCPU node and 0.24 × 4 for an 8 vCPU node. 32 GB of storage is included; more is billed in 32 GB blocks. Kyma has no subscription-based commercial model.

A workload too big for the default nodes goes on an **additional worker node pool** with larger machines. SAP recommends high availability for such pools in production. Without it, the pool sits in one zone.

#### ABAP environment: you get an ABAP system

Each system has a dedicated SAP HANA Cloud database, linked 1:1, according to SAP's [ABAP environment page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/abap-environment-11d6265.md). Development follows **ABAP Cloud**: the RESTful application programming model, CDS and released APIs only, the same model used for extensions inside S/4HANA.

**Sizing and billing.** SAP's [ABAP metering page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/service-plans-and-metering-for-sap-business-ai-platform-abap-environment-b7f5a93.md) says a standard system needs at least 2 HANA Compute Units and 1 ABAP Compute Unit, metered hourly in 16 GB blocks. SAP's [ABAP Compute Units page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/50-administration-and-ops/abap-compute-units-7d1caa8.md) defines one ACU as 16 GB of memory and about four vCPUs. The [resilience page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/50-administration-and-ops/resilience-of-an-abap-environment-system-4f380f8.md) explains the multi-availability-zone option: ACUs stay the same, HCUs double because a second database instance runs in another zone.

**Hibernation.** SAP's [hibernation page](https://github.com/SAP-docs/btp-developer-guide/blob/main/docs/use-system-hibernation-6a8d7ee.md) says stopped systems use no ACUs and only minimal HCUs; costs can drop below 5% on consumption-based contracts. SAP starts stopped systems for upgrades and hotfix imports. The developer's guide says customers can nominate non-production systems for a pre-upgrade up to four weeks before the quarterly release upgrade.

#### Who operates what

SAP's [operating model](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/70-getting-support/operating-model-9aafc94.md) splits the work for Cloud Foundry and Kyma:

| Task | Cloud Foundry | Kyma |
| --- | --- | --- |
| Patch the operating system under your app | SAP, for buildpack apps; you restage | You, in your container images |
| Keep platform add-ons current | SAP provides new system buildpacks | You keep custom module configuration correct |
| Scale, monitor, report health | You | You, and you may need to configure platform resources |
| Back up data you deploy yourself | Not applicable | You, for storage you run in the cluster |
| Penetration or performance tests | Tell SAP first and ask for approval | Not listed as a Kyma task |

SAP's comparison guide also lists the release rhythm: bi-weekly Cloud Foundry updates and continuous delivery for Kyma modules. Both have a quarterly major upgrade window as the only contractually planned downtime.

### Build it yourself: Calder's runtime placement

You will write Calder's workload list, place each workload on a runtime with a script that encodes the rules above, compare the result with a partner's proposal, and turn it into a decision document. Everything runs on your computer with no account. One optional step checks a real trial subaccount.

```mermaid
flowchart LR
  I[--init] --> J[calder_workloads.json]
  J --> R[runtime_fit.py<br/>rules from SAP's limits]
  R --> T[placement and<br/>partner comparison]
  R --> U[--units<br/>billing units]
  R --> W[--write]
  W --> M[calder_runtime_decisions.md]
```

**Before you start:** complete [Set up your computer for this course](https://erpfde.com/topics/set-up-your-computer/) and [Set up for Unit 21](https://erpfde.com/topics/set-up-for-unit-21/). This walkthrough doesn't repeat their steps.

> **Note** New words. A **workload** is one thing that runs: an app, an API, a job. **JSON** is a text format for structured data. A **rule** here is a plain `if` in Python that turns a documented limit into a decision. A **billing unit** is what SAP meters (GB of memory, capacity units, compute units), before any price is applied.

#### What you need

- Python and your `orchestrate-course` folder with its `.venv`.
- No account for Steps 1 to 6. Step 5 optionally uses your trial and the btp CLI from the Unit 21 setup.
- About 40 minutes. Everything is free.

#### Step 1: Open the course folder and turn on the virtual environment

1. Open VS Code, choose **File > Open Folder**, and open `orchestrate-course`.
2. Open a terminal: **Terminal > New Terminal**.
3. If the prompt doesn't start with `(.venv)`, turn it on:

   - **Windows (PowerShell):**

     ```powershell
     .venv\Scripts\Activate.ps1
     ```

   - **macOS / Linux:**

     ```bash
     source .venv/bin/activate
     ```

4. The `unit21` folder exists from the setup topic. If it doesn't, create it with `mkdir unit21`.

#### Step 2: Create the script

1. In VS Code, create a new file `unit21/runtime_fit.py`.
2. Paste this code and save. It uses only Python's built-in modules, so `requirements.txt` gets no new lines.

```python
"""Place each of Calder's BTP workloads on a runtime: Cloud Foundry, Kyma, the ABAP environment,
or no BTP runtime at all (ABAP Cloud inside S/4HANA).

Usage (run from the course folder):
  python unit21/runtime_fit.py --init        write the workload list to unit21/calder_workloads.json
  python unit21/runtime_fit.py               place every workload and compare with the partner's proposal
  python unit21/runtime_fit.py --units       also show the monthly billing units per runtime
  python unit21/runtime_fit.py --available FILE
                                             check the placements against `btp --format json list
                                             accounts/available-environment` output saved in FILE
  python unit21/runtime_fit.py --write       write unit21/calder_runtime_decisions.md (the deliverable)

Built-in modules only. No account, no network, no randomness. Calder Pumpworks is fictional;
workloads, sizes and the partner's proposal are course values. The rules restate limits from SAP's
documentation as read on 2026-11-26; billing units follow SAP's metering pages, and the Kyma
node count is a course approximation, not SAP's sizing method.
"""
import argparse
import json
import math
import sys
from pathlib import Path

WORKLOADS = Path("unit21/calder_workloads.json")
REPORT = Path("unit21/calder_runtime_decisions.md")

CF, KYMA, ABAP, ONSTACK = "Cloud Foundry", "Kyma", "ABAP environment", "ABAP Cloud in S/4HANA"
SKILL = {CF: "cf", KYMA: "kubernetes", ABAP: "abap", ONSTACK: "abap"}

# Limits from SAP's documentation (read 2026-11-26)
CF_MAX_INSTANCE_GB = 16          # SAP BTP-specific configurations: max instance memory per app
CF_MAX_PACKAGE_GB = 1.5          # maximum application package size
CF_MAX_START_MIN = 10            # health check timeout can be raised to 10 minutes
KYMA_ONLY = {                    # needs the Cloud Foundry environment on BTP doesn't meet
    "tcp-inbound": "TCP routing isn't supported in the Cloud Foundry environment on SAP BTP",
    "internal-network": "container-to-container networking isn't supported in Cloud Foundry on SAP BTP",
    "service-mesh": "SAP's comparison lists service mesh support for Kyma only",
    "streaming": "SAP's comparison lists streaming endpoints (RTMP, RTSP, WebRTC) for Kyma only",
    "k8s-operator": "Kubernetes operators and custom resources need a Kubernetes cluster",
    "helm": "Helm charts deploy to Kubernetes",
}
CF_STRENGTHS = {
    "mta": "multitarget applications (MTA) are supported in Cloud Foundry, not in Kyma",
    "transport-cts": "SAP Cloud Transport Management is listed for Cloud Foundry; Kyma uses Helm and a pipeline",
}

# Metering (read 2026-11-26)
HOURS = 730                      # SAP divides Cloud Foundry GB-hours by 730 per month
KYMA_CU_PER_HOUR = {2: 0.24 * 1.5, 4: 0.24 * 2, 8: 0.24 * 4, 16: 0.24 * 8, 32: 0.24 * 16}
KYMA_NODE_CU_PER_HOUR = KYMA_CU_PER_HOUR[2]   # default 2 vCPU node; SAP's capacity unit table
POOL_SIZES = [(2, 8), (4, 16), (8, 32), (16, 64), (32, 128)]   # general-purpose vCPU, GB
KYMA_MIN_NODES = 3               # default and minimum Auto Scaler Min for the standard plans
KYMA_NODE_GB = 8                 # default machine type: 2 vCPU, 8 GB
KYMA_RESERVED = 0.40             # "roughly 40% reserved" on the minimum cluster (SAP comparison)
ABAP_MIN_ACU, ABAP_MIN_HCU = 1, 2
HIBERNATED_SHARE = 0.05          # SAP: hibernated systems can drop to less than 5% of total cost


def sample():
    def w(id_, name, team, language, packaging, mem, inst, hours, skills, proposed, **kw):
        d = {"id": id_, "name": name, "owner_team": team, "language": language,
             "packaging": packaging, "memory_gb_per_instance": mem, "instances": inst,
             "hours_per_month": hours, "team_skills": skills, "needs": [],
             "reuses_abap": False, "extends": "none", "writes_in_s4_transaction": False,
             "multi_az": False, "nonprod_hibernated_hours": 0, "proposed": proposed}
        d.update(kw)
        return d

    return {
        "company": "Calder Pumpworks (fictional)",
        "as_of": "2026-11-26",
        "note": "Production stage only. Dev and test add their own units. Course values.",
        "workloads": [
            w("W01", "Order-exceptions agent API (AGT_ORDER_EXC)", "AI platform", "python",
              "buildpack", 0.5, 2, 730, ["cf"], KYMA,
              purpose="Reads blocked sales orders in CP10 and drafts next steps"),
            w("W02", "Distributor order-status app (R03)", "Apps team", "node", "buildpack",
              1, 2, 730, ["cf"], KYMA, needs=["mta", "transport-cts"],
              purpose="CAP service and Fiori UI that Hallam and other distributors sign in to"),
            w("W03", "AI gateway calder-ai-gw (LiteLLM)", "AI platform", "container", "image",
              2, 2, 730, ["cf"], KYMA,
              purpose="Proxy in front of the generative AI hub for both agents, moving off its own hosts"),
            w("W04", "MES event listener (I02 successor)", "Integration", "java", "buildpack",
              1, 2, 730, ["cf"], KYMA, needs=["tcp-inbound"],
              purpose="Receives order confirmations that the Rockford MES pushes over plain TCP"),
            w("W05", "Intercompany price job (R08)", "SAP development", "abap", "abap",
              0, 0, 0, ["abap"], ABAP, extends="s4-cp10", writes_in_s4_transaction=True,
              purpose="Sets CP-IMP200's monthly price at cost plus 8% in CP10"),
            w("W06", "Test certificate archive", "SAP development", "abap", "abap",
              0, 0, 730, ["abap"], CF, reuses_abap=True, extends="cp10-and-cp20",
              nonprod_hibernated_hours=510,
              purpose="Reuses CP20's ECC certificate logic and serves CP10 and CP20 until the 2027 rollout"),
            w("W07", "Nightly notification coding batch", "AI platform", "python", "buildpack",
              1, 1, 20, ["cf"], KYMA,
              purpose="Codes closed maintenance notifications once a night as a task"),
        ],
    }


def place(wl):
    """Return (runtime, reasons, warnings) for one workload."""
    reasons, warnings = [], []
    if wl["language"] == "abap" or wl.get("reuses_abap"):
        if wl.get("extends") == "s4-cp10" and wl.get("writes_in_s4_transaction"):
            reasons.append("ABAP logic that changes data inside one S/4HANA system: build it "
                           "there with ABAP Cloud (developer extensibility), not on BTP")
            rt = ONSTACK
        else:
            reasons.append("ABAP code or skills that serve more than one system or stay apart "
                           "from S/4HANA: the ABAP environment runs ABAP Cloud on BTP")
            rt = ABAP
    else:
        kyma_needs = [n for n in wl.get("needs", []) if n in KYMA_ONLY]
        big = wl.get("memory_gb_per_instance", 0) > CF_MAX_INSTANCE_GB
        large_pkg = wl.get("package_gb", 0) > CF_MAX_PACKAGE_GB and wl["packaging"] != "image"
        slow = wl.get("start_minutes", 0) > CF_MAX_START_MIN
        if kyma_needs or big or large_pkg or slow:
            rt = KYMA
            reasons += [KYMA_ONLY[n] for n in kyma_needs]
            if big:
                reasons.append(f"{wl['memory_gb_per_instance']} GB per instance is above Cloud "
                               f"Foundry's {CF_MAX_INSTANCE_GB} GB limit")
            if large_pkg:
                reasons.append(f"package above Cloud Foundry's {CF_MAX_PACKAGE_GB} GB limit")
            if slow:
                reasons.append(f"start-up above Cloud Foundry's {CF_MAX_START_MIN}-minute health check limit")
            lost = [n for n in wl.get("needs", []) if n in CF_STRENGTHS]
            warnings += [f"loses: {CF_STRENGTHS[n]}" for n in lost]
        else:
            rt = CF
            reasons.append("no need Cloud Foundry can't meet; it bills from the memory the "
                           "app reserves, with no cluster to run")
            reasons += [CF_STRENGTHS[n] for n in wl.get("needs", []) if n in CF_STRENGTHS]
            if wl["packaging"] == "image":
                warnings.append("container image on Cloud Foundry: your team builds and patches "
                                "the image; only buildpack apps get the stack SAP patches")
            if wl.get("hours_per_month", HOURS) < 100:
                reasons.append("runs a few hours a month: as a Cloud Foundry task it reserves memory only while it runs")
    if SKILL[rt] not in wl.get("team_skills", []):
        warnings.append(f"skills gap: {wl['owner_team']} lists no '{SKILL[rt]}' skill")
    return rt, reasons, warnings


def units(wls, placed):
    """Monthly billing units per runtime, production stage only."""
    cf_gb_hours = sum(w["memory_gb_per_instance"] * w["instances"] * w["hours_per_month"]
                      for w in wls if placed[w["id"]][0] == CF)
    cf = math.ceil(cf_gb_hours / HOURS) if cf_gb_hours else 0
    kyma_ws = [w for w in wls if placed[w["id"]][0] == KYMA]
    kyma = None
    if kyma_ws:
        usable = KYMA_NODE_GB * (1 - KYMA_RESERVED)
        small = [w for w in kyma_ws if w["memory_gb_per_instance"] <= usable]
        mem = sum(w["memory_gb_per_instance"] * w["instances"] for w in small)
        nodes = max(KYMA_MIN_NODES, math.ceil(mem / usable))
        cu = nodes * KYMA_NODE_CU_PER_HOUR * HOURS
        pools = []
        for w in kyma_ws:
            if w in small:
                continue
            # an additional worker node pool: the smallest general-purpose size whose 90%
            # holds one instance, one instance per node (course simplification)
            vcpu, gb = next(((v, g) for v, g in POOL_SIZES if 0.9 * g >= w["memory_gb_per_instance"]),
                            POOL_SIZES[-1])
            pool_cu = w["instances"] * KYMA_CU_PER_HOUR[vcpu] * HOURS
            pools.append({"id": w["id"], "nodes": w["instances"], "vcpu": vcpu, "gb": gb,
                          "cu": round(pool_cu, 1)})
            cu += pool_cu
        kyma = {"memory_gb": mem, "nodes": nodes, "pools": pools, "cu": round(cu, 1)}
    abap = []
    for w in wls:
        if placed[w["id"]][0] != ABAP:
            continue
        hcu = ABAP_MIN_HCU * (2 if w.get("multi_az") else 1)
        prod_acu_h = ABAP_MIN_ACU * w["hours_per_month"]
        prod_hcu_h = hcu * w["hours_per_month"]
        run = HOURS - w.get("nonprod_hibernated_hours", 0)
        dev = {"acu_h": ABAP_MIN_ACU * run, "hcu_h": ABAP_MIN_HCU * run,
               "hibernated_h": w.get("nonprod_hibernated_hours", 0)}
        abap.append({"id": w["id"], "acu_h": prod_acu_h, "hcu_h": prod_hcu_h, "dev": dev})
    return {"cf_gb_months": cf, "kyma": kyma, "abap": abap}


def load(path):
    try:
        return json.loads(Path(path).read_text(encoding="utf-8"))
    except FileNotFoundError:
        sys.exit(f"{path} not found. Run: python unit21/runtime_fit.py --init")
    except json.JSONDecodeError as e:
        sys.exit(f"{path} is not valid JSON: {e}")


def report(data, show_units, available):
    wls = data["workloads"]
    placed = {w["id"]: place(w) for w in wls}
    print(f"{data['company']}: runtime placement as of {data['as_of']}\n")
    print(f"{'ID':4} {'Workload':45} {'Placed on':22} Partner")
    disagree = 0
    for w in wls:
        rt = placed[w["id"]][0]
        mark = "" if w.get("proposed") == rt else "  <- differs"
        disagree += bool(mark)
        print(f"{w['id']:4} {w['name'][:45]:45} {rt:22} {w.get('proposed', '-')}{mark}")
    print()
    for w in wls:
        rt, reasons, warnings = placed[w["id"]]
        print(f"{w['id']} {rt}")
        for r in reasons:
            print(f"   because {r}")
        for x in warnings:
            print(f"   WARNING {x}")
    if any(p[0] == KYMA for p in placed.values()):
        img = [w["id"] for w in wls if placed[w["id"]][0] == CF and w["packaging"] == "image"]
        if img:
            print(f"\nNOTE A Kyma cluster is needed anyway; {', '.join(img)} could share it "
                  f"instead of running its image on Cloud Foundry. Decide it in the record.")
    print(f"\n{disagree} of {len(wls)} placements differ from the partner's proposal.")
    if show_units:
        u = units(wls, placed)
        print("\nMonthly billing units, production stage (not money: apply your own rate card)")
        print(f"  Cloud Foundry   {u['cf_gb_months']} GB of runtime memory (GB-hours / 730, rounded up)")
        if u["kyma"]:
            k = u["kyma"]
            print(f"  Kyma            {k['nodes']} nodes of 2 vCPU / 8 GB for {k['memory_gb']} GB of "
                  f"workloads (floor: 3 nodes, even when idle)")
            for pl in k["pools"]:
                print(f"                  + {pl['id']}: extra pool of {pl['nodes']} node(s) of "
                      f"{pl['vcpu']} vCPU / {pl['gb']} GB = {pl['cu']} capacity units "
                      f"(one zone only; SAP recommends high availability pools in production)")
            print(f"                  = {k['cu']} capacity units")
        for a in u["abap"]:
            print(f"  ABAP env {a['id']}    prod {a['acu_h']} ACU-hours + {a['hcu_h']} HCU-hours; "
                  f"dev system {a['dev']['acu_h']} ACU-h + {a['dev']['hcu_h']} HCU-h running, "
                  f"{a['dev']['hibernated_h']} h hibernated (under 5% of cost)")
        if not u["abap"]:
            print("  ABAP            none")
    if available:
        text = Path(available).read_text(encoding="utf-8").lower()
        need = {CF: "cloudfoundry", KYMA: "kyma", ABAP: "cloudfoundry"}
        print(f"\nAvailable environments in {available}:")
        for rt, key in need.items():
            if any(p[0] == rt for p in placed.values()):
                ok = key in text
                why = " (an ABAP system is created in a Cloud Foundry space)" if rt == ABAP else ""
                print(f"  {'OK     ' if ok else 'MISSING'} {rt}: '{key}'{why}")
    return placed


def write(data, placed):
    wls = data["workloads"]
    u = units(wls, placed)
    rows = "\n".join(f"| {w['id']} | {w['name']} | {placed[w['id']][0]} | {w.get('proposed', '-')} | "
                     f"{'; '.join(placed[w['id']][1])} |" for w in wls)
    warn = "\n".join(f"- {w['id']}: {x}" for w in wls for x in placed[w["id"]][2]) or "- none"
    k = u["kyma"]
    kyma_line = (f"{k['nodes']} nodes, {k['cu']} capacity units a month" if k else "no cluster")
    REPORT.write_text(f"""# Calder Pumpworks: runtime decisions on SAP BTP

As of {data['as_of']}. Calder Pumpworks is fictional; workloads and sizes are course values.
Limits restate SAP's documentation as read on 2026-11-26.

### Placement

| ID | Workload | Runtime | Partner proposed | Why |
| --- | --- | --- | --- | --- |
{rows}

### Warnings to resolve

{warn}

### Monthly billing units (production stage)

- Cloud Foundry: {u['cf_gb_months']} GB of runtime memory
- Kyma: {kyma_line}
- ABAP environment: {', '.join(f"{a['id']} {a['acu_h']} ACU-h + {a['hcu_h']} HCU-h" for a in u['abap']) or 'none'}

Units, not money. Price them with the rate card from your contract or SAP Discovery Center.

### Decision record: default runtime for Calder's BTP workloads

- **Context:** (why Calder needs a default now; what the partner proposed)
- **Options:** (1) Kyma for everything, (2) Cloud Foundry by default with Kyma and ABAP by exception, (3) ...
- **Decision:** (which option, and the rule that sends a workload to the exception)
- **Consequences:** (skills, the Kyma floor, patching images, transports, what you review each year)
""", encoding="utf-8")
    print(f"Wrote {REPORT}. Fill in the decision record before the design review.")


def main():
    p = argparse.ArgumentParser(description="Place Calder's workloads on BTP runtimes")
    p.add_argument("--init", action="store_true", help="write the sample workload list")
    p.add_argument("--file", default=str(WORKLOADS), help="workload list to read")
    p.add_argument("--units", action="store_true", help="show monthly billing units")
    p.add_argument("--available", help="btp JSON of available environments for a subaccount")
    p.add_argument("--write", action="store_true", help="write the decision document")
    a = p.parse_args()
    if a.init:
        WORKLOADS.parent.mkdir(exist_ok=True)
        if WORKLOADS.exists():
            sys.exit(f"{WORKLOADS} already exists; delete it first to start again.")
        WORKLOADS.write_text(json.dumps(sample(), indent=2) + "\n", encoding="utf-8")
        print(f"Wrote {WORKLOADS}: {len(sample()['workloads'])} workloads with the partner's proposal.")
        return
    data = load(a.file)
    placed = report(data, a.units or a.write, a.available)
    if a.write:
        print()
        write(data, placed)


if __name__ == "__main__":
    main()
```

#### Step 3: Write the workload list and read it

1. Run:

   ```bash
   python unit21/runtime_fit.py --init
   ```

2. Expected:

   ```text
   Wrote unit21/calder_workloads.json: 7 workloads with the partner's proposal.
   ```

3. Open `unit21/calder_workloads.json`. Each workload has a language, how it is packaged (`buildpack`, `image` or `abap`), memory per instance, instance count, hours a month, the team's skills, special `needs`, and the runtime the partner `proposed`. All values are course values for the fictional Calder.

The seven workloads:

| ID | Workload | What is special |
| --- | --- | --- |
| W01 | Order-exceptions agent API (`AGT_ORDER_EXC`) | Python, 2 × 0.5 GB, always on |
| W02 | Distributor order-status app (R03 in the fit-to-standard topic) | CAP and Fiori, deployed as an MTA through transports |
| W03 | AI gateway `calder-ai-gw` (LiteLLM) | A container image; it moves off its own hosts |
| W04 | MES event listener | The Rockford MES pushes over plain TCP (a course assumption) |
| W05 | Intercompany price job (R08) | ABAP that changes prices inside `CP10` |
| W06 | Test certificate archive | Reuses `CP20`'s ECC ABAP logic and serves both company codes |
| W07 | Nightly notification coding batch | Python, 20 hours a month |

#### Step 4: Place the workloads

1. Run:

   ```bash
   python unit21/runtime_fit.py
   ```

2. Expected:

```text
Calder Pumpworks (fictional): runtime placement as of 2026-11-26

ID   Workload                                      Placed on              Partner
W01  Order-exceptions agent API (AGT_ORDER_EXC)    Cloud Foundry          Kyma  <- differs
W02  Distributor order-status app (R03)            Cloud Foundry          Kyma  <- differs
W03  AI gateway calder-ai-gw (LiteLLM)             Cloud Foundry          Kyma  <- differs
W04  MES event listener (I02 successor)            Kyma                   Kyma
W05  Intercompany price job (R08)                  ABAP Cloud in S/4HANA  ABAP environment  <- differs
W06  Test certificate archive                      ABAP environment       Cloud Foundry  <- differs
W07  Nightly notification coding batch             Cloud Foundry          Kyma  <- differs

W01 Cloud Foundry
   because no need Cloud Foundry can't meet; it bills from the memory the app reserves, with no cluster to run
W02 Cloud Foundry
   because no need Cloud Foundry can't meet; it bills from the memory the app reserves, with no cluster to run
   because multitarget applications (MTA) are supported in Cloud Foundry, not in Kyma
   because SAP Cloud Transport Management is listed for Cloud Foundry; Kyma uses Helm and a pipeline
W03 Cloud Foundry
   because no need Cloud Foundry can't meet; it bills from the memory the app reserves, with no cluster to run
   WARNING container image on Cloud Foundry: your team builds and patches the image; only buildpack apps get the stack SAP patches
W04 Kyma
   because TCP routing isn't supported in the Cloud Foundry environment on SAP BTP
   WARNING skills gap: Integration lists no 'kubernetes' skill
W05 ABAP Cloud in S/4HANA
   because ABAP logic that changes data inside one S/4HANA system: build it there with ABAP Cloud (developer extensibility), not on BTP
W06 ABAP environment
   because ABAP code or skills that serve more than one system or stay apart from S/4HANA: the ABAP environment runs ABAP Cloud on BTP
W07 Cloud Foundry
   because no need Cloud Foundry can't meet; it bills from the memory the app reserves, with no cluster to run
   because runs a few hours a month: as a Cloud Foundry task it reserves memory only while it runs

NOTE A Kyma cluster is needed anyway; W03 could share it instead of running its image on Cloud Foundry. Decide it in the record.

6 of 7 placements differ from the partner's proposal.
```

3. Read it from the bottom. Six of seven placements differ from the partner's proposal. Only W04 needs Kyma, because of the TCP traffic. W05 leaves BTP altogether. W06 goes the other way: the partner put it on Cloud Foundry, but it is ABAP code that serves two systems.
4. Read the two warnings. W03's image needs someone to patch it, and W04's team has no Kubernetes skills. Neither changes the placement; both go into the decision record.
5. Read the `NOTE`. Once Calder runs a Kyma cluster for W04, W03's image could share it. The script doesn't decide this, because it trades a patching and skills question against cost. You decide it in Step 6.

#### Step 5: Look at the billing units

1. Run:

   ```bash
   python unit21/runtime_fit.py --units
   ```

2. The end of the output:

   ```text
   Monthly billing units, production stage (not money: apply your own rate card)
     Cloud Foundry   8 GB of runtime memory (GB-hours / 730, rounded up)
     Kyma            3 nodes of 2 vCPU / 8 GB for 2 GB of workloads (floor: 3 nodes, even when idle)
                     = 788.4 capacity units
     ABAP env W06    prod 730 ACU-hours + 1460 HCU-hours; dev system 220 ACU-h + 440 HCU-h running, 510 h hibernated (under 5% of cost)
   ```

> **Note** These figures come from Calder's made-up workloads and show the method only; they are not results from a real SAP account. Units are not money: the price per GB, capacity unit or compute unit comes from your contract or the SAP Discovery Center estimator, and the script uses none.

3. Read the Kyma line. W04 needs 2 GB, but the cluster floor is three nodes: 3 × 0.36 capacity units an hour × 730 hours. That floor is why "Kyma for everything small" is rarely cheapest, and why sharing an existing cluster is a real option.
4. The Kyma node count is a course approximation (memory divided by the 60% of each default node left after the reserve). SAP's own [Kyma price calculator](https://kyma-project.github.io/price-calculator/) is the tool for a real estimate.

#### Step 6 (optional): Check your trial subaccount

This step needs your BTP trial and the btp CLI from the Unit 21 setup. Skip it if either is missing.

1. Log in as in the setup topic: `btp login --sso`.
2. List your subaccounts and copy the ID of your trial subaccount: `btp list accounts/subaccount`.
3. Save the environments that subaccount offers as JSON:

   - **Windows (PowerShell):**

     ```powershell
     btp --format json list accounts/available-environment --subaccount <ID> | Out-File -Encoding utf8 unit21/available_env.json
     ```

   - **macOS / Linux:**

     ```bash
     btp --format json list accounts/available-environment --subaccount <ID> > unit21/available_env.json
     ```

4. Run the check:

   ```bash
   python unit21/runtime_fit.py --available unit21/available_env.json
   ```

5. The end of the output lists each runtime Calder needs as `OK` or `MISSING`. The script only searches the file for the words `cloudfoundry` and `kyma`, so it doesn't depend on SAP's exact field names. A `MISSING` Kyma line on a trial is normal: SAP offers the Kyma trial only on request.

#### Step 7: Write the decision document

1. Run:

   ```bash
   python unit21/runtime_fit.py --write
   ```

2. The last line:

   ```text
   Wrote unit21/calder_runtime_decisions.md. Fill in the decision record before the design review.
   ```

3. Open `unit21/calder_runtime_decisions.md`. It holds the placement table, the warnings and the units. At the end is an empty decision record. Fill in the four lines, for example:

   - **Context:** seven workloads; a partner proposed Kyma for all non-ABAP ones.
   - **Options:** (1) Kyma for everything, (2) Cloud Foundry by default with Kyma and ABAP by exception, (3) option 2 with W03 moved onto the Kyma cluster.
   - **Decision:** your choice, with the rule that sends a workload to an exception.
   - **Consequences:** who learns Kubernetes for W04, who patches W03's image, the cluster floor in the budget, which apps use Cloud Transport Management.

4. Save your work in Git:

   ```bash
   git add unit21
   git commit -m "Unit 21: Calder runtime placement"
   ```

#### How the code works

| Part | What it does |
| --- | --- |
| Constants at the top | SAP's documented limits and metering factors, each with where it comes from |
| `KYMA_ONLY`, `CF_STRENGTHS` | Needs that only Kyma meets, and strengths only Cloud Foundry has, with the reason printed |
| `sample()` | Calder's seven workloads and the partner's proposal |
| `place()` | The rule order: ABAP in S/4HANA, ABAP environment, Kyma-only needs and limits, otherwise Cloud Foundry; then a skills check |
| `units()` | Cloud Foundry GB-hours / 730; Kyma nodes with a three-node floor and extra pools for large instances; ABAP compute unit hours with hibernation |
| `report()` | The table, reasons, warnings, the shared-cluster note and the `--available` check |
| `write()` | The markdown deliverable with an empty decision record |

#### If something goes wrong

| What you see | What it means | What to do |
| --- | --- | --- |
| `python` is not recognized, or `command not found` | Python isn't installed, or the terminal can't find it | Repeat the Python step of Set up your computer, then open a new terminal; on macOS/Linux use `python3` until `.venv` is active |
| `No module named ...` | You added an import, or pasted a different script | The script needs built-in modules only; paste it again from Step 2 |
| `calder_workloads.json not found` | Step 3 hasn't run | Run `python unit21/runtime_fit.py --init` |
| `already exists; delete it first` | `--init` won't overwrite your edits | Delete the file only if you want the sample back |
| `is not valid JSON` | A comma or quote is missing after an edit | VS Code marks the line in red; fix it and run again |
| `btp` says you are not logged in | No session, or it ended after 12 hours | `btp login --sso` (setup topic) |
| `btp` times out | A company proxy blocks SAP's hosts | Set `HTTPS_PROXY` (ask IT) or try another network; Steps 1 to 5 and 7 don't need the network |
| Every line `MISSING` in Step 6 | The file holds an error message, not JSON | Open the file; log in and repeat Step 6.3 with `--format json` |

### The SAP way

What SAP offers for each runtime, as of 26 November 2026:

- **Cloud Foundry.** Consumption-based: the `standard` environment plan plus the `MEMORY` plan of the Cloud Foundry Runtime service, with a default quota of 200 GB per subaccount. Subscription-based: memory is paid in advance. A `free` plan gives a limited memory quota, and `build-runtime` and `build-code` plans exist only for SAP Build. SAP's [comparison guide](https://github.com/SAP-docs/btp-runtime-comparison-guide/blob/main/docs/technical-details-3d371c1.md) lists the Application Autoscaler service for scaling and MTA plus SAP Cloud Transport Management for delivery.
- **Kyma.** Standard plans `aws`, `gcp`, `azure` and `alicloud` with three availability zones, build runtime plans for SAP Build, a `free` plan (one node on AWS, once per global account, up to 30 days, no upgrade to paid), and a trial on request for 30 days. Joule in Kyma dashboard helps with cluster troubleshooting, but SAP's [Joule in Kyma dashboard page](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/joule-in-kyma-dashboard-10c7fb8.md) says it isn't available in EU restricted access regions or with a custom OIDC client.
- **ABAP environment.** Plans `free` (stopped each night), `standard` (minimum 1 ACU and 2 HCU, mandatory combination with the `abap_compute_unit` and `hana_compute_unit` plans) and `saas_oem` for multitenant SaaS; a deprecated fixed 16 GB plan. The Landscape Portal handles hibernation, pre-upgrade nomination and add-on lifecycle. Elastic scaling of application servers between 1 ACU and a configured maximum is described in SAP's developer's guide.

Regions differ by runtime. Each has its own region page on help.sap.com ([Cloud Foundry](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/regions-and-api-endpoints-available-for-the-cloud-foundry-environment-f344a57.md), [Kyma](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/regions-for-the-kyma-environment-557ec3a.md), [ABAP](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/regions-and-api-endpoints-for-the-abap-environment-879f373.md)), and the lists aren't identical. Check the region of each subaccount against the page for the runtime it will hold.

> **Note** SAP's comparison guide is marked "Last update: July 2025". Its facts matched the November 2026 runtime pages read for this topic, but check it against the detail pages before you quote it in a design.

### Which runtime when

| Workload trait | Cloud Foundry | Kyma | ABAP environment | Inside S/4HANA |
| --- | --- | --- | --- | --- |
| Small Java, Node.js or Python service | Best fit | Works, cluster floor applies | No | No |
| CAP app deployed as an MTA with transports | Best fit | Works, with Helm and a pipeline | No | No |
| Container image, HTTP only | Works; you patch the image | Works; you patch the image | No | No |
| Plain TCP inbound, internal networking, service mesh, streaming | Not on BTP | Best fit | No | No |
| More than 16 GB per instance | Not possible | Best fit, larger node pool | No | No |
| Night batch of a few hours a month | Best fit, as a task | Works, as a Job; floor applies | Works, as an application job | Works, as an application job |
| ABAP code reused across several systems | No | No | Best fit | One system only |
| ABAP logic changing data inside one S/4HANA system | No | No | Possible, remote | Best fit |
| Team skills | Twelve-factor apps, CAP | Kubernetes, cloud native tools | ABAP Cloud | ABAP Cloud |

### Architecture view

**Where it sits.** Calder's placement after the rules, with Calder's own systems on the left:

```mermaid
flowchart LR
  S4[S/4HANA CP10<br/>W05 price job inside] 
  ECC[ECC CP20]
  MES[Rockford MES]
  subgraph BTP[BTP subaccounts]
    CF[Cloud Foundry<br/>W01 W02 W03 W07]
    KY[Kyma<br/>W04]
    AB[ABAP environment<br/>W06]
  end
  CF -->|released APIs via destinations| S4
  AB -->|released APIs| S4
  AB -->|RFC via Cloud Connector| ECC
  MES -->|plain TCP| KY
  KY --> S4
```

**Non-functional requirements that decide the runtime:**

| Requirement | Typical target | What breaks if it's missed |
| --- | --- | --- |
| Idle cost | Under the budget line set per workload | A three-node cluster carries one small service |
| Inbound protocol | HTTP for most; TCP for the MES | The listener can't be reached on Cloud Foundry |
| Memory per instance | 16 GB or less on Cloud Foundry | Deployment refused; needs Kyma and a larger pool |
| Availability | Two or more instances across zones | One instance or a single-zone pool stops in a zone outage |
| Patch window | Image updates within your vulnerability policy | Unpatched images in production |
| Release path | One transport route per app | Changes reach production untested |

**Integration and identity.** Each runtime reaches S/4HANA through released APIs and the destination service, and on-premise systems such as ECC `CP20` through the Cloud Connector ([Connectivity: Cloud Connector, destinations and private links](https://erpfde.com/topics/btp-connectivity/) covers both). Users sign in through the subaccount's identity provider in all three. The runtime changes where tokens live: service bindings in Cloud Foundry, Kubernetes Secrets created by the SAP BTP Operator in Kyma, and communication arrangements in the ABAP environment.

**The decision to record** (short ADR form from [the design-doc topic](https://erpfde.com/topics/writing-a-solution-design-doc/)):

- **Context:** seven workloads; a partner proposed one Kyma cluster for the non-ABAP workloads.
- **Options:** Kyma for all; Cloud Foundry by default with exceptions; the default plus shared use of the cluster W04 needs anyway.
- **Decision:** Cloud Foundry by default. Kyma only for documented needs (W04). ABAP inside S/4HANA when it changes `CP10`'s data (W05), the ABAP environment when ABAP serves several systems (W06). W03 stays on Cloud Foundry until the platform team has Kubernetes skills, then moves to the cluster.
- **Consequences:** one Kubernetes skill to build for W04; an image patch owner for W03; a cluster floor in the budget from day one; W06's development system hibernated outside working hours.

**What a design review will ask:**

1. Which documented limit sends each Kyma workload to Kyma?
2. Who patches each container image, and how fast after a vulnerability notice?
3. What is the idle cost per runtime, and who owns it?
4. For each ABAP workload, why inside S/4HANA or why outside?
5. Do the subaccount regions offer the runtimes placed in them?

### Production concerns

- **Security and authorizations.** In Cloud Foundry, space roles decide who can push; SSH stays off unless you need it. In Kyma, Kubernetes role-based access per namespace and SAP's Pod security recommendations apply. In the ABAP environment, business roles and communication arrangements control access, as in S/4HANA. Map each to Calder's roles before go-live.
- **Evaluation.** Test each workload where it will run. Health check timeouts, memory limits and log rates differ between runtimes.
- **Cost.** Set `memory` in every Cloud Foundry manifest. Size Kyma's Auto Scaler Max deliberately; SAP notes that cluster autoscaling isn't covered by the service level agreement. Hibernate non-production ABAP systems on a schedule.
- **Operations.** Restage buildpack apps when SAP ships new buildpacks. Track Kyma module updates, which reach the regular channel about two weeks after the fast channel. Nominate an ABAP test system for the pre-upgrade.
- **Clean core.** All three runtimes keep custom code out of S/4HANA's core. Logic built inside S/4HANA with ABAP Cloud also counts as clean core, as long as it uses released APIs; see [the integration platform and clean core topic](https://erpfde.com/topics/integration-platform-and-clean-core/).

### Where AI fits

Agents are workloads, so the rules above apply to them unchanged. As of 26 October 2026, SAP's [AI golden path for GenAI applications](https://architecture.learning.sap.com/docs/golden-path/ai-golden-path/build-and-deliver/genai-applications) calls its CAP-based reference architecture runtime-agnostic across Cloud Foundry and Kyma, and the golden path for agents lists pro-code agents as running on Cloud Foundry or Kyma. That matches Calder's W01 and W07 on Cloud Foundry. Model calls go to SAP AI Core, which runs outside your runtime, so the runtime doesn't need GPUs for that.

Two things to watch. SAP's [AI-native north star architecture](https://github.com/SAP/architecture-center/blob/dev/docs/north-star-arch/ai-native-northstar-arch/6-platform-layer/readme.md) (dated 23 October 2026) describes a **managed agent runtime** with sandboxing, memory and evaluations. It is a target architecture, not a product with a release status, so don't plan around it yet. And low-code agents built in Joule Studio need no runtime from you; [where should an agent live](https://erpfde.com/topics/where-should-an-agent-live/) compares that choice with your own code on BTP.

### Pitfalls

- **Choosing the runtime before the workloads.** List the workloads and their needs first; the runtime follows.
- **One cluster for everything small.** The three-node floor is paid even when the apps are idle.
- **Assuming "container" means Kyma.** Cloud Foundry runs images too; the need for Kubernetes comes from networking, mesh, operators or size.
- **Forgetting image patching.** Images on either runtime are yours to patch; only buildpack apps get the stack SAP patches.
- **Putting all ABAP on BTP.** Logic that changes one S/4HANA system's data usually belongs inside it.
- **Leaving ABAP development systems running.** Hibernate them outside working hours.
- **Quoting the comparison guide without its date.** It says July 2025; check the detail pages.

### Exercise

Add a workload that only Kyma can carry, and see what it does to the cluster.

1. Open `unit21/calder_workloads.json`.
2. Add this entry at the end of the `workloads` list. Put a comma after the closing `}` of W07 first:

   ```json
   {"id": "W08", "name": "Casting porosity image check", "owner_team": "Quality",
    "language": "python", "packaging": "image", "memory_gb_per_instance": 24,
    "instances": 1, "hours_per_month": 730, "team_skills": ["cf"], "needs": [],
    "proposed": "Cloud Foundry",
    "purpose": "Checks photos of castings from Tamsfield Foundry for porosity"}
   ```

3. Run `python unit21/runtime_fit.py --units`.
4. Expected: W08 is placed on Kyma because 24 GB is above Cloud Foundry's 16 GB limit, with a skills-gap warning for Quality. The Kyma lines show an extra pool:

   ```text
     Kyma            3 nodes of 2 vCPU / 8 GB for 2 GB of workloads (floor: 3 nodes, even when idle)
                     + W08: extra pool of 1 node(s) of 8 vCPU / 32 GB = 700.8 capacity units (one zone only; SAP recommends high availability pools in production)
                     = 1489.2 capacity units
   ```

5. Decide whether the pool needs high availability, which means more nodes across zones. Change `instances` to match your decision and run again.
6. Run `python unit21/runtime_fit.py --write` and add W08 to the decision record's consequences. The file feeds [observability on BTP](https://erpfde.com/topics/btp-observability/) and [BTP commercial models and cost control](https://erpfde.com/topics/btp-commercial-models-and-cost/).

**Done when** `calder_runtime_decisions.md` lists W08 on Kyma with its reason, the units show the extra pool, and the decision record says whether W08's pool runs in one zone or three, and why.

### Check yourself

1. What does each runtime hand you, and bill you for?
   - A. Cloud Foundry a cluster, Kyma an app instance, the ABAP environment a database only
   - B. All three hand you virtual machines and bill per vCPU hour
   - C. CF an app instance (memory), Kyma a cluster (nodes), ABAP a system (ACU, HCU)
   - D. Cloud Foundry and Kyma bill per request, the ABAP environment per user

   Answer: C. Cloud Foundry meters reserved memory, Kyma meters capacity units for nodes and storage, and the ABAP environment meters ABAP and HANA Compute Units in 16 GB blocks. The unit you are handed is the unit you pay for.

2. Calder's MES listener must accept plain TCP connections. Why does the script place it on Kyma?
   - A. Cloud Foundry on BTP limits apps to 3,000 connections per container
   - B. TCP routing is listed as unsupported in Cloud Foundry on SAP BTP
   - C. Cloud Foundry apps can't use the Connectivity service
   - D. Kyma has a higher service level agreement for integration

   Answer: B. SAP's supported features page lists TCP routing among the features not supported on BTP. The connection limit is real but doesn't block TCP; the service level agreement is the same for both runtimes.

3. How does Cloud Foundry turn memory into a monthly billing figure?
   - A. Peak memory used by any app during the month, rounded up
   - B. Memory actually used while requests are processed, measured each second
   - C. Memory quota assigned to the subaccount, whether used or not
   - D. Hourly reserved memory across all spaces, divided by 730 and rounded up

   Answer: D. SAP's metering page defines the GB Memory metric that way, based on the memory reserved per instance. So idle instances cost the same as busy ones, and a nightly task costs only its hours.

4. Why does the script print a Kyma floor of 788.4 capacity units for a 2 GB workload?
   - A. Kyma bills a fixed monthly licence for every cluster you create
   - B. Three 2 vCPU nodes at 0.36 units an hour, for 730 hours
   - C. Kyma rounds every workload up to 32 GB of memory
   - D. Storage beyond 32 GB is billed from the first gigabyte

   Answer: B. SAP's minimum is three nodes of 2 vCPU and 8 GB, and its table gives 0.24 × 1.5 capacity units per hour for such a node. Three nodes for 730 hours make 788.4, regardless of how little runs on them.

5. The partner wants W03's LiteLLM image on Kyma "because it is a container". What is the better argument?
   - A. Kyma is the only runtime that can run container images on BTP
   - B. Cloud Foundry patches container images automatically, so it is the safer home
   - C. Either runtime runs it, and you patch it either way; it's skills and cost
   - D. Images must go on Kyma because MTA deployments don't accept them

   Answer: C. Cloud Foundry on BTP supports Docker images, and SAP's operating model leaves image patching to the customer; only buildpack apps get the stack SAP patches. Moving W03 onto the cluster W04 already needs is a cost and skills trade-off.

6. When does ABAP logic belong inside S/4HANA rather than in the ABAP environment?
   - A. When it is a background job rather than an app with a UI
   - B. When the team lacks Cloud Foundry skills
   - C. When it needs SAP Fiori launchpad integration
   - D. When it changes data inside that one S/4HANA system

   Answer: D. Logic that changes one system's data runs in the same system and transaction as that data, with ABAP Cloud. The ABAP environment fits ABAP that serves several systems, like Calder's certificate archive for CP10 and CP20.

7. What does the ABAP environment's multi-availability-zone option do to billing?
   - A. ABAP Compute Units stay the same, HANA Compute Units double
   - B. Both ABAP and HANA Compute Units double
   - C. Nothing changes, because zones are included in every plan
   - D. ABAP Compute Units double, while HANA Compute Units stay the same

   Answer: A. SAP's resilience page says a second database instance runs in another zone, so HCUs increase by factor 2, while the application servers are only distributed, not added.

8. Your W08 image check needs 24 GB and runs on a one-node extra pool. A review asks about availability. What is the right answer?
   - A. Kyma's control plane spans three zones, so the pool is covered too
   - B. Autoscaling will add replacement nodes in other zones if that zone fails
   - C. It sits in one zone; production pools should enable high availability
   - D. Single-node pools aren't allowed, so the question can't arise

   Answer: C. SAP says an additional pool with high availability disabled is deployed in one zone and lacks zone-level failure tolerance, and recommends enabling it in production. Autoscaling isn't covered by the service level agreement either.

9. Which statement about SAP's runtime comparison guide is right?
   - A. It ranks Kyma above Cloud Foundry for production workloads
   - B. It compares all three runtimes and recommends ABAP for S/4HANA extensions
   - C. It requires one runtime per global account
   - D. It compares Cloud Foundry and Kyma only, and says the choice can be a combination

   Answer: D. The guide sends ABAP to the ABAP environment and compares only the two non-ABAP runtimes. It says the decision needn't be made up front or be binary, and it is marked as last updated in July 2025.

## Sources

- [Comparison: SAP BTP, Kyma Runtime and SAP BTP, Cloud Foundry Runtime (SAP-docs on GitHub, page marked last updated July 2025, read 2026-11-26)](https://github.com/SAP-docs/btp-runtime-comparison-guide/blob/main/docs/comparison-sap-btp-kyma-runtime-and-sap-btp-cloud-foundry-runtime-de5c964.md): ABAP goes to the ABAP environment, so the guide compares only Cloud Foundry and Kyma; same SLA levels and multi-AZ support; the decision need not be up front or binary; subpages on sizing (Kyma minimum 3 nodes of 2 CPU and 8 GB with roughly 40% reserved, Cloud Foundry from 1 GB with a quarter core, 16 GB per instance), skills, technical details (MTA and Cloud Transport Management for Cloud Foundry only, service mesh and internal network for Kyma only), protocols (streaming endpoints Kyma only) and release frequency
- [SAP BTP-Specific Configurations (Cloud Foundry environment, SAP BTP documentation)](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/sap-btp-specific-configurations-9809fa4.md): health check timeout up to 10 minutes; SSH off by default; CF API v3 only; quarter core per GB; 16 GB maximum instance memory; disk quota up to 10 GB; 1.5 GB maximum package; 4,000 log lines per second per instance; audit events kept 14 days
- [Supported and Unsupported Cloud Foundry Features (SAP BTP documentation)](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/supported-and-unsupported-cloud-foundry-features-f8a351c.md): Docker, tasks, WebSockets, HTTP/2 and custom domains supported; container-to-container networking, isolation segments, TCP routing and CredHub credential delivery not supported
- [Service Plans and Metering for Cloud Foundry Runtime (SAP BTP documentation)](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/service-plans-and-metering-for-cloud-foundry-runtime-8d41fa4.md): creating an org is free, runtime memory is billable; consumption-based default quota of 200 GB per subaccount; GB Memory metric is the month's hourly usage across all spaces divided by 730, rounded up; consumption means memory reserved per instance
- [Service Plans and Metering for Kyma Runtime (SAP BTP documentation)](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/service-plans-and-metering-for-kyma-runtime-c33bb11.md): no subscription-based model for Kyma; capacity units per hour for nodes (2 vCPU = 0.24 x 1.5, 4 vCPU = 0.24 x 2, 8 vCPU = 0.24 x 4) and storage (32 GB included, then 32 GB blocks at 0.02); free plan once per global account for up to 30 days
- [Available Plans in the Kyma Environment (SAP BTP documentation)](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/50-administration-and-ops/available-plans-in-the-kyma-environment-befe01d.md): trial only on request; free plan one node, AWS only, once per global account, no upgrade to paid; standard plans aws, gcp, azure, alicloud with high availability; build runtime plans for SAP Build; provisioning parameters show Auto Scaler Min default 3 and default machine type 2 vCPU, 8 GB
- [Service Plans and Metering for SAP Business AI Platform, ABAP environment (SAP BTP documentation, updated November 2026)](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/service-plans-and-metering-for-sap-business-ai-platform-abap-environment-b7f5a93.md): free plan stopped each night, community support only; standard plan minimum 2 HANA Compute Units and 1 ABAP Compute Unit; abap_compute_unit and hana_compute_unit metered hourly in 16 GB blocks; saas_oem plan for multitenant SaaS
- [Resilience of an ABAP Environment System (SAP BTP documentation)](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/50-administration-and-ops/resilience-of-an-abap-environment-system-4f380f8.md): multi-availability-zone option spreads application servers and adds a second HANA Cloud instance; ACUs unchanged, HCUs doubled; doesn't reduce upgrade downtime
- [Operating Model (Cloud Foundry and Kyma runtimes, SAP BTP documentation)](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/70-getting-support/operating-model-9aafc94.md): SAP patches the stack for buildpack apps, customers restage; customers build and patch images in Kyma and keep module configuration current; customers own app scaling, health reporting, monitoring and custom domains; Kyma customers back up storage they deploy
- [Use System Hibernation (SAP BTP Developer's Guide)](https://github.com/SAP-docs/btp-developer-guide/blob/main/docs/use-system-hibernation-6a8d7ee.md): stopped ABAP systems consume no ACUs and minimal HCUs; costs can drop below 5% on consumption-based contracts; SAP starts stopped systems for upgrades; free tier systems stop each night
