Skip to content
All insights

case study//2 min read

Reducing Cloud Costs by 60% with Serverless & Edge Compute

A technical case study on eliminating idle compute overhead by migrating traditional long-running VM clusters to event-driven serverless functions and edge runtime workers.

Sameer BagwanCTO & Co-Founder, Digitat
Software developer optimizing serverless edge compute code and cloud architecture

In short

  • Provisioning for peak traffic in traditional VM clusters causes 70%+ compute waste during off-peak hours.
  • Edge execution eliminates cold starts for read APIs by keeping runtimes lightweight and geographically distributed.
  • Connection pooling proxies are mandatory when serverless functions query relational SQL databases.
  • Targeted cost allocation tagging gives engineering teams visibility into per-tenant compute expenses.

The Hidden Cost Trap of Idle Kubernetes Clusters

Modern startups frequently over-provision Kubernetes clusters to guarantee capacity during unexpected traffic spikes. An engineering team operating three production worker nodes, two standby replicas across availability zones, and dedicated ingress controllers easily spends $3,500 to $8,000 monthly before serving a single real customer request.

Analysis of typical SaaS compute utilization reveals that traditional VM-backed nodes operate at less than 12% average CPU utilization during off-peak hours. You are essentially paying cloud providers to keep virtual silicon warm while waiting for work.

Re-Architecting to Edge Compute & Ephemeral Functions

By decomposing legacy monoliths into lightweight edge handlers (Cloudflare Workers, Vercel Edge) for read-heavy API routing and serverless compute (AWS Lambda, Vercel Serverless) for asynchronous background processing, compute costs drop from continuous fixed hourly rates to sub-millisecond execution billing.

typescript
// Serverless Edge Router with sub-millisecond execution footprint
export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const url = new URL(request.url);
    
    // Serve cached responses directly from edge KV without hitting origin
    if (request.method === 'GET') {
      const cached = await env.CACHE_KV.get(url.pathname);
      if (cached) {
        return new Response(cached, {
          headers: { 'Content-Type': 'application/json', 'X-Cache': 'HIT' }
        });
      }
    }
    
    // Delegate to origin serverless pool
    return fetch(request);
  }
};

Solving Database Connection Storms at Scale

The primary challenge with serverless architecture is relational database connection pooling. When 1,000 serverless functions spin up simultaneously to handle a burst, opening 1,000 distinct PostgreSQL connections will exhaust database memory and crash the instance.

Implementing PgBouncer or utilizing modern serverless database connection poolers (such as Neon or AWS RDS Proxy) multiplexes thousands of ephemeral serverless connections over a small pool of 20 to 50 persistent physical database connections, guaranteeing stability under heavy load.

The 60% Cloud Cost Savings Scorecard

After migrating our core production API and analytics pipelines from multi-AZ Kubernetes node groups to edge workers and pooled serverless compute, our monthly cloud infrastructure bills dropped from $6,420 to $2,380 while P99 response times dropped from 210ms to 48ms worldwide.

  • Compute Infrastructure: Slashed by 64% through pay-per-execution billing.
  • Inter-AZ Data Transfer: Reduced by 78% by routing reads through localized edge caches.
  • Operational Maintenance: Eliminated 15+ hours monthly of Kubernetes cluster upgrades and node patching.

Tags

  • Serverless
  • Cloud Optimization
  • Cost Engineering
  • AWS
  • Vercel

Share

LinkedInX
Written bySameer BagwanCTO & Co-Founder, Digitat

Have a product worth writing about?

Tell us where it is today. We reply within 12 hours.