---
title: Serverless applications and servers
description: Choose between functions and a server, understand their isolation, and see how a serverless application serves pages and handles requests.
slug: /concepts/serverless-applications-and-servers
order: 20
visibility: public
redirects_from: []
---

# Serverless applications and servers

An application's kind is either serverless or server, chosen when you create it. A serverless application serves static files, runs functions for requests, or does both. A server runs your application in its own container.

## Choose the kind

Your AI tool chooses serverless unless the application needs something on the server list below. It tells you why in one line, including that functions share a process with other customers' functions and a server has its own container. It asks you before choosing a server if you are available; a server is charged for the time it is awake. It keeps your chosen size.

For a server with no size chosen and nobody to ask, it creates Shared 0.5 GB. It reports the size, that nobody was available, its awake-time charge and the option to request Shared 1 GB for more memory or CPU. A serverless application has no server charge. The [pricing page](https://dev.turnzero.ai/pricing) gives the rates. Use [Stay inside the Free Allowance](/cloud/guides/stay-inside-the-monthly-free-usage/) to check whether your choice fits your account’s Free Allowance.

Creation must name either a size, which makes a server, or the serverless kind with no size. The platform assigns no default. If the request specifies neither option, the refusal lists both choices.

Choose a server when the application needs any of these:

- WebSockets or another long connection.
- More CPU time or memory for one request than a function allows.
- A native module, child process or thread.
- An existing server, such as an Express or Next.js server.
- Work that continues after a request ends.
- A backend package not proved in a function.
- A library that uses Node's `http` or `https` modules, or its own HTTP client, instead of global `fetch`.
- A container of its own.

If you started with the default `server-hello` template and your app only needs static files or handlers that fit these limits, start from a serverless template. Use `static-site` for files alone, or follow [Deploy functions](/cloud/guides/deploy-functions/) for request handlers. [Change templates](/cloud/concepts/turnzero-command/#where-you-meant-another-template) explains how to replace an unedited starter.

Kind is fixed at creation in both directions. `set_app_size` refuses a serverless application's size or sleep change with 403 `serverless_unsupported`. Create a new server application for work that needs one. It has its own address and database; no platform act carries over the old application's hostname, database, files or secrets.

## How functions run

A function is a JavaScript module under `functions/` that receives a request and returns a response. A serverless application can use a database, schedules and outgoing calls to declared hosts. Its production database can move to a [dedicated size](/cloud/guides/choose-a-dedicated-database/) where that size is available. [Deploy functions](/cloud/guides/deploy-functions/) gives the file layout, limits and deploy steps.

For GET and HEAD, a matching [manifest redirect rule](/cloud/guides/serve-a-web-client/#redirect-an-exact-path) answers first. With no matching rule, a matching client file or folder page is served before a function. Functions handle any method on their own paths and paths beneath them. The longest matching function path wins. Only after neither a file nor a function matches does the platform use the site's not-found or root-page fallback.

Functions run only for requests, within limits on CPU time, memory, response time and temporary storage. They cannot accept WebSockets or keep work running after their response. Keep durable data in a database or Storage; a reused worker's memory and files are not durable.

## Jobs and schedules

A job runs a script to completion in its own container using a server application's image. A schedule sends recurring requests to a handler and can run on a serverless application. Declaring a job sets no time for it to start.

Where jobs are off, submissions with a `job` entry return `jobs_not_available` unless an earlier check refuses them. With jobs on, a serverless application that declares a job receives `serverless_no_job`.

## Isolation

Functions of different customers share a process. A server has its own container.

The shared process runs in a hardened sandbox on machines used only for functions. The platform limits each call's processing time and response time, each worker's memory, and each environment's calls running together in that process.

Each function runs in a separate worker inside that shared process. The platform supplies only its application's settings to the worker. A function that escapes its worker into the shared process could reach other serverless applications' settings, databases and files. A fault in the platform code that starts and handles calls could also let one application reach another application's data.

Choose a server if you need a container of your own.

## What a static site serves

A static site serves files and has no JavaScript function that handles requests. The platform serves the files of the version its environment serves, with no container of the application's own.

The site's files sit under `client/`, beside the manifest in the deploy folder. It needs no start script or health path. A root `package.json` or `lib/` folder is stored and unused: nothing is installed, built or run.

A path names a file or a folder’s `index.html`; a folder named without its closing slash redirects to the path with it. A GET or HEAD for a missing path receives your `client/404.html` with status 404, if that file stands. Otherwise, a request with no dot in the last part of its path receives the root `index.html`, if that file exists. Other missing paths receive 404 `not_found` as JSON.

Include `client/404.html` for your own not-found page. Leave it out when a single-page application needs the root page to handle its own paths after a reload. [Publish a static site](/cloud/guides/publish-a-static-site/) gives the folder layout, full path rules, bounds and deploy steps.

## Who can read a static site

A static site may be public or admit only people you invite. For an invited audience, the manifest declares the accounts service and the platform checks the visitor's session before reading any file.

A signed-in visitor you invited receives the site's files by the same path rules. Where a session is required, a page request (`GET` or `HEAD` accepting HTML) without one receives a 302 redirect to the platform's sign-in page; other requests without one are refused 401 `authentication_required`. A visitor outside the invited audience reads no file. The site runs no code of its own.

## Versions and operation

For static files alone, a deploy publishes the files without starting a process or running a health check. For functions, the platform installs dependencies and prepares the function files. If migrations are present, it applies them before the version serves. Promote and rollback make production serve a version already deployed.

A serverless application has no server to sleep or wake. Restart serves the same version again. Halt stops serving requests until resume. Deleting the application removes its version files, function files and settings. A rollback undoes no database migration.

A custom domain, where available, serves the production version by the same file rules ([Attach your own domain](/cloud/guides/attach-your-own-domain/)).

[Applications and environments](/cloud/concepts/applications-and-environments/) explains production, development and version history. [Manage versions and environments](/cloud/guides/manage-versions-and-environments/) gives the operations.

## Related

- [Deploy functions](/cloud/guides/deploy-functions/) writes request handlers and deploys them with optional pages and services.
- [Publish a static site](/cloud/guides/publish-a-static-site/) deploys pages, styles and images as a serverless application.
- [Serve a web client](/cloud/guides/serve-a-web-client/) serves files alongside an application's server code.
- [The manifest](/cloud/concepts/the-manifest/) describes the declarations an application submits.
