Skip to main content

Serverless Functions

Deploy event-driven functions that run on-demand. Pay only for execution time with automatic scaling from zero to thousands of concurrent executions.

What are Serverless Functions?

Serverless Functions are event-driven code that runs in response to HTTP requests, webhooks, or scheduled events. They automatically scale and you only pay for the time your code is executing.

Key Features

  • Pay-per-execution: Only pay for actual runtime
  • Auto-scaling: Scale from zero to thousands of concurrent executions
  • Cold Start Optimization: Optimized for fast cold starts
  • Built-in Timeout: Configurable execution timeouts
  • Environment Variables: Secure configuration management
  • Custom Domains: Use your own domain with automatic SSL

Use Cases

  • HTTP APIs and endpoints
  • Webhook handlers
  • Event processing
  • Image processing
  • Data transformation
  • Real-time notifications
  • Serverless cron jobs

Getting Started

  1. Create a Serverless Function from your dashboard
  2. Write your function code
  3. Configure triggers (HTTP, webhook, scheduled)
  4. Set timeout and memory limits
  5. Deploy and get your function URL

Supported Runtimes

  • Node.js: JavaScript and TypeScript
  • Python: Python 3.9+
  • Go: Compiled Go binaries
  • Rust: Rust binaries

Configuration Example

// Node.js function
export default async function handler(req, res) {
  const { name } = req.query;
  
  return res.json({
    message: `Hello, ${name}!`,
    timestamp: new Date().toISOString()
  });
}

Trigger Types

  • HTTP: REST API endpoints
  • Webhooks: Incoming webhook events
  • Scheduled: Cron-based triggers
  • Database: Database change events
  • Queue: Message queue triggers

Environment Variables

Secure configuration with environment variables:
  • Built-in: Automatically injected variables
  • Secrets: Encrypted sensitive data
  • Per-function: Function-specific variables

Cold Starts

Optimize cold start performance:
  • Keep-alive: Keep functions warm
  • Bundle size: Minimize dependencies
  • Runtime: Choose appropriate runtime
  • Region: Deploy close to your users

Pricing

Serverless Functions are billed by:
  • Requests: Number of invocations
  • Execution Time: Runtime in milliseconds
  • Memory: Memory allocated per function
  • Outbound Bandwidth: Data transfer out

Monitoring

Monitor your functions with:
  • Metrics: Request count, duration, errors
  • Logs: Real-time execution logs
  • Traces: Distributed tracing
  • Alerts: Configure failure notifications

Deploy Your First Function

Get started with serverless functions