Serverless and Edge Computing: Why 70% of Companies Are Migrating in 2025
Hello HaWkers, a silent but profound change is happening in the backend development world: 70% of companies are adopting serverless architectures by 2025, and Edge Computing is becoming a critical component of modern applications.
If you are still manually managing servers, configuring infrastructure, and dealing with scalability, you are missing the advantages of a revolution that promises to reduce costs by up to 70% and drastically improve user experience.
Let's understand what Serverless and Edge Computing are, why they are dominating the market, and how you can leverage these technologies in practice.
The Problem with Traditional Architectures
In the traditional model, you provision servers, configure load balancers, manage scalability, monitor resources, and pay for idle capacity. Even when no one is using your application, you are paying for servers running 24/7.
// Traditional Architecture: Express.js on dedicated server
const express = require('express');
const app = express();
app.get('/api/users/:id', async (req, res) => {
const user = await db.users.findById(req.params.id);
res.json(user);
});
// Server running 24/7, even without requests
app.listen(3000, () => {
console.log('Server running on port 3000');
// You pay for this server all the time
// Need to configure PM2, Nginx, load balancer, etc.
});Problems with this approach:
- Fixed costs: Pay for capacity even without usage
- Manual scalability: Need to manually provision more servers
- Operational complexity: Manage infrastructure, patches, security
- Global latency: Centralized servers far from users
Serverless: You Only Pay for What You Use
Serverless architecture allows running code without managing servers. You write functions that are executed on demand, scale automatically, and you only pay for executions.
// Serverless Function (AWS Lambda, Vercel, Netlify)
// api/users/[id].js
export default async function handler(req, res) {
const { id } = req.query;
// Function executes only when called
const user = await db.users.findById(id);
res.status(200).json(user);
// After responding, function "shuts down"
// You only pay for milliseconds of execution
}Serverless Advantages:
- Pay per use: Pay only for executions
- Automatic scalability: From 0 to millions of requests without configuration
- Zero management: No servers to maintain
- Simplified deploy: Git push and it's live
// Real example: Serverless API with TypeScript
// api/products/[id].ts
import { NextApiRequest, NextApiResponse } from 'next';
import { getProduct } from '@/lib/database';
interface Product {
id: string;
name: string;
price: number;
stock: number;
}
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Product | { error: string }>
) {
const { id } = req.query;
if (req.method !== 'GET') {
return res.status(405).json({ error: 'Method not allowed' });
}
try {
const product = await getProduct(id as string);
if (!product) {
return res.status(404).json({ error: 'Product not found' });
}
// Cache for 1 hour
res.setHeader('Cache-Control', 's-maxage=3600, stale-while-revalidate');
res.status(200).json(product);
} catch (error) {
console.error('Error fetching product:', error);
res.status(500).json({ error: 'Internal server error' });
}
}
Edge Computing: Processing Close to Users
Edge Computing takes the serverless idea one step further: instead of executing functions in a centralized data center, they run on globally distributed servers, close to users.
The Latency Problem:
// Traditional scenario
// User in Brazil -> Server in US -> Database in US
// Total latency: 200ms - 500ms
// With Edge Computing
// User in Brazil -> Edge in Brazil -> Cache/Local processing
// Total latency: 10ms - 50msEdge Functions in Action:
// Edge Function (Vercel Edge, Cloudflare Workers)
// middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
// This function runs on Edge, close to the user
const country = request.geo?.country || 'US';
const city = request.geo?.city || 'Unknown';
// Personalization based on location
// Without centralized server latency
if (country === 'BR') {
return NextResponse.redirect(new URL('/pt-br', request.url));
}
// A/B Testing on Edge
const bucket = Math.random();
const response = bucket < 0.5
? NextResponse.rewrite(new URL('/variant-a', request.url))
: NextResponse.rewrite(new URL('/variant-b', request.url));
response.cookies.set('ab-test-variant', bucket < 0.5 ? 'a' : 'b');
return response;
}
export const config = {
matcher: '/',
};
Cloudflare Workers: Edge Computing in Practice
Cloudflare Workers executes JavaScript in over 300 cities around the world, with average latency of 10-50ms globally.
// Cloudflare Worker - Edge API
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
const url = new URL(request.url);
// Cache on Edge
const cache = caches.default;
let response = await cache.match(request);
if (!response) {
// If not in cache, fetch from database
const data = await fetchFromDatabase(url.pathname);
response = new Response(JSON.stringify(data), {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'public, max-age=3600'
}
});
// Store in Edge cache
event.waitUntil(cache.put(request, response.clone()));
}
return response;
}
async function fetchFromDatabase(path) {
// Connect to database (D1, KV, etc.)
// This code runs on Edge, globally distributed
const result = await DB.prepare(
'SELECT * FROM products WHERE slug = ?'
).bind(path).first();
return result;
}Result: Global latency of 10-50ms vs 200-500ms from traditional centralized server.
Vercel Edge Functions: Next.js on Edge
Vercel allows running parts of Next.js on Edge, bringing SSR (Server-Side Rendering) close to the user:
// app/products/[slug]/page.tsx
// This component can run on Edge
export const runtime = 'edge';
interface Product {
name: string;
price: number;
description: string;
}
export default async function ProductPage({
params
}: {
params: { slug: string }
}) {
// SSR on Edge - renders close to user
const product = await fetch(
`https://api.example.com/products/${params.slug}`,
{ next: { revalidate: 3600 } }
).then(res => res.json() as Promise<Product>);
return (
<div>
<h1>{product.name}</h1>
<p>${product.price}</p>
<p>{product.description}</p>
</div>
);
}
Comparison: Serverless vs Traditional Costs
Let's compare real costs for an application with average traffic:
// Application with 10 million requests/month
// 💰 Traditional Architecture (EC2, DigitalOcean, etc.)
const traditionalCosts = {
servers: 3, // For redundancy
costPerServer: 40, // USD/month
loadBalancer: 20, // USD/month
total: (3 * 40) + 20 // = $140/month
};
// 💸 Serverless (AWS Lambda, Vercel, Netlify)
const serverlessCosts = {
requests: 10_000_000,
freeRequests: 1_000_000, // AWS Free Tier
billableRequests: 9_000_000,
costPer1M: 0.20, // USD
total: (9_000_000 / 1_000_000) * 0.20 // = $1.80/month
};
// 📊 Savings
const savings = traditionalCosts.total - serverlessCosts.total;
console.log(`Savings: $${savings}/month`); // $138.20/month (98.7% reduction!)Note: Costs vary greatly depending on usage patterns, but for applications with variable traffic, serverless is generally much more economical.
When to Use Serverless/Edge vs Traditional
✅ Use Serverless/Edge when:
- Traffic is variable or intermittent
- You want to focus on code, not infrastructure
- Need automatic scalability
- Global latency is important
- Want to reduce operational costs
❌ Use Traditional when:
- Workloads are predictable and constant
- You need full environment control
- Application requires persistent in-memory state
- Cold start latency is critical
- Serverless costs exceed traditional (very intensive workloads)
Serverless and Edge Challenges
Not everything is perfect. Serverless and Edge have limitations:
1. Cold Start
Inactive serverless functions can have initial delay (cold start):
// Cold Start: 100ms - 1s delay on first execution
// Solutions:
// - Keep-alive functions (periodic ping)
// - Provisioned concurrency (AWS Lambda)
// - Edge runtime (Vercel, Cloudflare) has minimal cold start2. Timeouts
Serverless functions have execution limits:
// AWS Lambda: 15min max
// Vercel Serverless: 10s (Hobby), 60s (Pro)
// Vercel Edge: 30s
// Cloudflare Workers: 50ms - 30s (depending on plan)3. Stateless
Serverless functions are stateless — they do not maintain state between executions:
// ❌ DOES NOT work in serverless
let requestCount = 0;
export default function handler(req, res) {
requestCount++; // This counter resets each execution
res.json({ count: requestCount });
}
// ✅ Use external database or cache
export default async function handler(req, res) {
const count = await redis.incr('request_count');
res.json({ count });
}The Future is Hybrid
The trend in 2025 is hybrid architectures: combine serverless, edge, and traditional servers as needed:
// Hybrid: Edge for fast routes, Serverless for APIs, Traditional for heavy processing
// Edge: Authentication and routing
// middleware.ts (Edge Runtime)
export function middleware(request: NextRequest) {
const token = request.cookies.get('auth-token');
if (!token) return NextResponse.redirect('/login');
return NextResponse.next();
}
// Serverless: Lightweight APIs
// api/users.ts (Serverless)
export default async function handler(req, res) {
const users = await db.users.findMany();
res.json(users);
}
// Traditional: Heavy background jobs
// Video processing, ML, ETL run on dedicated serversIf you want to understand more about modern architectures, I recommend reading: WebAssembly and JavaScript: The Performance Revolution on the Web where we explore how WASM is transforming application performance.
Let's go! 🦅
📚 Want to Master Modern Architectures?
This article covered Serverless and Edge Computing, but there is much more to learn about backend development and scalable architectures.
Developers who understand these architectures have more opportunities in the modern market.
Complete Study Material
If you want to master JavaScript and modern architectures from basics to advanced:
Investment options:
- $4.90 (single payment)
👉 Learn About JavaScript Guide
💡 Material updated with industry best practices

