We now know what PaaS is, which types exist and who offers them. The practical question is what it is worth using it for, and also what it is not. Just as in IaaS Use Cases we saw that IaaS shines with legacy applications, disaster recovery or workloads that need control of the operating system, PaaS has its natural territory: the software the company itself writes or can adapt, with variable workloads and a wish to spend time on the product rather than on servers. Outside that territory, PaaS can turn into a source of frustration and unexpected bills. In this lesson you will go through the typical use cases with their "when to do it" and "when not to" criteria, the most frequent antipatterns, a table that summarises each case against its IaaS and SaaS alternatives, and three concrete Hortalia cases solved with commands: the store that scales by itself at Christmas, the stock API that queries the ERP without exposing it, and a scheduled task that emails the warehouse the order list every morning. We will finish with an illustrative estimate of what is saved by scaling for the peak season instead of keeping ten fixed servers.
- How to recognise a good PaaS use case
Before going through concrete cases, four questions that work as a quick filter:
| Question | If the answer is "yes"... | If it is "no"... |
|---|---|---|
| Is the code ours, or can we adapt it? | PaaS is viable | Probably IaaS (rigid third-party software) or SaaS |
| Does it use a language and versions the platforms offer? | Application PaaS or FaaS | Containers (if it can be packaged) or IaaS |
| Does the load vary a lot or is it unpredictable? | Autoscaling adds a great deal of value | PaaS is still valid, but the saving will come from operations, not from elasticity |
| Would we rather spend the team's time on the product? | PaaS removes server administration | If the team already has operations sorted and cheap, the benefit is smaller |
If all four answers are "yes", as is the case with hortalia-shop, we have a textbook case.
- Typical use cases
2.1 New web applications and APIs
The case par excellence: an application written in a popular language (Python, Node.js, Java, .NET), with no odd operating system dependencies.
- When to do it: new projects, small or medium teams, variable traffic, the need to deploy often with no downtime.
- When not to: if the application needs long-running processes inside the request, access to hardware or OS settings the platform does not allow.
2.2 Backends for mobile applications
A mobile app needs a server that handles users, data and notifications.
- When to do it: with an application PaaS or, to move faster, with a BaaS such as Firebase or Supabase, which already brings authentication, a database and storage.
- When not to: if the business logic is very specific or there are strict data location requirements the BaaS does not meet; in that case, your own backend on PaaS.
2.3 Microservices
Splitting a large application into small, independent services, each with its own deployment cycle.
- When to do it: with serverless containers (Cloud Run, Azure Container Apps) when there are several services and teams; with managed Kubernetes if there are many and there is a platform team.
- When not to: with a single developer and a medium-sized application. Microservices multiply deployments, networks and monitoring; for Hortalia, a well-structured application is enough.
2.4 Event-driven processes and scheduled tasks
Processing a file when it arrives, reacting to a new order, running a report every night.
- When to do it: with FaaS or container jobs: you pay only when they run and there is no server left on, waiting.
- When not to: processes that run for hours or need a lot of memory continuously; container jobs, batch services or a VM that is powered on just for the task are better.
2.5 Development and test environments per branch
Each code branch (a new feature, a fix) gets its own temporary environment to test it in.
- When to do it: Cloud Run or Container Apps revisions, App Service slots or the "preview environments" of platforms such as Render or Vercel let you create and destroy environments in minutes. Compare it with the ERP test VM, which Laura had to switch on and off on a schedule.
- When not to: if the environments need full copies of large databases, the cost and the time rocket; reduced test data is used instead.
2.6 Managed databases for in-house applications
Even if the application lives somewhere else, a managed database saves you patches, backups and high availability.
- When to do it: applications with standard engines (PostgreSQL, MySQL, SQL Server) that do not need exotic extensions.
- When not to: third-party software that demands administrator access to the engine, specific versions that are not offered or features of the database server's OS. This is, in fact, one of the open questions around Hortalia's ERP: its vendor demands SQL Server in exactly the configuration it has today.
2.7 Integration between systems
Connecting applications that were not designed to talk to each other: the store with the ERP, the CRM with invoicing.
- When to do it: with queues (Service Bus, SQS, Pub/Sub) to decouple them, with iPaaS (Logic Apps, EventBridge, Application Integration) for flows with connectors, or with your own API on PaaS acting as a façade.
- When not to: when the volume is tiny and a weekly manual export is enough. Not everything needs an integration architecture.
2.8 Prototypes and minimum viable products (MVPs)
Testing an idea with real users before investing in it.
- When to do it: whenever you want to go live fast. Developer-focused platforms or serverless containers with scale to zero are ideal: almost no cost if nobody uses it.
- When not to: when the "prototype" turns into production without anyone reviewing security, backups and costs. That is an organisational risk, not a technical one.
- Antipatterns: when PaaS is not a good idea
| Antipattern | Why it fails | Better alternative |
|---|---|---|
| Legacy applications with OS dependencies | They need a specific Windows Server, COM components, system services, access to the local disk or to the registry. The platform does not allow it, or it demands a rewrite | IaaS (like Hortalia's ERP) or, if one exists, the SaaS equivalent |
| Applications with state in the instance | Sessions in memory, files on the local disk: horizontal scaling breaks them | Adapt them first (twelve factors) or keep them on IaaS in the meantime |
| Strict latency requirements or special hardware | Low-latency trading, specific GPUs, licenses tied to hardware, proprietary drivers | IaaS with specific sizes or dedicated hosts |
| Costs at large, sustained scale | With heavy, constant load 24 hours a day, the premium you pay for convenience multiplies. Many large companies optimise by moving stable pieces to IaaS or to containers with usage commitments | Analyse the TCO (05-02); reserved instances or usage commitments |
| Very long processes inside a web request | The platform's time limits cut them off | Queues and background jobs |
| Total dependence on exclusive features with no exit plan | Every proprietary service adds lock-in; changing provider becomes a huge project | Standard code, containers, IaC and an exit analysis (05-04) |
| Scaling with no limit and no alerts | A bug or an attack multiplies instances and the bill | Maximum instance count, budgets and alerts |
- Summary: case, reason and alternatives
| Case | Why PaaS | IaaS alternative | SaaS alternative |
|---|---|---|---|
| New website or API | Fast deployment, scaling, no patching | VM with a web server: more control, more work | A SaaS commerce platform or CMS, if the business is standard |
| Mobile backend | BaaS or PaaS save you authentication, data and notifications | VM with your own API | Configurable SaaS apps (not very flexible) |
| Microservices | Serverless containers or managed Kubernetes | Your own cluster on VMs | Not applicable |
| Events and scheduled tasks | FaaS: pay per run, no server left on | VM with cron (on all day) | SaaS automation tools for simple cases |
| Environments per branch | Revisions, slots, ephemeral environments | One VM per environment, with a power-on schedule | Not applicable |
| Database for in-house apps | DBaaS: backups, patches and high availability included | The engine installed on a VM | The database included in a SaaS product |
| Integration between systems | Queues, iPaaS, a façade API | An integration server on a VM | Native connectors of the SaaS applications |
| Prototypes / MVPs | Almost no cost at rest, fast to launch | A small VM (which has to be administered) | No-code/low-code tools |
- Hortalia, case 1: the store that scales by itself at Christmas
Let us recall the sizing we set in module 1 (illustrative visits per hour): 300 in February (1 instance), 1,500 in summer (3) and 6,000 at Christmas (10). In Popular PaaS Providers, Marc planned the asp-hortalia-shop plan (Linux, Premium v3 P0v3) with a minimum of 2 instances for availability. Now he defines the autoscaling rules with Azure Monitor.
5.1 The base configuration
RG=rg-hortalia-shop
PLAN=asp-hortalia-shop
AUTOSCALE=autoscale-hortalia-shop
az monitor autoscale create \
--resource-group $RG \
--resource $PLAN \
--resource-type Microsoft.Web/serverfarms \
--name $AUTOSCALE \
--min-count 2 --max-count 10 --count 2az monitor autoscale create: creates an Azure Monitor autoscale setting. In App Service it applies to the plan, not to the application: every app in the plan shares its instances.--resourceand--resource-type Microsoft.Web/serverfarms: the resource being scaled;serverfarmsis the technical name of App Service plans.--min-count 2 --max-count 10 --count 2: never fewer than 2 instances, never more than 10, and 2 by default if there is no metric data.
5.2 The scale-out and scale-in rules
# Scale out: sustained high CPU
az monitor autoscale rule create --resource-group $RG --autoscale-name $AUTOSCALE \
--condition "CpuPercentage > 70 avg 10m" \
--scale out 2 --cooldown 5
# Scale out: requests waiting in the queue
az monitor autoscale rule create --resource-group $RG --autoscale-name $AUTOSCALE \
--condition "HttpQueueLength > 50 avg 5m" \
--scale out 1 --cooldown 5
# Scale in: sustained low CPU
az monitor autoscale rule create --resource-group $RG --autoscale-name $AUTOSCALE \
--condition "CpuPercentage < 30 avg 15m" \
--scale in 1 --cooldown 10--condition "CpuPercentage > 70 avg 10m": reads as "if the plan's average CPU usage over the last 10 minutes goes above 70%".CpuPercentageandHttpQueueLengthare App Service plan metrics.--scale out 2: adds 2 instances. During the Christmas peaks traffic rises quickly, and adding them two at a time gets there sooner.HttpQueueLength > 50: if there are more than 50 requests waiting to be served, the application is saturated even if CPU does not show it (for example, waiting for the database).--scale in 1 --cooldown 10: removes instances one at a time and waits 10 minutes between removals. Scaling in slowly avoids the "yo-yo" effect of removing an instance and putting it straight back.- Golden rule: the scale-out and scale-in thresholds must be far apart (70% against 30%). If they were 50% and 45%, removing one instance would push the CPU of the remaining ones above the threshold and the platform would add it back.
5.3 A special profile for the Christmas peak season
Autoscaling reacts to what is already happening; it takes a few minutes to add capacity. For a peak season you know about in advance, it is better to get ahead of it with a date-based profile:
az monitor autoscale profile create --resource-group $RG --autoscale-name $AUTOSCALE \
--name campana-navidad \
--start 2026-11-27 --end 2027-01-07 \
--timezone "Romance Standard Time" \
--min-count 4 --max-count 10 --count 4 \
--copy-rules default--name campana-navidad: a second profile that coexists with the default profile.--start/--endand--timezone "Romance Standard Time": active from 27 November (Black Friday) to 7 January, in Madrid time (Romance Standard Timeis the Windows identifier for the time zone of mainland Spain).--min-count 4: during the peak season, never fewer than 4 instances, even in the small hours. You pay a little more in exchange for not starting every morning "cold".--copy-rules default: copies the CPU and queue rules from the default profile so that they work in this profile too.
This is how the configuration looks in JSON (a simplified extract of what az monitor autoscale show returns), useful for keeping it in the repository as documentation or for deploying it with IaC:
{
"profiles": [
{
"name": "campana-navidad",
"capacity": { "minimum": "4", "maximum": "10", "default": "4" },
"fixedDate": {
"timeZone": "Romance Standard Time",
"start": "2026-11-27T00:00:00",
"end": "2027-01-07T23:59:00"
},
"rules": [
{
"metricTrigger": {
"metricName": "CpuPercentage",
"operator": "GreaterThan",
"threshold": 70,
"statistic": "Average",
"timeAggregation": "Average",
"timeGrain": "PT1M",
"timeWindow": "PT10M"
},
"scaleAction": {
"direction": "Increase",
"type": "ChangeCount",
"value": "2",
"cooldown": "PT5M"
}
}
]
}
]
}capacity: the profile's minimum, maximum and default values.fixedDate: the dates and time zone in which the profile is active; outside them the default profile applies.metricTrigger: the condition.timeGrain: PT1Mstates that the metric is sampled every minute;timeWindow: PT10M, that the average of the last 10 minutes is evaluated. The durations follow the ISO 8601 format:PT= "period of time",10M= 10 minutes.scaleAction: what to do.ChangeCountwithvalue: 2adds two instances;cooldown: PT5Mwaits 5 minutes before acting again.
5.4 What autoscaling does not solve
- The database. Ten instances with several processes each open a lot of connections to PostgreSQL. Marc has to use a connection pool (Azure Database for PostgreSQL Flexible Server includes PgBouncer as a built-in option) and review the size of the database for the peak season; a Burstable B1ms that is fine for the prototype will not be for Christmas.
- Slow code. If a page takes 3 seconds because of a query with no index, ten instances will serve it just as slowly. Scaling is no substitute for optimising.
- The cost. Laura adds an alert if the plan goes above 8 instances for more than an hour: it is not an error, but somebody should know about it.
Premium v3 also offers platform-managed autoscaling (based on HTTP traffic, where you only set the maximum). Marc prefers to start with explicit rules, which he understands and can explain to Sara, and to consider the managed option with real data from the first peak season.
- Hortalia, case 2: the stock API that queries the ERP without exposing it
Today, the store does not know the real stock: Sara updates a spreadsheet by hand every morning and, at Christmas, products that have sold out are still being sold. Marc wants the store to query the ERP's stock. The constraint is firm and Laura set it back in module 1: the ERP is not exposed to the internet.
6.1 The design
flowchart LR
C["Customers<br/>(internet)"] -->|HTTPS| SHOP["app-hortalia-shop<br/>(App Service)"]
subgraph VNET["vnet-hortalia-spaincentral 10.20.0.0/16"]
INT["snet-appsvc-int<br/>10.20.2.0/26<br/>(App Service integration)"]
PE["snet-privateendpoints<br/>10.20.3.0/27<br/>the API's private endpoint"]
ERP["snet-erp 10.20.1.0/24<br/>vm-erp-01 10.20.1.10<br/>SQL Server"]
end
SHOP -. "outbound through the VNet" .-> INT
INT --> PE
PE --> API["app-hortalia-stock-api<br/>(App Service, no public access)"]
API -. "outbound through the VNet" .-> INT
INT -->|"TCP 1433, read only"| ERP
ERP -. "VPN vpng-hortalia" .- ALM["Warehouse network<br/>192.168.10.0/24"]
The pieces of the design:
app-hortalia-stock-api: a small API (Flask) on the same plan as the store. It exposes a single operation:GET /stock/<code>. Why an intermediate API and not connect the store directly to SQL Server? Because that way the store does not know the ERP's schema (which the vendor may change in an update), least privilege is applied (the API only reads one view), and the result can be cached for a few seconds so as not to load the ERP at Christmas.- Virtual network integration (outbound): App Service does not live inside the VNet, but with VNet integration its outbound traffic to private addresses enters the VNet through a delegated subnet (
snet-appsvc-int). That way the API reaches10.20.1.10:1433and, if the ERP were still in the warehouse, it would reach192.168.10.0/24over the VPN. - Private endpoint (inbound): a private endpoint gives the API a private IP in
snet-privateendpointsand its public access is disabled. It can only be called from the VNet, that is, from the store. - The ERP's NSG: a new rule allows port 1433 only from the integration subnet.
- Read-only user: a SQL Server login
tienda_lecturawithSELECTpermission on av_stock_tiendaview, which Laura creates in agreement with the ERP vendor. Its password lives inkv-hortalia-shop.
6.2 The main commands
VNET_ID=$(az network vnet show --resource-group rg-hortalia-erp \
--name vnet-hortalia-spaincentral --query id --output tsv)
# 1. Delegated subnet for App Service integration
az network vnet subnet create --resource-group rg-hortalia-erp \
--vnet-name vnet-hortalia-spaincentral --name snet-appsvc-int \
--address-prefixes 10.20.2.0/26 \
--delegations Microsoft.Web/serverFarms
# 2. Integrate the API (and the store) with that subnet
az webapp vnet-integration add --resource-group rg-hortalia-shop \
--name app-hortalia-stock-api --vnet $VNET_ID --subnet snet-appsvc-int
az webapp vnet-integration add --resource-group rg-hortalia-shop \
--name app-hortalia-shop --vnet $VNET_ID --subnet snet-appsvc-int
# 3. Allow SQL Server only from the integration subnet
az network nsg rule create --resource-group rg-hortalia-erp --nsg-name nsg-snet-erp \
--name Permitir-SQL-AppService --priority 130 \
--direction Inbound --access Allow --protocol Tcp \
--source-address-prefixes 10.20.2.0/26 --source-port-ranges '*' \
--destination-address-prefixes 10.20.1.10 --destination-port-ranges 1433VNET_ID=$(...): stores the full identifier of the ERP's VNet in a variable, which is needed because the VNet is in a different resource group (rg-hortalia-erp) from the store's.az network vnet subnet create ... --delegations Microsoft.Web/serverFarms: creates the subnet and delegates it to App Service, that is, reserves it so the platform can place the apps' outbound interfaces in it. A/26(64 addresses) leaves room to scale: each instance uses addresses from the subnet.az webapp vnet-integration add: connects each application to the subnet. From here on, its connections to private addresses go out through the VNet.az network nsg rule create ... --priority 130: adds to thensg-snet-erpNSG (the one from 02-02) a rule allowing TCP 1433 from10.20.2.0/26to the ERP's IP. Priority 130 comes before theDenegar-Resto-VNetrule (4000), which will keep blocking the rest of the internal traffic.
The API's private endpoint is created with az network private-endpoint create (group sites) in snet-privateendpoints, together with the privatelink.azurewebsites.net private DNS zone so that the store resolves the API's name to its private IP; after that, the API's public access is disabled. These are networking steps that Laura reviews and documents in her Terraform code.
6.3 The API, in essence
import os
import time
import pymssql
from flask import Flask, abort, jsonify
app = Flask(__name__)
CACHE = {} # {code: (timestamp, units)}
CACHE_SECONDS = 60
def query_erp(code: str) -> int | None:
with pymssql.connect(
server=os.environ["ERP_SQL_HOST"], # 10.20.1.10
user=os.environ["ERP_SQL_USER"], # tienda_lectura
password=os.environ["ERP_SQL_PASSWORD"], # reference to Key Vault
database=os.environ["ERP_SQL_DB"],
login_timeout=5,
) as connection:
cursor = connection.cursor()
cursor.execute(
"SELECT unidades FROM v_stock_tienda WHERE codigo = %s", (code,)
)
row = cursor.fetchone()
return row[0] if row else None
@app.route("/stock/<code>")
def stock(code):
now = time.time()
if code in CACHE and now - CACHE[code][0] < CACHE_SECONDS:
return jsonify(code=code, units=CACHE[code][1], cache=True)
units = query_erp(code)
if units is None:
abort(404)
CACHE[code] = (now, units)
return jsonify(code=code, units=units, cache=False)- The connection is configured only with environment variables. In App Service,
ERP_SQL_PASSWORDis defined as a Key Vault reference (@Microsoft.KeyVault(...)): the platform reads the secret with the app's managed identity and the value never appears in the configuration or in the code. - The query uses a parameter (
%swith the tuple(code,)) and does not concatenate the code into the SQL text: that is how SQL injection is avoided. login_timeout=5: if the ERP does not answer, the API fails in 5 seconds instead of leaving the store's page hanging.- The in-memory cache (
CACHE) is a deliberate exception to the "stateless" rule: each instance has its own copy and it can be lost with no consequences, because all it does is avoid repeating queries for 60 seconds. If it were lost, the next request would query the ERP. What would not be acceptable is keeping something there that cannot be rebuilt.
- Hortalia, case 3: the order list for the warehouse at 06:00
Every morning, the warehouse manager prints the previous day's store orders in order to prepare the boxes. Today Marc does it by hand. Keeping a server on 24 hours a day for a job that takes a few seconds a day would be absurd: it is a perfect case for FaaS with a timer trigger.
Marc creates the func-hortalia-tareas function app on the Flex Consumption plan (with VNet integration so it can reach the store's private database; check that the plan is available in the chosen region). The code:
import base64
import csv
import io
import logging
import os
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
import azure.functions as func
import psycopg
from azure.communication.email import EmailClient
app = func.FunctionApp()
MADRID = ZoneInfo("Europe/Madrid")
@app.timer_trigger(schedule="0 0 4,5 * * *", arg_name="timer", run_on_startup=False)
def listado_almacen(timer: func.TimerRequest) -> None:
now = datetime.now(MADRID)
if now.hour != 6:
logging.info("It is %s in Madrid; not time to send", now.strftime("%H:%M"))
return
yesterday = (now - timedelta(days=1)).date()
with psycopg.connect(os.environ["DATABASE_URL"]) as connection:
rows = connection.execute(
"SELECT numero, cliente, producto, cantidad FROM pedidos "
"WHERE fecha::date = %s ORDER BY numero",
(yesterday,),
).fetchall()
output = io.StringIO()
writer = csv.writer(output, delimiter=";")
writer.writerow(["order", "customer", "product", "quantity"])
writer.writerows(rows)
email = EmailClient.from_connection_string(os.environ["ACS_CONNECTION_STRING"])
message = {
"senderAddress": os.environ["REMITENTE"],
"recipients": {"to": [{"address": os.environ["DESTINO_ALMACEN"]}]},
"content": {
"subject": f"Store orders for {yesterday:%d/%m/%Y} ({len(rows)})",
"plainText": "Attached is yesterday's order list.",
},
"attachments": [{
"name": f"orders-{yesterday}.csv",
"contentType": "text/csv",
"contentInBase64": base64.b64encode(
output.getvalue().encode("utf-8")
).decode(),
}],
}
email.begin_send(message).result()
logging.info("List sent: %d orders", len(rows))Explanation:
@app.timer_trigger(schedule="0 0 4,5 * * *"): the schedule uses the six-field NCRONTAB format: second, minute, hour, day, month and day of the week.0 0 4,5 * * *means "at 04:00:00 and at 05:00:00, every day".- Why 4 and 5, if we want 06:00? Because on the Flex Consumption plan timers work in UTC, and Madrid is on UTC+1 in winter and UTC+2 in summer. 06:00 in Madrid is 05:00 UTC in winter and 04:00 UTC in summer. The function wakes up at both moments and, with
ZoneInfo("Europe/Madrid"), checks the local time: it only carries on if it is 6 in Madrid. That way the clock change does not throw it off. (On dedicated App Service plans a time zone can be set with theWEBSITE_TIME_ZONEsetting, but not on the Linux serverless plans.) psycopg.connect(os.environ["DATABASE_URL"]): connects to PostgreSQL with the connection string from the configuration (again, a Key Vault reference). The query uses a%sparameter for the date.csv.writer(..., delimiter=";"): generates a CSV with semicolons, the separator that Excel in a Spanish locale opens correctly.EmailClient(Azure Communication Services Email): sends the email with the CSV attached, encoded in Base64.begin_send(...).result()waits for the send to complete. The sender and the recipient also come from the configuration.- Cost: two runs a day of a few seconds each. On pay per use, cents a month (illustrative). A small VM for the same job would cost tens of euros.
An alternative without code would be Azure Logic Apps (iPaaS) with a recurrence trigger and PostgreSQL and email connectors. Marc prefers the function because he already works in Python and the code stays in the repository next to the store's.
- Illustrative estimate: scaling for the peak season versus fixed servers
Sara asks the key question: "How much does all this save us?". Marc compares two options with the same instance type (P0v3, illustrative price of €60/month per instance):
- Option A, fixed: 10 instances all year round, sized for Christmas (the way you think with your own server: buy for the peak).
- Option B, autoscaling: a minimum of 2 instances; the rules and the peak-season profile add more as demand requires. Marc estimates the average number of instances for each month.
INSTANCE_PRICE_MONTH = 60 # € per P0v3 instance per month (illustrative)
# Estimated average number of running instances each month with autoscaling
average_instances = {
"jan": 2, "feb": 2, "mar": 2, "apr": 2, "may": 2, "jun": 3,
"jul": 3, "aug": 3, "sep": 2, "oct": 2, "nov": 3, "dec": 6,
}
fixed = 10 * INSTANCE_PRICE_MONTH * 12
autoscaling = sum(average_instances.values()) * INSTANCE_PRICE_MONTH
print(f"A) 10 fixed instances: €{fixed:>5,.0f}/year")
print(f"B) Autoscaling: €{autoscaling:>5,.0f}/year")
print(f"Saving: €{fixed - autoscaling:>5,.0f}/year "
f"({(fixed - autoscaling) / fixed:.0%})")average_instancesholds the monthly estimate: 2 for most of the year (the minimum for availability), 3 in summer and in November (Black Friday and the start of the peak season) and 6 on average in December (10 during the peak hours, 4 in the small hours thanks to the peak-season profile).fixedmultiplies 10 instances by the price and by 12 months.autoscalingadds up the monthly averages (instance-months) and multiplies by the price.- The
{value:>5,.0f}format right-aligns with a thousands separator and no decimals (Python uses the comma as the thousands separator).
Output:
The reading for Sara, with the necessary caveats:
- The saving on the application's compute is around €5,300 a year (~73%), all with illustrative prices.
- It does not include the database, which will also have to be sized for Christmas (and which, on a DBaaS, can be scaled up temporarily with a brief outage during the chosen window).
- It does not include Laura's and Marc's time, which on PaaS is less than with ten VMs to patch: that saving shows up in the full TCO in Costs and TCO.
- Option B depends on the rules working. Marc proposes a load test in October to verify them before the peak season.
Common Mistakes and Tips
- Moving an application that depends on the OS to PaaS "to see if it works". Review the dependencies first; if there are system components, IaaS or containers.
- Scaling thresholds that are too close together. They cause constant scaling out and in. Keep the thresholds far apart and use cooldowns.
- Relying only on reactive scaling for a peak season you know about. Get ahead of it with date-based profiles.
- Forgetting the database when scaling the application. More instances means more connections; use a pool and review the size.
- Connecting the store directly to the ERP's database. It couples the store to the vendor's schema and widens the permissions. A read-only façade API is safer and easier to maintain.
- Scheduling timers without thinking about the time zone. The clock change in March and October throws "at 06:00" tasks off if the plan works in UTC.
- Tip: for each use case, write one line saying "why PaaS" and "what we would do otherwise". If you cannot find a good answer straight away, it may not be a PaaS case.
Exercises
Exercise 1. For each situation, say whether PaaS is a good option and, if not, what alternative you would propose: a) a warehouse management application from a vendor that only works on Windows Server with a Windows service of its own; b) a new Node.js API so that the sales reps can look up prices from their phones; c) a process that generates 50 PDF invoices every night and takes 3 minutes; d) a video platform with very heavy, constant load 24 hours a day, with hundreds of servers; e) a temporary web form for a two-week lead generation campaign.
Exercise 2. Marc has configured these rules: add 1 instance if CPU goes above 55% for 5 minutes, and remove 1 if it falls below 50% for 5 minutes, with no cooldown. Explain what problem will show up and propose a better configuration.
Exercise 3. Redo the estimate in section 8 with two changes: a) the minimum becomes 1 instance outside the peak season (January-May and September-October), and b) the price per instance is €70/month. What is the new saving? What risk does Hortalia take on with change a)?
Solutions
Solution 1. a) No: it depends on the OS and on a Windows service; IaaS (a Windows VM) or the vendor's SaaS if one exists. b) Yes: application PaaS (or serverless containers). c) Yes, with FaaS or a container job: 3 minutes fits within the limits and it only runs at night. d) Probably not for everything: at that sustained scale, the cost of convenience weighs heavily; you would look at IaaS or containers with usage commitments, and perhaps PaaS for specific pieces. e) Yes: a platform with scale to zero or a SaaS forms solution; it gets destroyed when the campaign ends.
Solution 2. The thresholds are too close together (55% and 50%) and there is no cooldown. When an instance is added, the average CPU drops below 50%, the platform removes one, the CPU rises above 55% again, and so on: the "yo-yo" effect, with instances starting and stopping endlessly (and requests affected as they are recycled). Better: scale out if CPU > 70% for 10 minutes (+1 or +2, 5-minute cooldown) and scale in if CPU < 30% for 15 minutes (−1, 10-minute cooldown).
Solution 3. Averages: Jan-May 1 (5 months → 5), Jun-Aug 3 (9), Sep-Oct 1 (2), Nov 3, Dec 6 → a total of 25 instance-months. B = 25 × 70 = €1,750/year. A = 10 × 70 × 12 = €8,400/year. Saving = €6,650/year (~79%), illustrative. Risk: with a single instance, any failure or platform recycling leaves the store out of service for a few minutes, and scaling out for an unexpected peak starts from lower down. Compared with keeping the minimum at 2 at the same price (32 × 70 = €2,240/year), change a) saves only €490/year (7 months × 1 instance × €70) in exchange for less availability; Sara and Marc have to decide whether it is worth it. Common mistake: looking only at the saving and not at the cost of an outage in the middle of the selling season.
Conclusion
In this lesson you have gone through the natural use cases for PaaS (new web applications and APIs, mobile backends, microservices, event-driven processes and scheduled tasks, environments per branch, managed databases, integration between systems and prototypes) with their when-to and when-not-to criteria, and the antipatterns worth avoiding: legacy applications tied to the OS, state in the instance, special hardware requirements, costs at large sustained scale and scaling with no limits. At Hortalia you have configured the store's autoscaling with CPU and queue rules and a Christmas peak-season profile, you have designed a stock API that queries the ERP through the VNet with App Service integration, a private endpoint and a least-privilege NSG, and you have written a timer function that emails the order list to the warehouse every day at 06:00, taking the clock change into account. The illustrative estimate shows a saving of the order of 73% on compute compared with ten fixed servers.
We have talked a lot about isolated commands and fragments of code. The time has come to put it all into practice from start to finish. In Hands-on Exercise: Deploying a Web Application you will deploy, step by step, a reduced version of hortalia-shop on Azure App Service: you will test it locally, publish it, configure it with environment variables, look at its logs, do a zero-downtime deployment with a slot, scale it and, when you have finished, delete everything so you do not pay more than you need to.
