Serverless

You might say

I only have a small feature. Is there a way to run code on demand without buying or managing a server?

Run backend code on demand without managing a long-running serverA serverless function is deployed to a managed platform and starts when an HTTP request, schedule, or event triggers it. It reduces server operations for small independent tasks, but runtime limits, cold starts, regions, and stateless execution still shape the design.
RequestPOST /api/contact
⚡ FunctionPlatform starts on demand
Response200 OK
The instance is 0 when there are no requests · Billed by the number of runs

When to use it

  • Small API endpoint
    Good for short, event-driven tasks
    HTTPSubmit formWebhookPayment webhookCronDaily summary
  • Webhook handler
    Deploy frontend and functions together
    git pushBuild page + APIGet a URL
    The platform can host the runtime, but you still manage configuration, monitoring, and cost.
  • Scheduled task
    Keep state in an external service
    RequestShort-lived functionDatabase / storage
  • Event-driven processing with irregular traffic
    Put secrets in platform settings
    Environment variablesAI_API_KEY = ••••••••Git repositoryNo secrets included

When NOT to use it

  • Keep important state only in function memory
    Task exceeds the function time limit
    Video transcodingEstimated 10 minutes Function limitTimes out after 10 seconds
  • Run a long job beyond the platform limit
    The next request may use a different instance
    Instance A memorycount = 8 Instance B memorycount = 0
    Data that must persist should go into a database or cache.
  • Assume there is no infrastructure or cost to manage
    Check platform limits before launch
    Timeout10sRegionsin1Concurrency100Calls this month82%
  • Split a simple workflow into too many tiny functions
    Business logic is wrapped in platform APIs
    vercel.only.doBusinessRule()cloudflare.only.saveOrder()
    Too many platform-specific APIs raise the cost of migrating or refactoring core rules.
Anatomy
API gatewayFunction instanceExternal status
The platform handles URLs, HTTPS, scaling, and request routing.
Your code runs when a request or event arrives.
Persistent state lives in databases or storage, not function memory.
Typical use cases
Contact form API
Next.js API RouteDeploys with the frontend project
git pushPlatform build/api/contact available
Depends on the repository branch and deployment settings
Payment webhook
Contact formRequest one email at a time
Send
Function resultEmail sent
Scheduled email
Payment callbackUpdate orders after receiving platform events
payment.succeededVerify signatureOrder changed to paid
should be designed to be idempotent to avoid repeated accounting for the same callback
Image processing trigger
Scheduled tasksAutomatically perform a summary every day
ScheduleEvery day at 09:00ActionGenerate yesterday's dataRecent run✓ 12.4s