Serverless Edge Functions: Build and Deploy with Cloudflare

In production, we often encounter a situation: a standard server cannot handle peak loads, and spinning up a cluster for a couple of endpoints is like shooting sparrows with a cannon. Cloudflare Workers solve this problem: code runs on V8 isolates with a cold start of less than 1 ms on 300+ edge nod

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1281
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1237
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    977
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    1026
  • image_website-sbh_0.webp
    Website development for SBH Partners
    1103
  • image_website-_0.webp
    Website development for Red Pear
    550

In production, we often encounter a situation: a standard server cannot handle peak loads, and spinning up a cluster for a couple of endpoints is like shooting sparrows with a cannon. Cloudflare Workers solve this problem: code runs on V8 isolates with a cold start of less than 1 ms on 300+ edge nodes. According to Cloudflare Workers documentation, the cold start is under 1 ms. The free tier covers 100,000 requests per day — enough for most projects. Our experience integrating Workers on dozens of sites shows: fault tolerance increases, and infrastructure costs drop by 40-60% compared to traditional solutions. For a project with 500k requests per month, this saves up to $200 monthly. Worker pricing starts at $5 per month for 10 million requests, making it affordable for startups.

Cloudflare Workers achieve cold start under 1 ms

Workers run on Cloudflare Workers technology with V8 isolation, where each Worker runs in a separate V8 context. Unlike containers, V8 isolates do not require loading an OS or runtime — the code is compiled and executed instantly. This gives a cold start <1 ms, while AWS Lambda takes 500-2000 ms due to container initialization. Cloudflare Workers cold start is up to 2000 times faster than AWS Lambda. For example, Workers handle requests 100 times faster on first launch, which is critical for low-latency APIs. With our 5 years of experience and over 100 projects, we guarantee reliable implementation.

Comparison with AWS Lambda and Vercel Functions

Workers run in every Cloudflare PoP — a user from Moscow gets a response from the nearest node, not from us-east-1. This is fundamental for latency-sensitive tasks. Limitation: Workers use Web API, not Node.js API — fs, child_process, native modules are unavailable. But there is no cold start like Lambda (where it can reach several seconds with default settings). Vercel Functions also have delays — they rely on containers. Workers on V8 isolates win in initialization speed.

When to Use Workers vs Traditional Backend

If your site requires low latency for API requests, geo-distribution, or integration with external services — Workers are the obvious choice. A full server is recommended when you need long connections to PostgreSQL, work with large files, or complex CPU calculations. For everything else, Workers are a lightweight and cheap alternative.

Basic Worker
// src/index.ts export default { async fetch(request: Request, env: Env): Promise<Response> { const url = new URL(request.url); if (url.pathname === "/api/contact" && request.method === "POST") { return handleContact(request, env); } if (url.pathname === "/api/geo") { return handleGeo(request); } return new Response("Not found", { status: 404 }); }, }; async function handleContact(request: Request, env: Env): Promise<Response> { const data = await request.json<{ name: string; email: string; message: string }>(); // Send via Resend API const emailResponse = await fetch("https://api.resend.com/emails", { method: "POST", headers: { Authorization: `Bearer ${env.RESEND_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ from: "site@YOUR_DOMAIN", to: ["team@YOUR_DOMAIN"], subject: `Message from ${data.name}`, text: `${data.name} (${data.email}): ${data.message}`, }), }); if (!emailResponse.ok) { return Response.json({ error: "Email send failed" }, { status: 500 }); } return Response.json({ ok: true }); } // Geolocation from Cloudflare headers function handleGeo(request: Request): Response { const cf = (request as any).cf; return Response.json({ country: cf?.country, city: cf?.city, timezone: cf?.timezone, latitude: cf?.latitude, longitude: cf?.longitude, }); } 

Wrangler and deployment

Deployment steps:

  1. Install Wrangler CLI: npm install -g wrangler
  2. Authenticate: wrangler login
  3. Write your Worker code in src/index.ts
  4. Configure wrangler.toml with your settings
  5. Deploy: wrangler deploy
Wrangler Configuration Example
# wrangler.toml name = "my-site-api" main = "src/index.ts" compatibility_date = "2024-11-01" [vars] ENVIRONMENT = "production" [[routes]] pattern = "YOUR_DOMAIN/api/*" zone_name = "YOUR_DOMAIN" 
npm install -g wrangler wrangler login wrangler dev # local development wrangler deploy # deploy 

Secrets:

wrangler secret put RESEND_API_KEY wrangler secret put DATABASE_URL 

Workers KV and D1: data storage at the edge

KV is a key-value store, eventually consistent. Suitable for cache, sessions, configuration. Workers KV provides edge acceleration for data access.

KV Example
// Bind in wrangler.toml // [[kv_namespaces]] // binding = "CACHE" // id = "abc123..." export default { async fetch(request: Request, env: Env & { CACHE: KVNamespace }) { const cacheKey = new URL(request.url).pathname; const cached = await env.CACHE.get(cacheKey); if (cached) { return new Response(cached, { headers: { "Content-Type": "application/json", "X-Cache": "HIT" } }); } const data = await fetchFreshData(request); await env.CACHE.put(cacheKey, JSON.stringify(data), { expirationTtl: 300 }); return Response.json(data); } }; 

D1 is Cloudflare's serverless SQLite database. Suitable for small data volumes (up to 10 GB). With serverless computing, D1 scales automatically without management overhead.

D1 Example
export default { async fetch(request: Request, env: Env & { DB: D1Database }) { const { results } = await env.DB.prepare( "SELECT * FROM products WHERE category = ? ORDER BY created_at DESC LIMIT 20" ).bind("electronics").all(); return Response.json(results); } }; 

Working with data and limitations

  • CPU time: 10 ms (free), 30 s (Paid)
  • Memory: 128 MB
  • No Node.js built-ins (fs, path, crypto — only Web Crypto API)
  • No long-lived connections to PostgreSQL (use Hyperdrive or HTTP API)

Hyperdrive solves PostgreSQL connection problem

Hyperdrive proxies connections to an external PostgreSQL database through a connection pool on the Cloudflare side, solving the latency issue of connecting to a remote DB. This allows Workers to work with relational databases without delays in establishing new connections.

Performance comparison: Workers vs AWS Lambda vs Vercel Functions

Parameter Cloudflare Workers AWS Lambda Vercel Functions
Cold start <1 ms 500-2000 ms 100-500 ms
Geo-distribution 300+ PoP 30+ regions per deployment region
Max CPU 30 s 15 min 60 s
Free limit 100k requests/day 1M requests/month 100k requests/month

Workers significantly win in cold start and global availability. Building an API on Cloudflare ensures low latency worldwide.

Storage options comparison

Service Type Use Case Consistency
Workers KV Key-value Cache, sessions Eventual
D1 SQLite Small relational data Strong
Hyperdrive Proxy External PostgreSQL Strong (via DB)

What's included in the work

When ordering Workers development, you get:

  • Architecture design and selection of optimal services (KV, D1, Hyperdrive)
  • Implementation of all endpoints with error handling and timeouts
  • CI/CD with GitHub Actions and automatic deployment via Wrangler
  • Documentation for operation and description of all environment variables
  • Load testing up to 1000 RPS with subsequent optimization
  • Team training on Cloudflare Dashboard and Wrangler CLI

Timeline

Basic Worker with routing and 3-5 endpoints — from 2 to 3 days. Integration of KV and D1, CI/CD via GitHub Actions — plus 2 days. Full solution with Hyperdrive and custom domains — up to a week. Contact us for an accurate estimate of your project.