Deploying means getting another machine to run the same thing as yours, with different data, different secrets and people watching. A managed platform takes care of the server, the certificate, scaling and a good part of the network; in exchange it sets its own rules, and the application has to respect them. Almost every problem in a first deployment is an assumption that held true on your machine: that the disk persists, that there's a single process, that the database is right next door.

In this lesson you'll see what Next.js really requires, what kinds of platform exist and how to compare them, you'll prepare AgendaViva so it doesn't depend on the disk or on a single process, and you'll publish it on Vercel as a concrete example. Almost all the work applies to any other platform. The plan and limit details are from December 2026 and change often: check them before deciding.

  1. What Next.js requires

The documentation sums it up in one sentence: a Node.js server. A single next start process correctly runs every feature you've used. Everything else improves performance or becomes necessary when there are several processes:

Feature Streaming Shared cache, with several instances
Server Components, Server Actions Required No
Shell and holes (Cache Components) Required Recommended
Pages that revalidate (ISR) No Recommended
updateTag and revalidateTag No Recommended: without it, each instance finds out on its own
proxy.ts No No
after No No, but a shutdown that waits, yes
next/image No No; it needs the sharp library

"Required" in the first column means that, if something buffers the response, the page is still correct but arrives all at once at the end (04-04). That's how the official guide separates two qualities when evaluating a platform: functional fidelity (everything works, yes or no) and performance fidelity (the shell is served close to the visitor, cache notifications propagate quickly), which is a scale.

Static export (output: 'export') is ruled out: without a server there are no actions, holes, proxy or sessions.

1.1. Kinds of platform

Kind Examples the documentation mentions How it runs It fits if…
Node.js server or managed container Railway, Render, Fly.io, Google Cloud Run, DigitalOcean next start or your image You want a good old process without administering the machine
With a verified adapter Vercel, Bun The adapter transforms the build You want the platform to understand Next.js, and for that to be checked
With its own integration Cloudflare, Netlify, AWS Amplify, Firebase App Hosting, Deno Deploy… It depends You already work with that provider
Your own server Any machine with Docker Lesson 11-05 You want control, or you can't take the data off your premises

An adapter is a module that takes part in next build through a public API and produces what the platform needs. "Verified" has a precise meaning: it's open source, it runs the Next.js compatibility test suite and it lives in the nextjs organization on GitHub. At the time of writing, Vercel's and Bun's are; Cloudflare and Netlify are working on theirs and, in the meantime, offer their own integrations, where support for each feature can vary. Vercel's uses the same API as the others.

That makes it possible to compare without prejudice. The questions are the same for all of them:

  1. Does it stream responses? Does it support Cache Components with shell and holes?
  2. What happens with updateTag when there are several instances?
  3. Where are the servers, and where's the database?
  4. How long can a request last, and the after work?
  5. What body size does it accept? Our poster takes up to 2 MB.
  6. How do you schedule a task every five minutes?
  7. How do you go back to the previous version, and how long does it take?
  8. How is it billed, and what happens if a bot multiplies the traffic?
  9. What data do they process, in which country, and under what contract?
  10. How much would it cost to leave?

The ninth is a compliance question and can decide the matter on its own. The tenth is answered by what we'll do now: keeping whatever is specific to each platform at the edges.

  1. Preparing the application

2.1. The variables

The most common mistake is defining a variable in the wrong place. Ours are divided by when they're read:

Variable At build time At runtime Secret
NEXT_PUBLIC_SITE_URL Yes: it gets baked in Changing it does nothing No
ALLOW_INDEXING Yes: it goes in the headers No
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY Yes: it ends up inside Yes
NEXT_DEPLOYMENT_ID Yes No
DATABASE_URL Yes: the shells Yes Yes
WEATHER_URL, WEATHER_KEY Yes: the forecast is in the shell Yes The key
MAIL_*, OIDC_*, VENUES_SECRET, TASKS_KEY Yes Yes
STORAGE_* (section 2.2) Yes The keys
MAX_SPOTS_PER_BOOKING, SITE_NOTICE, TRUSTED_PROXIES, INTERNAL_URL, MAINTENANCE_MODE, ERRORS_URL, OTEL_* Yes No
EXPOSE_TESTING_API, QUERY_DELAY_MS Never in production
  • Each environment, its own values. At a minimum: development, preview and production. Never the production database in a preview, which runs unreviewed code.
  • Secrets aren't shared between environments. If the preview one leaks, production is untouched.
  • ALLOW_INDEXING=1 only in production, and at build time. If it's missing, the site responds with X-Robots-Tag: noindex (09-04): it's the first item on the launch-day checklist.
  • Mark the secret ones as such on the platform, so they can't be read back from its dashboard later.

2.2. Object storage

On a serverless platform the disk is read-only or disappears with the instance. The FileStorage interface from 06-05 was designed for this day:

// lib/storage/s3.ts — npm install @aws-sdk/client-s3
import 'server-only'
import {
  DeleteObjectCommand, GetObjectCommand, ListObjectsV2Command, NoSuchKey, PutObjectCommand, S3Client,
} from '@aws-sdk/client-s3'
import { readEnv } from '@/lib/env'
import { isImageKey } from '@/lib/images'
import type { FileStorage, StoredFile } from './types'

let client: S3Client | undefined // Reuses connections; stores nothing about anyone

function open() {
  const { s3Storage } = readEnv()
  if (!s3Storage) throw new Error('S3 storage is not configured')
  const { endpoint, region, bucket, key, secret } = s3Storage
  client ??= new S3Client({
    endpoint,
    region,
    credentials: { accessKeyId: key, secretAccessKey: secret },
  })
  return { client, bucket }
}

function check(key: string): string {
  if (!isImageKey(key)) throw new Error('Invalid file key')
  return key
}

export const s3Storage: FileStorage = {
  async save(key, content) {
    const { client, bucket } = open()
    await client.send(
      new PutObjectCommand({ Bucket: bucket, Key: check(key), Body: content }),
    )
  },

  async read(key) {
    const { client, bucket } = open()
    try {
      const object = await client.send(new GetObjectCommand({ Bucket: bucket, Key: check(key) }))
      return object.Body ? new Uint8Array(await object.Body.transformToByteArray()) : null
    } catch (error) {
      if (error instanceof NoSuchKey) return null
      throw error
    }
  },

  async remove(key) {
    const { client, bucket } = open()
    await client.send(new DeleteObjectCommand({ Bucket: bucket, Key: check(key) }))
  },

  async list() {
    const { client, bucket } = open()
    const files: StoredFile[] = []
    let continuationToken: string | undefined
    do {
      const page = await client.send(
        new ListObjectsV2Command({
          Bucket: bucket, Prefix: 'events/', ContinuationToken: continuationToken,
        }),
      )
      for (const { Key, LastModified } of page.Contents ?? []) {
        if (Key && LastModified && isImageKey(Key)) files.push({ key: Key, modifiedAt: LastModified })
      }
      continuationToken = page.NextContinuationToken
    } while (continuationToken)
    return files
  },
}

// lib/storage/index.ts
export function getStorage(): FileStorage {
  return readEnv().s3Storage ? s3Storage : diskStorage
}

In lib/env.ts, s3Storage follows the oidc model: an object if all five variables are present (STORAGE_ENDPOINT, STORAGE_REGION, STORAGE_BUCKET, STORAGE_KEY, STORAGE_SECRET) and null if none are; with some present and others not, an error on startup.

  • Many providers speak the S3 protocol. Switching from one to another is a matter of variables.
  • The bucket is private. Images still go out through /images/…, with our headers (06-05, 08-05), and the optimizer takes them from there: there are no remotePatterns and no changes to the CSP.
  • The credential, with the bare minimum: read, write, delete and list in that bucket, and nothing else.
  • Every poster passes through the function when it's uploaded and the first time it's optimized. At 2 MB, it fits within the 4.5 MB body limit that Vercel functions have by default; for larger files, the direct upload with a signed URL from 06-05.

2.3. The database

In 04-02 the pool had ten connections and lived as long as the process. When the platform creates and freezes instances, three problems appear:

Problem What happens Remedy
Instances × connections Twenty instances with ten each exhaust a PostgreSQL that allows a hundred A small pool and a middleman that shares them (PgBouncer or the provider's)
Frozen instances Timers don't run: idle connections aren't closed Close them before freezing; the platform offers a way
Distance Every query crosses an ocean The same region for both
// lib/db/client.ts
async function createDb(url: string, max: number) {
  const pool = new Pool({ connectionString: url, max, idleTimeoutMillis: 5000 })
  pool.on('error', (error) => log('error', 'db.connection', describeError(error)))

  if (process.env.VERCEL) {
    const { attachDatabasePool } = await import('@vercel/functions')
    attachDatabasePool(pool) // Closes idle connections before the instance freezes
  }
  return drizzle({ client: pool })
}

export type Database = Awaited<ReturnType<typeof createDb>>

const store = globalThis as typeof globalThis & { agendaVivaDb?: Promise<Database> }

export async function getDb(): Promise<Database> {
  await io()
  const { databaseUrl, queryDelay, dbConnections } = readEnv()

  if (queryDelay > 0) {
    await new Promise<void>((resolve) => setTimeout(resolve, queryDelay))
  }
  store.agendaVivaDb ??= createDb(databaseUrl, dbConnections)
  return store.agendaVivaDb
}

// lib/env.ts: DB_CONNECTIONS: integerWithDefault(10, 1, 50) → dbConnections

What's stored is the promise, not the result: if two requests arrive at the same time on startup, they share the same pool instead of creating two. The only provider-specific line is isolated and only loaded there (npm install @vercel/functions). Vercel's recommendation is to define the pool once, with a short idle timeout, and not to bring it down to one connection: its instances handle several requests at once and would get in each other's way.

With a middleman in transaction mode there are two things to know. SELECT … FOR UPDATE works, because it lives inside a transaction. Anything that depends on the session (named prepared statements, LISTEN, advisory locks) may not; we don't use any of that. Migrations, on the other hand, go through the direct connection: DIRECT_DATABASE_URL.

  1. Migrations that coexist

During a deployment there's a stretch of time when both versions of the code use the same database. And if something goes wrong, rolling back will leave the old code with the new schema. The rule that makes this possible is called expand and contract:

Step Deployment Schema Code
1. Expand A Adds the column, nullable or with a default The old code ignores it
2. Use A The new code writes the new one, and the old one if needed
3. Backfill Task Copies the old data in batches
4. Read B Only uses the new one
5. Contract C Drops the old one Nobody uses it

Renaming a column, then, takes three deployments. The migrations in this module follow the rule: new tables the previous code doesn't even look at. Two more precautions:

  • Watch out for locks. Creating an index on a large table blocks writes while it lasts; CREATE INDEX CONCURRENTLY doesn't, but it can't run inside a transaction. Adding NOT NULL scans the table. With a few thousand rows it doesn't matter; you need to know it before you have millions.
  • There's no automatic rollback. Drizzle doesn't generate reverse migrations, and undoing a DROP doesn't bring the data back. You fix forward, with another migration, or restore a backup.

The migration runs before the build, because the build queries the new schema (05-02). If the build then fails, the schema is ahead of the code: nothing happens, precisely because it's compatible.

  1. A deployment on Vercel

You connect the repository from its dashboard. From then on, every branch produces a preview with its own address, and the main branch produces production. What you need to write fits in two files:

{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "regions": ["fra1"],
  "buildCommand": "bash scripts/managed-build.sh",
  "crons": [
    { "path": "/api/tasks/send-notifications", "schedule": "*/5 * * * *" },
    { "path": "/api/tasks/clean-auth", "schedule": "40 3 * * *" },
    { "path": "/api/tasks/clean-files", "schedule": "10 4 * * *" }
  ]
}
#!/usr/bin/env bash
# scripts/managed-build.sh
set -euo pipefail

# Each environment has its own database
DATABASE_URL="$DIRECT_DATABASE_URL" npm run db:migrate

# Previews don't know their address until now
export NEXT_PUBLIC_SITE_URL="${NEXT_PUBLIC_SITE_URL:-https://$VERCEL_BRANCH_URL}"
npm run build
  • regions next to the database. By default functions run in a United States region; with PostgreSQL in Europe, every query from every hole would cross the Atlantic.
  • VERCEL_BRANCH_URL is set by the platform. In production you set NEXT_PUBLIC_SITE_URL by hand, with the public domain.
  • NEXT_DEPLOYMENT_ID isn't needed: with skew protection enabled, the platform sets the identifier.
  • next build doesn't use output. The standalone option from the next lesson is for containers.

4.1. Tasks, via GET

Its scheduler calls with GET, sends Authorization: Bearer with the value of the CRON_SECRET variable, doesn't retry and may call twice. Our tasks expect a POST. 07-04 already announced the exception:

// app/api/tasks/send-notifications/route.ts (and the other two)
export const maxDuration = 120

async function run(request: Request): Promise<Response> {
  // Reads the request: outside guarded, so the GET isn't prerendered (07-01)
  const authorized = hasBearerKey(request, readEnv().tasksKey)

  return guarded(async () => {
    if (!authorized) return errorResponse('unauthorized', 'Invalid key.')
    const result = await sendNotifications()
    log('info', 'notifications.sent', { ...result })
    return Response.json(result)
  })
}

export const GET = run
export const POST = run

Set CRON_SECRET to the same value as TASKS_KEY. Making the tasks repeatable, able to overlap harmlessly and reporting failure with a 500 wasn't a whim: it's what a scheduler like this demands. The key is fixed per deployment; changing it means deploying again. The free plan only allows one run per day per task, which isn't enough for the outbox: with it, you'd need another scheduler calling from outside. The documentation also warns that this feature will be replaced by another one, called Schedules. It's a good example of why the task is an endpoint of ours and not a file in their format.

4.2. The limits that affect us

Aspect On Vercel (December 2026) AgendaViva
Disk Read-only; /tmp per instance S3 storage
Duration 300 s by default on every plan maxDuration of 30, 60 and 120
Request body 4.5 MB by default bodySizeLimit of 2.2 MB
Response body 4.5 MB, unless streamed Posters of up to 2 MB
Visitor IP Overwrites X-Forwarded-For TRUSTED_PROXIES=1
Process memory Shared between nearby requests, and lost Nothing depends on it
Variables Changing them doesn't affect what's deployed Maintenance mode requires a deployment

The last row is a surprise. MAINTENANCE_MODE=1 does nothing until the next deployment; for an emergency, use the firewall or a rollback. Also check which uses your plan allows before going live.

4.3. Previews

A copy for every change, with its own address, is the biggest advantage of these platforms: people who don't program see the change before it's merged. It's also a copy of the application on the internet:

  • Protect them. Standard protection requires signing in everywhere except on the production domain; check that it's the one your project has, because it's configured per team and per project. On top of that, the platform adds noindex, and so does our header, because ALLOW_INDEXING doesn't exist there.
  • With their own database. Several PostgreSQL providers create a data branch per preview. If not, a single shared, seeded one; scripts/seed.ts refuses to run outside local, and it should stay that way, so the sample data is loaded from a prepared copy.
  • Never with real data. Not even "a copy from yesterday".
  • No email. With an empty MAIL_URL nothing goes out, and the outbox piles up notifications nobody will receive.
  • The proxy check fails towards the harmless option. eventExists will call a protected address and get a 401, which isn't a 404, and will let the request through (07-02). Real 404s are checked in production.
  • The identity provider doesn't know those callback addresses. It's tested with a fixed environment, or left switched off.

4.4. The domain

You add it in the dashboard, create the DNS records it tells you to, and the certificate is obtained automatically. Choose one form, with www or without it, and redirect the other one permanently. Then:

D=https://agendaviva.example
curl -sI $D | grep -iE 'HTTP/|x-robots-tag|strict-transport|content-security'
curl -sI http://agendaviva.example | grep -iE 'HTTP/|location'      # Redirect to https
curl -s $D/robots.txt; curl -s $D/sitemap.xml | head -n 5           # With the right domain
curl -s $D | grep -o '<link rel="canonical"[^>]*>'
curl -s -o /dev/null -w '%{http_code}\n' $D/events/does-not-exist   # 404
node scripts/watch-response.mjs $D/events/jazz-night                # Does it arrive in chunks?
curl -s -X POST $D/api/tasks/send-notifications -o /dev/null -w '%{http_code}\n'  # 401

x-robots-tag: noindex mustn't appear, and localhost mustn't appear anywhere. The session cookie carries __Host- and Secure: sign in and check that it's stored.

Strict-Transport-Security starts at one day (08-05). It's extended to weeks and then to a year once everything hanging from the domain works over HTTPS.

  1. Caching with many instances

In a single process, the three caches involved look like one. Once they're spread out, you see them separately:

What In one process On a platform like Vercel
Pages and shells (ISR) Memory and disk Durable storage and a distribution network; invalidation propagates to every region
'use cache' Process memory Memory of each instance: it doesn't last long
'use cache: remote' The same memory A shared store, per region

What was computed at build time is in the shell and doesn't suffer. What's cached during the request does: with instances that are born and die, 'use cache' hardly ever hits. AgendaViva has three functions like that, the ones that depend on searchParams. They're the candidates 05-02 flagged:

// lib/data/events.ts
async function queryCachedEvents(category: Category | null, district: string | null, page: number) {
  'use cache: remote'
  cacheLife('listings')
  cacheTag(EVENTS_TAG, VENUES_TAG)
  // … unchanged
}

// lib/data/venues.ts: listDistricts and listVenueSummaries, which the filter form uses
'use cache: remote'
  • Few keys and lots of use: categories times districts times five pages is about a hundred entries. Text search stays uncached: each key would be used once.
  • It isn't free. Every hit is a trip over the network and, depending on the platform, a charge. If the query takes 5 ms and is right next door, the remote cache can be slower. You add it to protect the database, not out of habit.
  • On a single server it's harmless: without configuring cacheHandlers, it uses the same memory as the other one.
  • It doesn't survive a deployment. The key includes the deployment or build identifier, so every version starts cold. That's deliberate, because the shape of the data may have changed.
  • Tags work the same way. invalidateEvent doesn't notice the change.
  • Event pages and the home page stay as they were. Their place is the shell.

5.1. The distribution network

10-01 promised to talk about the CDN. The files in /_next/static/ have a one-year lifetime and a hashed name: anyone can store them without risk. Documents are another matter, because a generic CDN doesn't understand tags: it would keep /events for as long as s-maxage says, even if you've called updateTag. If you put one in front yourself, the documentation asks for it to include the _rsc parameter in the key, forward the rsc header, not store the HTML and the payload separately, and for you to purge it along with the invalidation. Our pages contain request holes; the prudent thing is for the CDN to store only static files and images and let documents through. An integrated platform does that work, and it's a good part of what you pay for.

  1. Rolling back

A deployment that can be undone in seconds is less scary, and what's less scary gets done more often, in smaller changes. Vercel calls it Instant Rollback: it points the domain at an earlier deployment, without rebuilding. Before you need it, learn what it does not undo:

It undoes It doesn't undo
The code and static files The schema and the data
The build configuration Emails already sent
Scheduled tasks, back to the ones from then A leaked secret
The variables: it uses the ones from that deployment, even if you've changed them since

The last row is dangerous if, in the meantime, you rotated a secret because it leaked: the restored version uses the old one. And after a rollback, the platform stops automatically publishing new changes until you turn it back on; it's easy to forget and believe the fix is already in production.

The other effect of having two versions is skew: someone who had the page open requests scripts or actions that no longer exist. With a deployment identifier, Next.js detects it on the next navigation and reloads the whole page. The platform can also route each person to their own version for a few hours. Check it with a tab left open during a deployment, especially with a half-filled form.

  1. What it costs

A platform that scales on its own also bills on its own. These are the usage items that depend on how we've written the application:

You pay for… What triggers it in AgendaViva How to contain it
Invocations and CPU LiveAvailability every 20 s per tab; the proxy's existence check Polling only with the tab visible; moving to 30 s
Proxy Runs on almost every route A tight matcher (07-02)
Optimized images Every width of every poster Correct sizes, localPatterns (09-02)
Page revalidations listings every 15 minutes when there's traffic Longer lifetimes, and invalidating on change
Prefetches Every visible link IntentLink with intent (10-02)
Remote cache Filter reads Only what's in section 5
Database Size, and active hours The tasks every five minutes keep it from going to sleep
Data transfer Posters and static files Modern formats, long caching

The second-to-last one is a classic: a database billed by active hours and a task that wakes it up twelve times an hour. It's not that it's wrong; it's that you have to know.

Set a budget with an alert and, if the platform allows it, a hard cap. Decide beforehand what you'd rather happen if it's reached: the site stops, or the bill grows. A bot crawling every combination of filters can multiply a day's usage by a hundred; the firewall's rate limit is also a spending tool.

Common Mistakes and Tips

  • Choosing a platform based on the first demo and not on the ten questions.
  • Setting at runtime a variable that's baked in at build time.
  • Forgetting ALLOW_INDEXING, or setting it in a preview with its own domain.
  • Writing to the disk of a function.
  • A large pool per instance, or migrations through the middleman.
  • Functions and database on different continents.
  • Renaming a column in a single deployment.
  • Previews against the production database.
  • Relying on 'use cache' during the request on a serverless platform.
  • Putting remote on everything.
  • Believing that rolling back undoes the data.
  • A generic CDN that stores documents and knows nothing about tags.
  • Not setting a spending limit.

Exercises

Exercise 1: evaluating a platform

Choose a provider other than Vercel and answer the ten questions from section 1.1 using its documentation, noting the date. Then say which AgendaViva files would change to deploy there.

Solution

The answer depends on the one you choose; what's being assessed is the method. For a managed container with a single instance, for example, the usual answers will be: (1) it streams, if its load balancer doesn't buffer, and you have to measure it with watch-response.mjs; (2) with one instance, invalidation is correct without doing anything; (3) you choose the region; (4) no duration limit of its own, but the load balancer's applies; (5) the load balancer's; (6) there's usually a scheduler, or you use the CI one; (7) go back to the previous image; (8) by size and hours, more predictable; (9) contract and country; (10) not much, because it's a standard image.

Files: the Dockerfile (11-05) and the provider's configuration are added; vercel.json and managed-build.sh are no longer needed; lib/db/client.ts doesn't change, because the specific line depends on process.env.VERCEL; the tasks accept both methods. A short list is exactly the result we were after.

Exercise 2: a delicate migration

You need to split users.name into name and last_name. Write out the deployments, what each one does with the schema and the code, and what would happen at each step if you had to roll back.

Solution

  1. Expand. A nullable last_name text column. The code doesn't change. Rolling back: no effect, the old code ignores it.
  2. Write. Sign-up asks for both fields; name still holds the full text for anyone reading it, and last_name is filled in. Rolling back: the old code writes only name, in full; there are rows without a last name, which will be filled in later.
  3. Backfill. There's no reliable rule for splitting a name, and getting someone's name wrong is disrespectful. It's left null, and the account asks the person to complete it next time.
  4. Read. The code uses name and last_name, accepting nulls. Rolling back: only name is shown.
  5. Contract. When there are no nulls left, or never: NOT NULL only if the business really requires it.

The useful conclusion is that step 3 turns the change into a process that takes months. Often the right question is whether they need splitting at all.

Exercise 3: the bill

A month after launch, function usage is five times what was forecast and traffic is as expected. Propose the order in which you'd look into it, with what data, and two changes that don't make the experience worse.

Solution

First, which routes are being invoked: almost certainly /api/events/[slug]/availability, because an event page left open for eight hours makes 1,440 requests. SWR already stops polling when the tab is hidden unless told otherwise; check that nobody set refreshWhenHidden, and raise the interval to 30 s, or to 60 s when there are plenty of spots left, which is when the figure matters least.

Second, who: if there are thousands of filter combinations from a few addresses, it's a bot. A limit in the firewall, and the filters with noindex already keep search engines from insisting (09-04).

Third, the prefetches: look at how many requests carry next-router-prefetch and whether IntentLink is still used in the lists.

Fourth, the proxy's existence check, which doubles every event page. With INTERNAL_URL unset it goes out to the internet and comes back in, paying twice. If the exact 404 isn't worth its price, it's removed: 07-02 already said that a 200 with noindex is a reasonable response. It's a decision, and therefore an ADR.

Conclusion

Next.js asks for a Node.js server that streams; the rest is performance and coordination. To leave your machine, AgendaViva has learned not to depend on the disk, to share a few connections, to migrate without the versions getting in each other's way, and to tell what's baked in at build time from what's read at runtime. A managed platform provides the certificate, scaling, previews and rollback, and charges by usage: it's worth knowing which lines of code generate that usage. What's platform-specific has ended up in a JSON file, a script and one line.

The other half of the decision is doing it yourself. In Deploying to Your Own Server with Docker you'll build the image, put NGINX in front and take charge of what someone else did here: shutdown, backups and the second instance.

© Copyright 2026. All rights reserved