Chapterبەش 10 · Lectureوانە 10.2

Serverless and Edge Functionsکردارەکان بێ‌ڕاژەکار و کردارەکانی لێوار

A server you run compared with a function the platform runs; serverless computing and FaaS (and SQLite's other meaning of serverless); events and triggers; a fetch-style handler run with Node.js and the same job in PHP; cold starts measured in a demo; limits on time, memory, files and state; pricing per request with a worked example; edge functions in CDN edge locations, what they are good for, a runnable edge function; how they differ from IoT edge computing; and the real platforms of November 2026.

کە خۆت کاری پێدەکەیت بەراورد بە کە کاری پێدەکات؛ و (و واتاکەی تری بێ‌ڕاژەکار لە SQLiteـدا)؛ و ؛ بە شێوازی fetch کە بە ⁦Node.js⁩ کاری پێدەکرێت و هەمان کار بە PHP؛ لە نموونەیەکدا؛ سنووری کات، ، و دۆخ؛ نرخی هەر بە نموونەیەکی کارکراو؛ لە ، بۆ چی باشن و کە کاری پێدەکرێت؛ جیاوازییان لەگەڵ IoT؛ و ڕاستەقینەکانی تشرینی دووەمی ⁦2026⁩.

20 min read21 خولەک خوێندنەوە · 18 stepsهەنگاو

What you will learnچی فێر دەبیت

  • Explain how a serverless function differs from a server you run, and place FaaS next to IaaS, PaaS and BaaS.
  • Tell the cloud meaning of serverless from SQLite's meaning.
  • Name common events and triggers, and write and run a fetch-style handler.
  • Explain cold and warm starts, the limits of functions and pay-per-request pricing, with a worked cost.
  • Say what edge functions are good and bad at, and how they differ from IoT edge computing.
  • ڕوونی بکەیتەوە بێ‌ڕاژەکار چ جیاوازییەکی لەگەڵ هەیە کە خۆت کاری پێدەکەیت و لە تەنیشت ، و دابنێیت.
  • واتای هەوریی بێ‌ڕاژەکار لە واتاکەی SQLite جیا بکەیتەوە.
  • و باو ناو ببەیت و بە شێوازی fetch بنووسیت و کاری پێ بکەیت.
  • و ، سنوورەکانی و نرخی هەر بە ژماردنێکی کارکراو ڕوون بکەیتەوە.
  • بڵێیت بۆ چی باشن و بۆ چی خراپن و چ جیاوازییەکیان لەگەڵ IoT هەیە.

Who runs the server?کێ ڕاژەکارەکە کار پێدەکات؟

Until now your PHP code has lived on a server that you run yourself. In XAMPP you start Apache, and it waits all day for requests; for a real site you rent a server and keep it updated. There is another way: you upload only a function, and a platform runs it each time a request or another event arrives. While nobody asks, nothing of yours is running.

تا ئێستا کۆدی PHPـەکەت لەسەر ژیاوە کە خۆت کاری پێدەکەیت. لە XAMPPـدا Apache دەست پێ دەکەیت و هەموو ڕۆژەکە چاوەڕێی دەکات؛ بۆ ڕاستەقینە بە کرێ دەگریت و نوێی دەکەیتەوە. ڕێگەیەکی تریش هەیە: تەنیا هەڵبار دەکەیت و هەر جارێک یان تر بگات کاری پێدەکات. کاتێک کەس داوا ناکات، هیچ شتێکی تۆ کار ناکات.

This lesson explains that way: serverless functions, the events that start them, cold starts, their limits and their price. Then it turns to edge functions: small functions that run in many data centres, close to each visitor.

ئەم وانەیە ئەو ڕێگەیە ڕوون دەکاتەوە: بێ‌ڕاژەکار، ئەو دەستیان پێ دەکەن، ، سنوورەکان و نرخیان. پاشان دەچێتە سەر : بچووک کە لە زۆر ، نزیک لە هەر سەردانکەرێک، کار دەکەن.

Two panels. A server you run: Apache in XAMPP, always running and always waiting, with a 24-hour clock; you install, update and protect it; a rented server costs money every month, even when nobody visits; one machine, so busy days need a bigger one. A function the platform runs: fetch() sleeps until called; a request comes in and a response goes out; you write only the function; the provider runs and updates the servers; you pay for each request and its time; on a busy day more copies start by themselves.دوو بەش. ڕاژەکارێک کە خۆت کاری پێدەکەیت: Apache لە XAMPPـدا، هەمیشە کار دەکات و هەمیشە چاوەڕێیە، لەگەڵ کاتژمێرێکی 24 کاتژمێری؛ خۆت دایدەمەزرێنیت، نوێی دەکەیتەوە و دەیپارێزیت؛ ڕاژەکارێک بەکرێگیراو هەموو مانگێک پارەی دەوێت، تەنانەت کاتێک کەس سەردان ناکات؛ یەک ئامێر، بۆیە ڕۆژانی قەرەباڵغ ئامێرێکی گەورەتری دەوێت. کردارێک کە سەکۆکە کاری پێدەکات: fetch() دەخەوێت تا بانگ دەکرێت؛ داواکارییەک دێتە ژوورەوە و وەڵامێک دەچێتە دەرەوە؛ تەنیا کردارەکە دەنووسیت؛ دابینکەرەکە ڕاژەکارەکان کار پێدەکات و نوێیان دەکاتەوە؛ بۆ هەر داواکارییەک و کاتەکەی پارە دەدەیت؛ لە ڕۆژی قەرەباڵغدا کۆپیی زیاتر خۆیان دەست پێ دەکەن.
Your own server waits all day; a serverless function wakes up only when called. خۆت هەموو ڕۆژەکە چاوەڕێ دەکات؛ بێ‌ڕاژەکار تەنیا کاتێک بانگ دەکرێت هەڵدەستێت.CêIT

Serverless computing and FaaSژمێرکاریی بێ‌ڕاژەکار و FaaS

Definitionپێناسە

A cloud model in which the provider starts and stops servers automatically as requests arrive, so you never manage a server and pay only while your code or database is working.

مۆدێلێکی هەورییە کە تێیدا دابینکەرەکە بە شێوەیەکی خۆکار ڕاژەکارەکان کاتێک داواکاری دێت دادەگیرسێنێت و دەیانوەستێنێت، بۆیە هەرگیز ڕاژەکار بەڕێوە نابەیت و تەنیا لەو کاتەدا پارە دەدەیت کە کۆد یان بنکەدراوەکەت کار دەکات.

Serverless does not mean that there are no servers. It means that the servers are not your job: the provider starts copies of your code when requests arrive, adds more on a busy day, removes them when traffic stops (even down to zero) and bills you for the use. The most common form is FaaS, Function as a Service, where your unit of work is a single function; AWS Lambda and Cloudflare Workers are examples.

بێ‌ڕاژەکار واتای ئەوە نییە کە هیچ نییە. واتە کاری تۆ نین: دابینکەرەکە کاتێک دێن کۆپیی کۆدەکەت دەست پێ دەکات، لە ڕۆژی قەرەباڵغدا زیاتر زیاد دەکات، کاتێک هاتوچۆ دەوەستێت لایان دەبات (تەنانەت تا سفر) و بەپێی بەکارهێنان پارەت لێ وەردەگرێت. باوترین شێوەی ـە، Function as a Service، کە تێیدا یەکەی کارەکەت تەنیا یەک ؛ AWS Lambda و Cloudflare Workers نموونەن.

It sits next to the service models of Cloud Computing: with IaaS you run the virtual machines, with PaaS the platform runs your app, and with FaaS you hand over even the decision of how many servers run and when. BaaS is a close relative: it gives an app a ready back end, and serverless functions often add the custom parts.

لە تەنیشت مۆدێلەکانی خزمەتگوزاریی هەورەژمێرکاری دادەنیشێت: لە خۆت کار پێدەکەیت، لە کار پێدەکات و لە تەنانەت بڕیاری ئەوەش دەدەیتە دەست دابینکەر کە چەند و کەی کار بکەن. BaaS خزمێکی نزیکە: ئامادە دەداتە و بێ‌ڕاژەکار زۆرجار بەشە تایبەتەکانی بۆ زیاد دەکەن.

A grid of who manages each layer in four set-ups: your own server (XAMPP), IaaS, PaaS and FaaS (serverless). The layers from top to bottom are your data, your code, how many servers and when, the language runtime (PHP, Node.js), the operating system, and hardware, power and building. With your own server you manage all six. With IaaS the provider manages the hardware. With PaaS the provider also manages the operating system and the runtime. With FaaS the provider manages everything except your code and your data.خشتەیەکی ئەوەی کێ هەر چینێک بەڕێوە دەبات لە چوار دۆخدا: ڕاژەکاری خۆت (XAMPP)، IaaS، PaaS و FaaS (بێ‌ڕاژەکار). چینەکان لە سەرەوە بۆ خوارەوە: دراوەکەت، کۆدەکەت، چەند ڕاژەکار و کەی، بەرنامەی زمان (PHP، Node.js)، سیستەمی وەگەڕخەر و ڕەقەکاڵا، کارەبا و بینا. لە ڕاژەکاری خۆتدا هەر شەشیان بەڕێوە دەبەیت. لە IaaSـدا دابینکەر ڕەقەکاڵا بەڕێوە دەبات. لە PaaSـدا دابینکەر سیستەمی وەگەڕخەر و بەرنامەی زمانیش بەڕێوە دەبات. لە FaaSـدا دابینکەر هەموو شتێک بەڕێوە دەبات جگە لە کۆدەکەت و دراوەکەت.
FaaS leaves you only your code and your data. تەنیا کۆدەکەت و بۆ تۆ دەهێڵێتەوە.CêIT

Serverless computing and FaaSژمێرکاریی بێ‌ڕاژەکار و FaaS

Serverless: two meaningsبێ‌ڕاژەکار: دوو واتا

You met the word in SQLite Basics: SQLite is serverless because there is no separate database server program; the SQLite library inside your program reads the file itself. In cloud computing the word means something else: the servers exist, but the provider runs them. SQLite's own website calls the first meaning classic serverless and the second neo-serverless, and advises asking which one a product means. CêIT keeps them apart with two terms: for SQLite's meaning and for the cloud.

ئەم وشەیەت لە بنەماکانی SQLiteـدا بینی: بێ‌ڕاژەکارـە چونکە هیچ جیای نییە؛ SQLite لە ناو خۆی دەخوێنێتەوە. لە وشەکە واتایەکی تری هەیە: هەن، بەڵام دابینکەرەکە کاریان پێدەکات. خودی SQLite بە واتای یەکەم دەڵێت classic serverless و بە دووەم ⁦neo-serverless⁩ و ئامۆژگاری دەکات بپرسیت بەرهەمێک مەبەستی کامیانە. CêIT بە دوو زاراوە لە یەکیان جیا دەکاتەوە: بۆ واتای SQLite و بۆ هەور.

Two panels. SQLite, no database server: your PHP program contains the SQLite library, which reads and writes the file school.db itself; no server program is started, the classic meaning. Cloud, no server for you to run: fetch() is sent to the provider's cloud, drawn with three dashed servers; the servers still exist, but the provider runs them; you upload code, today's cloud meaning.دوو بەش. SQLite، ڕاژەکاری بنکەدراوە نییە: بەرنامەی PHPـەکەت کتێبخانەی SQLiteـی تێدایە، کە خۆی فایلی school.db دەخوێنێتەوە و دەنووسێت؛ هیچ ڕاژەکاری جیا دەست پێناکرێت، واتای کۆن. هەور، ڕاژەکارێک نییە کە تۆ کاری پێبکەیت: fetch() دەنێردرێت بۆ هەوری دابینکەرەکە کە بە سێ ڕاژەکاری خاڵخاڵ کێشراوە؛ ڕاژەکارەکان هەر هەن، بەڵام دابینکەرەکە کاریان پێدەکات؛ تۆ کۆد هەڵبار دەکەیت، واتای ئەمڕۆی هەور.
Same word, two ideas: no server program (SQLite), or no server for you to manage (cloud).یەک وشە، دوو بیرۆکە: هیچ نییە ⁦(SQLite)⁩، یان هیچ نییە کە تۆ بەڕێوەی ببەیت (هەور).CêIT

Events and triggersڕووداوەکان و پیتکەکانی کردار

A serverless function never runs by itself. It runs because something happened: an event. A trigger is the setting that connects one kind of event to your function. AWS's documentation says that more than 200 of its services can trigger a Lambda function. The common event sources are:

بێ‌ڕاژەکار هەرگیز خۆبەخۆ کار ناکات. کار دەکات چونکە شتێک ڕووی داوە: . ئەو کە جۆرێک لە بە دەبەستێتەوە. AWS دەڵێت زیاتر لە ⁦200⁩ خزمەتگوزاریی AWS دەتوانن Lambda کار پێ بکەن. سەرچاوە باوەکانی ئەمانەن:

  • an HTTP request: an API call, a form, or a message from another service;
  • a file uploaded to cloud storage: make a small copy of a photo;
  • a message in a queue: send an email a little later;
  • a timer: every night at 02:00, build a report;
  • a change in a database: update a search list when a row changes.
  • HTTP: بانگکردنی API، ، یان پەیامێک لە خزمەتگوزارییەکی ترەوە؛
  • کە هەڵبار دەکرێت بۆ : کۆپییەکی بچووکی وێنەیەک دروست بکە؛
  • پەیامێک لە : ئیمەیڵێک کەمێک دواتر بنێرە؛
  • : هەموو شەوێک لە کاتژمێر ⁦02:00⁩، دروست بکە؛
  • گۆڕانکارییەک لە : کاتێک دەگۆڕێت، لیستی گەڕان نوێ بکەرەوە.
On the left, five events: HTTP request GET /hello, a photo is uploaded, a message in a queue, a timer every night at 02:00, a row changes in a database. Arrows lead from all of them to one box, your function, which runs once per event. Arrows lead out to five results: a JSON response, a small copy is saved, an email is sent, a report is made, a search list is updated.لە چەپ، پێنج ڕووداو: داواکاریی HTTP بە GET /hello، وێنەیەک هەڵبار دەکرێت، پەیامێک لە کیوویەکدا، تایمەرێک هەموو شەوێک لە 02:00، تۆمارێک لە بنکەدراوەدا دەگۆڕێت. تیر لە هەموویانەوە دەچن بۆ یەک چوارگۆشە، کردارەکەت، کە بۆ هەر ڕووداوێک جارێک کار دەکات. تیرەکان دەچنە دەرەوە بۆ پێنج ئەنجام: وەڵامێکی JSON، کۆپییەکی بچووک هەڵدەگیرێت، ئیمەیڵێک دەنێردرێت، ڕاپۆرتێک دروست دەکرێت، لیستی گەڕان نوێ دەکرێتەوە.
Many kinds of events, one way of working: event, then function, then result.زۆر جۆری ، یەک شێوەی کار: ، پاشان ، پاشان ئەنجام.CêIT

A function in code: request in, response outکردارێک لە کۆددا: داواکاری دێتە ژوورەوە، وەڵام دەچێتە دەرەوە

For HTTP events most platforms now use one shape: a handler that receives a standard Request object and returns a Response object, the same objects as the Fetch API of the browser (MDN: Response). Cloudflare Workers, Vercel Functions, Netlify, Supabase and Deno accept it in November 2026. Node.js has Request and Response built in (stable since version 21), so with Node.js 24 you can run a handler on your own computer and play the platform yourself:

بۆ HTTP زۆربەی ئێستا یەک شێوە بەکار دەهێنن: کە ستانداردی Request وەردەگرێت و Response دەگەڕێنێتەوە، هەمان ئەو Fetch APIـی (⁦MDN: Response⁩). Cloudflare Workers، Vercel Functions، Netlify، Supabase و Deno لە تشرینی دووەمی ⁦2026⁩ـدا قبووڵی دەکەن. ⁦Node.js⁩ خۆی Request و Responseـی تێدایە (لە وەشانی ⁦21⁩ـەوە جێگیرن)، بۆیە بە ⁦Node.js 24⁩ دەتوانیت لەسەر خۆت کار پێ بکەیت و خۆت ڕۆڵی ببینیت:

A fetch-style functionکردارێک بە شێوەی fetchhello-function.mjsJSRuns on the serverلەسەر ڕاژەکاری وێب کار دەکات
// hello-function.mjs - a fetch-style function: a Request comes in, a Response goes out
export default {
  async fetch(request) {
    const url = new URL(request.url);

    if (url.pathname === '/hello') {
      const name = url.searchParams.get('name') ?? 'world';
      return Response.json({ message: `Hello, ${name}!` });
    }
    return new Response('Not found', { status: 404 });
  },
};
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 3

The handler: the platform calls fetch() once for every request.

: بۆ هەر جارێک fetch() بانگ دەکات.

Lineدێڕی 8

Response.json() makes a 200 response with the application/json content type.

Response.json() ⁦200⁩ بە جۆری ناوەڕۆکی application/json دروست دەکات.

Lineدێڕی 10

Any other path: a plain-text 404.

هەر تر: ⁦404⁩ بە دەقی سادە.

Playing the platform on your computerڕۆڵی سەکۆ لەسەر کۆمپیوتەرەکەتrun-locally.mjsJSType in a terminalلە تێرمیناڵدا بینووسە
// run-locally.mjs - play the platform: build Requests and call the function
import fn from './hello-function.mjs';

for (const path of ['/hello?name=Shilan', '/hello', '/menu']) {
  const response = await fn.fetch(new Request('https://example.com' + path));
  console.log(path, '->', response.status, response.headers.get('content-type'));
  console.log('   ', await response.text());
}
A request card on the left: GET, https://example.com/hello?name=Shilan, with the header accept-language: ckb. An arrow leads to the handler, fetch(request), your code. An arrow leads on to a response card: 200 OK, content-type: application/json, and the body {"message":"Hello, Shilan!"}. Below: the same shape on Cloudflare Workers, Vercel, Netlify, Supabase and Deno (2026); Request and Response are standard web objects (MDN).کارتی داواکاری لە چەپ: GET، https://example.com/hello?name=Shilan، لەگەڵ سەردێڕی HTTPـی accept-language: ckb. تیرێک دەچێت بۆ مامەڵەکەرەکە، fetch(request)، کۆدەکەت. تیرێکی تر دەچێت بۆ کارتی وەڵام: 200 OK، content-type: application/json و لاشەی {"message":"Hello, Shilan!"}. لە خوارەوە: هەمان شێوە لە Cloudflare Workers، Vercel، Netlify، Supabase و Denoـدا (2026)؛ Request و Response ئۆبجێکتەکانی ستانداردی وێبن (MDN).
One request in, one response out: the shape of a fetch-style function.یەک دێتە ژوورەوە، یەک دەچێتە دەرەوە: شێوەی بە شێوازی fetch.CêIT

A function in code: request in, response outکردارێک لە کۆددا: داواکاری دێتە ژوورەوە، وەڵام دەچێتە دەرەوە

The same job in PHP on XAMPPهەمان کار بە PHP لەسەر XAMPP

Compare it with the PHP way from Build your own JSON API. In PHP the file is the handler: Apache, always running, finds hello.php and runs it for each request. The superglobals hold the request, and header() and echo build the response.

بەراوردی بکە لەگەڵ ڕێگای PHP لە APIـی JSONـی خۆت دروست بکە. لە PHPـدا : Apache، کە هەمیشە کار دەکات، hello.php دەدۆزێتەوە و بۆ هەر جێبەجێی دەکات. هەڵدەگرن و header() و echo دروست دەکەن.

The PHP versionوەشانی PHPapi/hello.phpPHPRuns on the serverلەسەر ڕاژەکاری وێب کار دەکات
<?php
// api/hello.php - the same job on XAMPP: Apache runs all the time and calls this file
header('Content-Type: application/json');

$name = $_GET['name'] ?? 'world';
echo json_encode(['message' => "Hello, $name!"]);
Your own server and a serverless function, side by side. خۆت و بێ‌ڕاژەکار، لە تەنیشت یەک.
QuestionپرسیارPHP on your server (XAMPP)PHP لەسەر خۆت ⁦(XAMPP)⁩A serverless function بێ‌ڕاژەکار
Who waits for requestsکێ چاوەڕێی دەکاتApache, all dayApache، هەموو ڕۆژەکەthe platform; your code sleeps؛ کۆدەکەت دەخەوێت
The request$_GET, $_POST, $_SERVERa Request object Request
The responseheader(), http_response_code(), echonew Response(...), Response.json()
A busy dayڕۆژێکی قەرەباڵغone machine: buy a bigger oneیەک ئامێر: ئامێرێکی گەورەتر بکڕەmore copies start by themselvesکۆپیی زیاتر خۆیان دەست پێ دەکەن
The billپارەدانthe same every monthهەموو مانگێک وەک یەکper request and run timeبۆ هەر و کاتی کارکردن

Cold starts and warm startsدەستپێکی سارد و دەستپێکی گەرم

A function needs a place to run: an execution environment with the language runtime, your code and some memory. When a request arrives and no environment is ready, the platform must first download the code, start the runtime and run your start-up code, which is everything outside the handler. That wait is a cold start. Afterwards the environment is kept for a while, so the next request is a fast warm start. AWS reports that cold starts happen in under 1% of calls and take from under 100 ms to over 1 second (as of 2026), and that this start-up time is billed too.

شوێنێکی پێویستە بۆ کارکردن: بە بەرنامەی زمانەکە، کۆدەکەت و بڕێک . کاتێک دێت و هیچ ژینگەیەک ئامادە نییە، دەبێت سەرەتا کۆدەکە بهێنێت، بەرنامەی زمانەکە دەست پێ بکات و کۆدی دەستپێکردنی تۆ جێبەجێ بکات، کە هەموو ئەو کۆدەیە لە دەرەوەی . ئەو چاوەڕوانییە . دواتر ژینگەکە ماوەیەک دەهێڵرێتەوە، بۆیە دواتر دەبێت بە خێرا. AWS دەڵێت لە کەمتر لە ⁦1%⁩ـی بانگکردنەکاندا ڕوو دەدەن و لە کەمتر لە ⁦100 ms⁩ تا زیاتر لە 1 چرکە دەخایەنن (لە ⁦2026⁩ـدا) و پارەی ئەم کاتی دەستپێکردنەش وەردەگیرێت.

An animation in six steps. Request 1 arrives and no environment is running. Cold start: the platform prepares an environment: it downloads the code, starts Node.js and runs the code outside fetch(); this wait is the cold start, from under 100 ms to over 1 second. fetch() answers request 1, and calls is 1. Request 2, a moment later, is a warm start: only fetch() runs, and calls is 2. After a quiet while the environment is removed and its variables are gone. Request 3 meets a cold start again, and calls starts from 1.
An animation in six steps. Request 1 arrives and no environment is running. Cold start: the platform prepares an environment: it downloads the code, starts Node.js and runs the code outside fetch(); this wait is the cold start, from under 100 ms to over 1 second. fetch() answers request 1, and calls is 1. Request 2, a moment later, is a warm start: only fetch() runs, and calls is 2. After a quiet while the environment is removed and its variables are gone. Request 3 meets a cold start again, and calls starts from 1.
A cold start prepares an environment; warm starts reuse it until it is removed. ژینگەیەک ئامادە دەکات؛ دووپاتە بەکاری دەهێننەوە تا لادەبرێت.CêIT

Cold starts and warm startsدەستپێکی سارد و دەستپێکی گەرم

Watch it: code outside the handler runs onceببینە: کۆدی دەرەوەی مامەڵەکەر یەکجار کار دەکات

Code at the top of the module runs once, when an environment starts; fetch() runs for every request. This demo plays two environments by importing the same file twice:

ئەو کۆدەی لە سەرەوەی مۆدیولەکەدایە یەکجار کار دەکات، کاتێک ژینگەیەک دەست پێ دەکات؛ fetch() بۆ هەموو کار دەکات. ئەم نموونەیە بە دوو جار هێنانی هەمان ، ڕۆڵی دوو ژینگە دەبینێت:

A function that counts its callsکردارێک کە بانگکردنەکانی خۆی دەژمێرێتcounter-function.mjsJSRuns on the serverلەسەر ڕاژەکاری وێب کار دەکات
// counter-function.mjs - code outside fetch() runs once per environment
console.log('init: the platform starts a new environment (cold start)');
const startedAt = Date.now();
let calls = 0;                       // lives only as long as THIS environment

export default {
  async fetch(request) {
    calls++;
    return Response.json({ calls, aliveMs: Date.now() - startedAt });
  },
};
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 2-4

Outside the handler: runs once per environment, at the cold start.

لە دەرەوەی : بۆ هەر ژینگەیەک یەکجار، لە کاتی ، کار دەکات.

Lineدێڕی 8

Inside the handler: runs on every request.

لە ناو : لە هەموو کار دەکات.

Two environments, four requestsدوو ژینگە، چوار داواکاریcold-and-warm.mjsJSType in a terminalلە تێرمیناڵدا بینووسە
// cold-and-warm.mjs - one environment serves three requests, then a second one starts
const request = () => new Request('https://example.com/count');

const first = (await import('./counter-function.mjs?env=1')).default;     // cold start
for (let i = 0; i < 3; i++) {
  console.log('env 1:', await (await first.fetch(request())).text());     // warm starts
}

const second = (await import('./counter-function.mjs?env=2')).default;    // another copy
console.log('env 2:', await (await second.fetch(request())).text());

Environment 1 counted 1, 2, 3; environment 2 started again at 1. Use the first fact: open a database connection or load a library outside the handler, so that warm starts reuse it, as AWS recommends. Beware of the second: never keep important data, such as a visitor count, in a variable, because you never know which environment answers, or when it disappears.

ژینگەی 1 ژماردی 1، 2، 3؛ ژینگەی 2 دیسان لە 1ـەوە دەستی پێ کرد. سوود لە ڕاستییەکەی یەکەم وەربگرە: بکەرەوە یان لە دەرەوەی بهێنە، بۆ ئەوەی دووپاتە بەکاری بهێننەوە، وەک AWS ئامۆژگاری دەکات. ئاگاداری دووەمیان بە: هەرگیز گرنگ، وەک ژمارەی سەردانکەران، لە هەڵمەگرە، چونکە هەرگیز نازانیت کام ژینگە وەڵام دەداتەوە یان کەی نامێنێت.

Limits: time, memory, files and stateسنوورەکان: کات، بیرگە، فایلەکان و دۆخ

A platform shares its machines among many customers, so every function lives inside limits. As of November 2026:

ئامێرەکانی لە نێوان زۆر کڕیاردا بەش دەکات، بۆیە هەموو لە ناو سنوورێکدا دەژی. لە تشرینی دووەمی ⁦2026⁩ـدا:

  • Time: an AWS Lambda function may run for at most 15 minutes per call. A Cloudflare Worker on the free plan gets 10 ms of CPU time per request (30 seconds by default on the paid plan, up to 5 minutes).
  • Memory: Lambda from 128 MB to 10,240 MB; a Worker gets 128 MB.
  • Files: the disk is read-only except a scratch folder (/tmp on Lambda and Vercel) that disappears with the environment. Keep uploads in cloud storage and data in a database.
  • State: variables die with their environment, as the demo showed.
  • کات: AWS Lambda لە هەر بانگکردنێکدا زۆرترین ⁦15⁩ خولەک کار دەکات. Cloudflare Worker لە پلانی بێبەرانبەردا ⁦10 ms⁩ کاتی CPU بۆ هەر وەردەگرێت (لە پلانی پارەداردا بە بنەڕەت ⁦30⁩ چرکە، تا 5 خولەک).
  • : Lambda لە ⁦128 MB⁩ تا ⁦10,240 MB⁩؛ ⁦Worker 128 MB⁩ وەردەگرێت.
  • : دیسکەکە تەنیا بۆ خوێندنەوەیە جگە لە بوخچەیەکی کاتی (/tmp لە Lambda و Vercelـدا) کە لەگەڵ ژینگەکەدا ون دەبێت. ئەو هەڵبار دەکرێن لە و لە هەڵبگرە.
  • دۆخ: لەگەڵ ژینگەکەیاندا دەمرن، وەک نموونەکە پیشانی دا.
Four cards. Time: stops at a time limit; Lambda 15 minutes; Workers Free 10 ms CPU. Memory: a fixed amount; Lambda 128 MB to 10 GB; Workers 128 MB. Files: only a scratch folder, /tmp, gone with the environment. State: variables are lost when an environment is removed. Below: so keep files in cloud storage and data in a database, and split long jobs into small steps or send them to a queue.چوار کارت. کات: لە سنووری کاتدا دەوەستێت؛ Lambda 15 خولەک؛ Workers Free 10 ms CPU. بیرگە: بڕێکی جێگیر؛ Lambda لە 128 MB تا 10 GB؛ Workers 128 MB. فایلەکان: تەنیا بوخچەیەکی کاتی، /tmp، کە لەگەڵ ژینگەکەدا ون دەبێت. دۆخ: گۆڕاوەکان ون دەبن کاتێک ژینگەیەک لادەبرێت. لە خوارەوە: بۆیە فایلەکان لە خەزنکردنی هەوریدا و دراوە لە بنکەدراوەدا هەڵبگرە و کاری درێژ بکە بە هەنگاوی بچووک یان بینێرە بۆ کیوویەک.
Four limits, and where to keep what does not fit inside them.چوار سنوور و ئەو شوێنەی کە ئەوەی تێیاندا جێی نابێتەوە لێی هەڵدەگیرێت.CêIT

Paying per requestپارەدان بۆ هەر داواکارییەک

Serverless follows the pay-as-you-go idea of cloud computing (measured service). AWS Lambda, for example, charges for the number of requests and for the time × memory your code uses, counted in GB-seconds. In November 2026 its US East price list said: $0.20 per million requests, about $0.0000167 per GB-second, and a free tier of 1 million requests and 400,000 GB-seconds a month. Worked example: a school's results API gets 3 million requests a month, and each runs 120 ms with 128 MB (0.125 GB).

پەیڕەوی بیرۆکەی ـی دەکات (خزمەتگوزاریی پێوانەکراو). بۆ نموونە AWS Lambda پارە بۆ ژمارەی و بۆ کات × ئەو کۆدەکەت بەکاری دەهێنێت وەردەگرێت، کە بە GB-چرکە دەژمێردرێت. لە تشرینی دووەمی ⁦2026⁩ـدا لیستی نرخی US East دەیگوت: ⁦$0.20⁩ بۆ هەر ملیۆنێک ، نزیکەی ⁦$0.0000167⁩ بۆ هەر GB-چرکەیەک و بەشی بێبەرانبەری مانگانە 1 ملیۆن و ⁦400,000 GB⁩-چرکە. نموونەیەکی کارکراو: APIـی ئەنجامەکانی قوتابخانەیەک مانگانە 3 ملیۆن وەردەگرێت و هەریەکەیان ⁦120 ms⁩ بە ⁦128 MB (0.125 GB)⁩ کار دەکات.

compute=3 000 000×0.12 s×0.125 GB=45 000 GB-s  (<400 000 free)requests=(3 000 000−1 000 000)×$0.201 000 000=$0.40\begin{aligned}\text{compute} &= 3\,000\,000 \times 0.12\,\text{s} \times 0.125\,\text{GB} = 45\,000\ \text{GB-s} \;(< 400\,000\ \text{free})\\ \text{requests} &= (3\,000\,000 - 1\,000\,000) \times \frac{\$0.20}{1\,000\,000} = \$0.40\end{aligned}

Total for the month: $0.40. Other services, such as data transfer, are billed separately.

کۆی مانگەکە: ⁦$0.40⁩. خزمەتگوزارییەکانی تر، وەک گواستنەوەی ، بە جیا حیساب دەکرێن.

A line chart of monthly cost against requests per month, from 0 to 100 million. A dashed flat line at $20 is a rented server that costs the same every month (an example). The serverless line starts at $0, passes $0.40 at 3 million requests, rises slowly to about $5 at 27 million, then faster, crosses $20 at about 60 million and reaches about $38 at 100 million. Example: each request runs 120 ms with 128 MB, AWS Lambda prices of November 2026.هێڵکارییەکی تێچووی مانگانە بەرانبەر ژمارەی داواکارییەکان لە مانگێکدا، لە 0 تا 100 ملیۆن. هێڵێکی ڕاستی خاڵخاڵ لە $20 ڕاژەکارێک بەکرێگیراوە کە هەموو مانگێک هەمان نرخی هەیە (نموونە). هێڵی ژمێرکاریی بێ‌ڕاژەکار لە $0 دەست پێ دەکات، لە 3 ملیۆن داواکاری دەگاتە $0.40، هێواش بەرز دەبێتەوە تا نزیکەی $5 لە 27 ملیۆن، پاشان خێراتر، لە نزیکەی 60 ملیۆندا $20 دەبڕێت و لە 100 ملیۆندا دەگاتە نزیکەی $38. نموونە: هەر داواکارییەک 120 ms بە 128 MB کار دەکات، نرخەکانی AWS Lambda لە تشرینی دووەمی 2026.
Cheap at small scale, growing with use: compare it with a fixed price.لە قەبارەی بچووکدا هەرزان، لەگەڵ بەکارهێناندا گەورە دەبێت: لەگەڵ نرخێکی جێگیردا بەراوردی بکە.CêIT

The other side: a bug that loops, or an attack, can send millions of requests, and the bill follows; at 100 million requests the same function would cost about $38 a month. Set a budget alert, and remember that moving to another provider later is work (vendor lock-in).

لایەنەکەی تر: کە بێ کۆتایی دووپاتە دەبێتەوە، یان هێرشێک، دەتوانێت ملیۆنان بنێرێت و پارەکەش بەدوایدا دێت؛ لە ⁦100⁩ ملیۆن هەمان مانگانە نزیکەی ⁦$38⁩ تێدەچێت. ئاگادارکەرەوەیەکی بودجە دابنێ و لە بیرت بێت گواستنەوە بۆ دابینکەرێکی تر دواتر کاری دەوێت (قەتیسبوون لای دابینکەر).

Edge functions: code close to every visitorکردارەکانی لێوار: کۆد نزیک لە هەموو سەردانکەرێک

A normal serverless function runs in one region that you choose; Vercel's default, for example, is Washington, D.C. (iad1). A visitor in Erbil then waits for a trip across the world and back. A already keeps copies of pages in many edge locations: data centres spread over the world. An edge function runs your code in those edge locations, so the one nearest the visitor answers. Cloudflare says its network reaches 348 cities and that 95% of internet users are within 50 ms of it (November 2026). Edge platforms such as Cloudflare Workers run code in small sandboxes inside one JavaScript engine (V8 isolates), which start far faster than a container, so cold starts are rare and short.

بێ‌ڕاژەکاری ئاسایی لە یەک ناوچەدا کار دەکات کە خۆت هەڵیدەبژێریت؛ بۆ نموونە بنەڕەتی Vercel واشنتنە (iad1). ئەوسا سەردانکەرێک لە هەولێر چاوەڕێی گەشتێک بە جیهاندا دەکات و دەگەڕێتەوە. پێشتر کۆپیی لە زۆر هەڵدەگرێت: ئەو بە جیهاندا بڵاو کراونەتەوە. کۆدەکەت لە کار پێدەکات، بۆیە نزیکترینیان لە سەردانکەرەکە وەڵام دەداتەوە. Cloudflare دەڵێت ڕایەڵەکەی دەگاتە ⁦348⁩ شار و ⁦95%⁩ـی بەکارهێنەرانی ئینتەرنێت لە ماوەی ⁦50 ms⁩ـدا لێیەوە نزیکن (تشرینی دووەمی ⁦2026⁩). سەکۆکانی لێوار وەک Cloudflare Workers کۆد لە ناو بچووکدا لە ناو یەک بزوێنەری JavaScript (isolateـەکانی ⁦V8⁩) کار پێدەکەن، کە زۆر خێراتر لە دەست پێ دەکەن، بۆیە دەگمەن و کورتن.

A stylised map. On the left, one origin server in one region. Around it, many small circles: edge locations. On the right, a visitor in Erbil; a short thick arrow goes to the nearest edge location, labelled near: a short trip; a long dashed curve goes to the origin server, labelled far: a long trip to the origin. Legend: an edge location is a CDN data centre that can run your edge function. Cloudflare: 348 cities; 95% of internet users within 50 ms (November 2026).نەخشەیەکی سادەکراو. لە چەپ، یەک ڕاژەکاری سەرچاوە لە یەک ناوچەدا. لە دەوری، زۆر بازنەی بچووک: شوێنەکانی لێوار. لە ڕاست، سەردانکەرێک لە هەولێر؛ تیرێکی کورت و ئەستوور دەچێت بۆ نزیکترین شوێنی لێوار، بە ناوی نزیک: گەشتێکی کورت؛ هێڵێکی چەماوەی درێژی خاڵخاڵ دەچێت بۆ ڕاژەکاری سەرچاوە، بە ناوی دوور: گەشتێکی درێژ بۆ ڕاژەکاری سەرچاوە. ڕوونکردنەوە: شوێنی لێوار ناوەندێکی دراوەی ڕایەڵەی گەیاندنی ناوەڕۆکە کە دەتوانێت کرداری لێوارەکەت کار پێ بکات. Cloudflare: 348 شار؛ 95%ـی بەکارهێنەرانی ئینتەرنێت لە ماوەی 50 msـدا (تشرینی دووەمی 2026).
The nearest edge location answers; the origin stays far away.نزیکترین وەڵام دەداتەوە؛ لە دوور دەمێنێتەوە.CêIT

Edge functions: code close to every visitorکردارەکانی لێوار: کۆد نزیک لە هەموو سەردانکەرێک

What edge functions are good atکردارەکانی لێوار بۆ چی باشن

An edge function is small and sees every request before the origin server does. That makes it good at quick decisions: redirects (send / to the visitor's language page); access checks (stop requests without the right secret before they reach the origin); A/B tests (keep each visitor in group A or B with a cookie); small personalisation (text or prices by country, from the platform's location data); and small, fast APIs and header changes.

بچووکە و هەموو پێش دەبینێت. ئەمە بۆ بڕیاری خێرا باشی دەکات: (/ بنێرە بۆ زمانی سەردانکەرەکە)؛ پشکنینی ( بەبێ نهێنییە دروستەکە ڕابگرە پێش ئەوەی بگەنە )؛ (هەر سەردانکەرێک بە لە کۆمەڵەی A یان B بهێڵەرەوە)؛ تایبەتکردنی بچووک (دەق یان نرخ بەپێی وڵات، لە شوێنی )؛ هەروەها APIـی بچووک و خێرا و گۆڕینی .

It is a poor fit for long or heavy work, for big libraries that need Node.js-only features or a disk, and for code that sends many queries to one database far away: every query would cross the world again. Vercel's documentation advises running functions close to their data for this reason.

بۆ کاری درێژ یان قورس، بۆ گەورە کە تایبەتمەندیی تایبەت بە ⁦Node.js⁩ یان دیسکیان پێویستە و بۆ کۆدێک کە زۆر بۆ یەک دوور دەنێرێت گونجاو نییە: هەر دیسان بە جیهاندا دەڕوات. Vercel بەم هۆیەوە ئامۆژگاری دەکات نزیک لە کار پێ بکرێن.

Two columns. Good at the edge: redirects from / to /ckb/ or /en/; access checks before the origin; A/B tests with a cookie; small changes per country or language; small, fast APIs and headers; in short, small, quick and close to the visitor. Better in a region or a server: long jobs such as video and big reports; heavy computing; big libraries or Node.js-only APIs; many queries to one far database; saving files on the disk; in short, near the data or with more time.دوو ستوون. باشە بۆ لێوار: ئاڕاستەکردنەوە لە / بۆ /ckb/ یان /en/؛ پشکنینی ڕێگەپێدان پێش ڕاژەکاری سەرچاوە؛ تاقیکردنەوەی A/B بە کووکییەک؛ گۆڕانکاریی بچووک بەپێی وڵات یان زمان؛ APIـی بچووک و خێرا و سەردێڕەکانی HTTP؛ بە کورتی بچووک، خێرا و نزیک لە سەردانکەر. باشترە لە ناوچەیەک یان ڕاژەکارێکدا: کاری درێژ وەک ڤیدیۆ و ڕاپۆرتێکی گەورە؛ ژمێرکاریی قورس؛ کتێبخانەی گەورە یان APIـی تایبەت بە Node.js؛ زۆر پرس بۆ یەک بنکەدراوە دوور؛ هەڵگرتنی فایل لەسەر دیسک؛ بە کورتی نزیک لە دراوە یان بە کاتی زیاتر.
Small and quick at the edge; heavy work and many queries near the data.بچووک و خێرا لە لێوار؛ کاری قورس و زۆر نزیک لە .CêIT

Edge functions: code close to every visitorکردارەکانی لێوار: کۆد نزیک لە هەموو سەردانکەرێک

An edge function with three jobsکردارێکی لێوار بە سێ کار

This edge function does all three jobs in the fetch style. env holds the settings that the platform passes in, so the admin secret is not written in the code. In the local run, env.origin stands in for the origin server.

ئەم هەر سێ کارەکە بە شێوازی fetch دەکات. env ئەو هەڵدەگرێت کە دەیاننێرێت، بۆیە نهێنیی بەڕێوەبەر لە کۆدەکەدا نانووسرێت. لە کارپێکردنی ناوخۆییدا env.origin جێگای دەگرێتەوە.

Redirect, access check and A/B testئاڕاستەکردنەوە، پشکنینی ڕێگەپێدان و تاقیکردنەوەی ⁦A/B⁩edge-function.mjsJSRuns on the serverلەسەر ڕاژەکاری وێب کار دەکات
// edge-function.mjs - three small jobs an edge function does before the origin server
export default {
  async fetch(request, env) {
    const url = new URL(request.url);

    // 1. Redirect: the home page sends each visitor to a page in their language
    if (url.pathname === '/') {
      const lang = request.headers.get('accept-language') ?? '';
      const page = lang.startsWith('ckb') ? '/ckb/' : '/en/';
      return Response.redirect(new URL(page, url), 302);
    }

    // 2. Auth check: stop requests to /admin that have no valid token
    if (url.pathname.startsWith('/admin')) {
      if (request.headers.get('authorization') !== `Bearer ${env.ADMIN_TOKEN}`) {
        return new Response('Unauthorized', { status: 401 });
      }
    }

    // 3. A/B test: every visitor stays in group A or B, remembered in a cookie
    const cookie = request.headers.get('cookie') ?? '';
    let group = cookie.match(/ab=(A|B)/)?.[1];
    const isNew = !group;
    group ??= Math.random() < 0.5 ? 'A' : 'B';

    const fromOrigin = await env.origin(request, group);     // ask the origin server
    const response = new Response(fromOrigin.body, fromOrigin);  // a copy we may change
    if (isNew) {
      response.headers.append('set-cookie', `ab=${group}; Path=/; Max-Age=2592000`);
    }
    return response;
  },
};
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 7-10

Redirect: Accept-Language is a standard HTTP header; new URL(page, url) makes the full address that Response.redirect() needs.

: Accept-Language کە هەموو دەینێرێت؛ new URL(page, url) ئەو ناونیشانە تەواوە دروست دەکات کە Response.redirect() پێویستیەتی.

Lineدێڕی 14-16

Access check: the secret comes from env, not from the code. A wrong or missing header gets 401 at the edge.

پشکنینی : نهێنییەکە لە envـەوە دێت، نەک لە کۆدەوە. هەڵە یان نەبوو لە لێوارەوە ⁦401⁩ وەردەگرێت.

Lineدێڕی 21-29

A/B test: an old visitor keeps the group in the cookie; a new one gets a random group and a cookie for 30 days.

: سەردانکەری کۆن کۆمەڵەکەی لە دەمێنێتەوە؛ سەردانکەری نوێ کۆمەڵەیەکی هەڕەمەکی و بۆ ⁦30⁩ ڕۆژ وەردەگرێت.

Playing the platformڕۆڵی سەکۆrun-edge.mjsJSType in a terminalلە تێرمیناڵدا بینووسە
// run-edge.mjs - play the platform: settings in env, and a pretend origin server
import edge from './edge-function.mjs';

const env = {
  ADMIN_TOKEN: 'demo-123',                                    // a setting, not in the code
  origin: async (request, group) =>
    new Response(`page ${new URL(request.url).pathname} (design ${group})`),
};
const site = 'https://shop.example';
const tests = [
  ['/', { 'accept-language': 'ckb-IQ,ckb;q=0.9,en;q=0.5' }],
  ['/', { 'accept-language': 'en-GB,en;q=0.9' }],
  ['/admin', {}],
  ['/admin', { authorization: 'Bearer demo-123' }],
  ['/products', { cookie: 'ab=B' }],
  ['/products', {}],
];

for (const [path, headers] of tests) {
  const res = await edge.fetch(new Request(site + path, { headers }), env);
  const where = res.headers.get('location') ?? (await res.text());
  const cookie = res.headers.get('set-cookie') ?? '';
  console.log(`${path.padEnd(9)} ${res.status}  ${where}  ${cookie}`);
}

Read the six lines: two redirects (Kurdish first, then English); 401 for /admin without the secret and the page with it; the visitor with the cookie ab=B stays in B and gets no new cookie; the new visitor gets a group and a set-cookie.

شەش دێڕەکە بخوێنەوە: دوو (سەرەتا کوردی، پاشان ئینگلیزی)؛ ⁦401⁩ بۆ /admin بەبێ نهێنییەکە و لەگەڵیدا؛ ئەو سەردانکەرەی ab=Bـی هەیە لە B دەمێنێتەوە و نوێ وەرناگرێت؛ سەردانکەرە نوێیەکە کۆمەڵەیەک و set-cookie وەردەگرێت.

Edge functions, edge computing and the cloudکردارەکانی لێوار، ژمێرکاریی لێوار و هەور

The word edge means “closer to where things happen”, but in different places. Edge functions run in a CDN's data centres, near the people who visit a website. Edge computing in the Internet of Things runs on the device itself or on a gateway next to it, near the sensors (cloud, fog and edge). A serverless function in a region runs in the cloud, near the data. And cloud databases can be serverless too: the provider adds and removes computing power and can pause the database when nobody uses it.

وشەی لێوار واتە «نزیکتر لەو شوێنەی شتەکانی لێ ڕوو دەدات»، بەڵام لە شوێنی جیاوازدا. لە کار دەکەن، نزیک لەو خەڵکەی سەردانی دەکەن. لە لەسەر خودی ئامێرەکە یان لەسەر دەروازەیەکی تەنیشتی کار دەکات، نزیک لە (هەور، تەم و لێوار). بێ‌ڕاژەکار لە ناوچەیەکدا لە هەوردا کار دەکات، نزیک لە . هەروەها بنکەدراوە هەورییەکانـیش دەتوانن بێ‌ڕاژەکار بن: دابینکەر توانای ژمێرکاری زیاد و کەم دەکات و دەتوانێت ڕابگرێت کاتێک کەس بەکاری ناهێنێت.

Three bands. Cloud region: serverless functions and databases, in a few big data centres. CDN edge: edge functions and cached pages, in hundreds of cities. IoT edge: edge computing on the device or a gateway, on millions of devices. Below: same word, three places; always ask where the code runs.سێ پشتێن. ناوچەی هەور: ژمێرکاریی بێ‌ڕاژەکار و بنکەدراوەکان، لە چەند ناوەندێکی دراوەی گەورەدا. لێواری CDN: کردارەکانی لێوار و لاپەڕەتۆڕەکان لە کاشدا، لە سەدان شاردا. لێواری IoT: ژمێرکاریی لێوار لەسەر ئامێر یان دەروازە، لەسەر ملیۆنان ئامێر. لە خوارەوە: یەک وشە، سێ شوێن؛ هەمیشە بپرسە کۆدەکە لە کوێ کار دەکات.
Same word, three places: always ask where the code runs.یەک وشە، سێ شوێن: هەمیشە بپرسە کۆدەکە لە کوێ کار دەکات.CêIT

Platforms in November 2026سەکۆکان لە تشرینی دووەمی ⁦2026⁩ـدا

Product names, runtimes and limits change every year, so learn the ideas and check the official pages before you choose. As of November 2026:

ناوی بەرهەمەکان، بەرنامەی زمانەکان و سنوورەکان هەموو ساڵێک دەگۆڕێن، بۆیە بیرۆکەکان فێر ببە و پێش هەڵبژاردن لاپەڕە فەرمییەکان بپشکنە. لە تشرینی دووەمی ⁦2026⁩ـدا:

Seven platforms, checked on their official pages in November 2026.حەوت ، لە تشرینی دووەمی ⁦2026⁩ـدا لە لاپەڕە فەرمییەکانیان پشکنراون.
PlatformWhere the code runsکۆدەکە لە کوێ کار دەکاتNotes (as of November 2026)تێبینی (تشرینی دووەمی ⁦2026⁩)
AWS Lambdaone region you chooseیەک ناوچە کە خۆت هەڵیدەبژێریتNode.js, Python, Java and more; up to 15 minutes per call; triggered by 200+ AWS services⁦Node.js⁩، Python، Java و زیاتر؛ تا ⁦15⁩ خولەک بۆ هەر بانگکردنێک؛ زیاتر لە ⁦200⁩ خزمەتگوزاریی AWS دەتوانن کاری پێ بکەن
Lambda@Edge, CloudFront FunctionsAWS's CDN edgeلێواری CDNـی AWSLambda@Edge: Node.js and Python. CloudFront Functions: JavaScript, under a millisecond, 2 MB of memory, no network access⁦Lambda@Edge: Node.js⁩ و ⁦Python. CloudFront Functions: JavaScript⁩، کەمتر لە میلی‌چرکەیەک، ⁦2 MB⁩ ، بێ دەستگەیشتن بە
Cloudflare Workers348 cities⁦348⁩ شارV8 isolates; free plan: 100,000 requests a day and 10 ms CPU per requestisolateـی ⁦V8⁩؛ پلانی بێبەرانبەر: ⁦100,000⁩ لە ڕۆژێکدا و ⁦10 ms CPU⁩ بۆ هەر
Vercel Functionsone region by default (iad1, Washington, D.C.)بە بنەڕەت یەک ناوچە (iad1، واشنتن)Node.js, Bun, Python, Go, Ruby, Rust, Wasm; the Edge runtime still exists, but Vercel now advises Node.js, and Next.js 16.3 no longer supports runtime = 'edge'⁦Node.js⁩، Bun، Python، Go، Ruby، Rust، Wasm؛ Edge runtime هێشتا هەیە، بەڵام Vercel ئێستا ⁦Node.js⁩ پێشنیار دەکات و ⁦Next.js 16.3⁩ چیتر پشتگیریی runtime = 'edge' ناکات
Netlify Functions, Netlify Edge FunctionsFunctions: one region (default Ohio); Edge Functions: the edgeFunctions: یەک ناوچە (بنەڕەت Ohio)؛ Edge Functions: لێوارEdge Functions run on Deno: 50 ms CPU per request, 512 MBEdge Functions لەسەر Deno کار دەکەن: ⁦50 ms CPU⁩ بۆ هەر ، ⁦512 MB⁩
Supabase Edge Functionsregional nodes near usersنۆدی ناوچەیی نزیک لە TypeScript, Deno-compatible; 2 s CPU, 256 MB, 150 s (free) or 400 s (paid)TypeScript، گونجاو لەگەڵ Deno؛ ⁦2 s CPU⁩، ⁦256 MB⁩، ⁦150 s⁩ (بێبەرانبەر) یان ⁦400 s⁩ (پارەدار)
Deno Deploy2 regions (the new platform)2 ناوچە (سەکۆ نوێیەکە)JavaScript and TypeScript; Deploy Classic was shut down on 20 July 2026JavaScript و TypeScript؛ Deploy Classic لە ⁦20⁩ی تەمموزی ⁦2026⁩ داخرا
Two groups of platforms. In a region you choose: AWS Lambda (Node.js, Python, Java and more), Vercel Functions (default region iad1, Washington, D.C.), Deno Deploy, the new version (2 regions; Classic closed on 20 July 2026), Netlify Functions (functions in one region). Near the visitor, at the edge: Cloudflare Workers (V8 isolates in 348 cities), CloudFront Functions and Lambda@Edge (AWS's CDN edge), Netlify Edge Functions (Deno, 50 ms CPU per request), Supabase Edge Functions (Deno-compatible, near users). Below: names and limits change every year; Vercel now advises Node.js instead of its Edge runtime.دوو کۆمەڵە سەکۆ. لە ناوچەیەک کە خۆت هەڵیدەبژێریت: AWS Lambda (Node.js، Python، Java و زیاتر)، Vercel Functions (ناوچەی بنەڕەت iad1، واشنتن)، Deno Deploy، وەشانە نوێیەکە (2 ناوچە؛ Classic لە 20ی تەمموزی 2026 داخرا)، Netlify Functions (کردارەکان لە یەک ناوچەدا). نزیک لە سەردانکەر، لە لێوار: Cloudflare Workers (لە 348 شاردا، بە V8)، CloudFront Functions و Lambda@Edge (لێواری CDNـی AWS)، Netlify Edge Functions (Deno، 50 ms CPU بۆ هەر داواکارییەک)، Supabase Edge Functions (گونجاو لەگەڵ Deno، نزیک لە بەکارهێنەرەکان). لە خوارەوە: ناو و سنوورەکان هەموو ساڵێک دەگۆڕێن؛ Vercel ئێستا Node.js لە جیاتی Edge runtimeـەکەی پێشنیار دەکات.
Two families: functions in a region, and functions at the edge.دوو خێزان: لە ناوچەیەکدا و لە لێواردا.CêIT

Common mistakesهەڵە باوەکان

Wrong: a relative URL in Response.redirect()هەڵە: URLـێکی کورت لە ⁦Response.redirect()⁩ـداmistake-redirect.mjsJSType in a terminalلە تێرمیناڵدا بینووسە
// mistake-redirect.mjs - Response.redirect() needs a full URL
const response = Response.redirect('/ckb/', 302);
console.log(response.status);

Fix: build the full address from the request, as the edge function does: Response.redirect(new URL('/ckb/', request.url), 302).

چارەسەر: ناونیشانە تەواوەکە لە دروست بکە، وەک دەیکات: Response.redirect(new URL('/ckb/', request.url), 302).

Exercisesڕاهێنانەکان

Exerciseڕاهێنان

Serverless function, edge function or a long-running server? (a) Send visitors from / to /ckb/ or /en/. (b) Build a report every night at 02:00. (c) A chat service that keeps thousands of connections open all day. (d) Make a small copy of every photo that is uploaded.

بێ‌ڕاژەکار، یان کە هەمیشە کار دەکات؟ (أ) ناردنی سەردانکەران لە /ـەوە بۆ /ckb/ یان /en/. (ب) دروستکردنی هەموو شەوێک لە کاتژمێر ⁦02:00⁩. (ج) خزمەتگوزارییەکی چات کە هەزاران پەیوەندی هەموو ڕۆژەکە کراوە دەهێڵێتەوە. (د) دروستکردنی کۆپییەکی بچووک بۆ هەر وێنەیەک کە هەڵبار دەکرێت.

Show answerوەڵامەکە پیشان بدە
  • (a) An edge function: a tiny decision about each request, best made near the visitor.
  • (b) A serverless function with a timer trigger.
  • (c) A long-running server, or a service built for open connections: functions are made for short calls with time limits.
  • (d) A serverless function with a file-upload trigger.
  • (أ) : بڕیارێکی بچووک لەبارەی هەر ، باشترە لە نزیک سەردانکەرەوە بدرێت.
  • (ب) بێ‌ڕاژەکار کە دەستی پێ دەکات.
  • (ج) کە هەمیشە کار دەکات، یان خزمەتگوزارییەک کە بۆ پەیوەندیی کراوە دروست کراوە: بۆ بانگکردنی کورت و بە سنووری کات دروست کراون.
  • (د) بێ‌ڕاژەکار کە دەستی پێ دەکات.
Exerciseڕاهێنان

With the Lambda prices of this lesson, what does a function cost per month if it gets 4 million requests, each running 200 ms with 256 MB?

بە نرخەکانی Lambda لەم وانەیەدا، مانگانە چەندی تێدەچێت ئەگەر 4 ملیۆن وەربگرێت و هەریەکەیان ⁦200 ms⁩ بە ⁦256 MB⁩ کار بکات؟

Show answerوەڵامەکە پیشان بدە
compute=4 000 000×0.2 s×0.25 GB=200 000 GB-s  (<400 000 free)requests=(4 000 000−1 000 000)×$0.201 000 000=$0.60\begin{aligned}\text{compute} &= 4\,000\,000 \times 0.2\,\text{s} \times 0.25\,\text{GB} = 200\,000\ \text{GB-s} \;(< 400\,000\ \text{free})\\ \text{requests} &= (4\,000\,000 - 1\,000\,000) \times \frac{\$0.20}{1\,000\,000} = \$0.60\end{aligned}

Total: $0.60 a month, before other services such as data transfer.

کۆ: ⁦$0.60⁩ لە مانگێکدا، پێش خزمەتگوزارییەکانی تر وەک گواستنەوەی .

Exerciseڕاهێنان

Change hello-function.mjs so that /hello answers only GET. Any other method must get status 405 and the header Allow: GET. Test it with GET, POST and DELETE.

hello-function.mjs بگۆڕە بۆ ئەوەی /hello تەنیا وەڵامی GET بداتەوە. هەر تر دەبێت ⁦405⁩ و Allow: GET وەربگرێت. بە GET، POST و DELETE تاقیی بکەرەوە.

Hintئاماژە

Check request.method before you build the JSON; new Response(body, { status, headers }) sets both.

پێش دروستکردنی JSONـەکە request.method بپشکنە؛ new Response(body, { status, headers }) هەردووکیان دادەنێت.

Show answerوەڵامەکە پیشان بدە
hello-get-only.mjsJSRuns on the serverلەسەر ڕاژەکاری وێب کار دەکات
// hello-get-only.mjs - /hello answers only GET; other methods get 405
export default {
  async fetch(request) {
    const url = new URL(request.url);

    if (url.pathname === '/hello') {
      if (request.method !== 'GET') {
        return new Response('Method Not Allowed', { status: 405, headers: { allow: 'GET' } });
      }
      const name = url.searchParams.get('name') ?? 'world';
      return Response.json({ message: `Hello, ${name}!` });
    }
    return new Response('Not found', { status: 404 });
  },
};
test-get-only.mjsJSType in a terminalلە تێرمیناڵدا بینووسە
import fn from './hello-get-only.mjs';

for (const method of ['GET', 'POST', 'DELETE']) {
  const res = await fn.fetch(new Request('https://example.com/hello?name=Dilan', { method }));
  console.log(method.padEnd(6), res.status, res.headers.get('allow') ?? '-', await res.text());
}
Exerciseڕاهێنان

Find the bug: let visits = 0; export default { fetch() { visits++; return Response.json({ visits }); } }; is used as the visitor counter of a school website.

بدۆزەرەوە: let visits = 0; export default { fetch() { visits++; return Response.json({ visits }); } }; وەک سەردانکەرانی قوتابخانەیەک بەکار دەهێنرێت.

Show answerوەڵامەکە پیشان بدە

Each execution environment has its own visits, starting at 0 at its cold start, and the number disappears when the environment is removed. Two visitors can both see 1, and the count falls back after a quiet night. Store the count in a database and add 1 there with one UPDATE.

هەر visitsـی خۆی هەیە کە لە لە 0ـەوە دەست پێ دەکات و کاتێک ژینگەکە لادەبرێت ژمارەکە نامێنێت. دوو سەردانکەر دەتوانن هەردووکیان 1 ببینن و دوای شەوێکی بێدەنگ ژمارەکە دەگەڕێتەوە دواوە. ژمارەکە لە هەڵبگرە و بە یەک UPDATE لەوێ 1ـی بۆ زیاد بکە.

Exerciseڕاهێنان

An edge function runs 12 queries on a database in Frankfurt for every page. Visitors in Erbil and in Sydney both complain that pages are slow. Why, and what would you change?

بۆ هەر ⁦12⁩ لەسەر لە فرانکفۆرت جێبەجێ دەکات. سەردانکەران لە هەولێر و لە سیدنی هەردووکیان سکاڵا دەکەن کە خاون. بۆچی و چی دەگۆڕیت؟

Show answerوەڵامەکە پیشان بدە

The function runs near each visitor, but each of the 12 queries travels to Frankfurt and back, so the far trip is paid 12 times. Run that function in a region next to the database (or a regional serverless function), send fewer queries (one query that returns everything), or cache answers at the edge.

نزیک لە هەر سەردانکەرێک کار دەکات، بەڵام هەر یەک لە ⁦12⁩ دەچێت بۆ فرانکفۆرت و دەگەڕێتەوە، بۆیە گەشتە دوورەکە ⁦12⁩ جار دەدرێت. ئەو لە ناوچەیەکی تەنیشت کار پێ بکە ( بێ‌ڕاژەکاری ناوچەیی)، کەمتر بنێرە (یەک کە هەموو شتێک بگەڕێنێتەوە)، یان لە لێوار لە هەڵبگرە.

Summaryپوختە

  • Serverless computing: servers still exist, but the provider runs and scales them; FaaS runs single functions per event and bills per request and time.
  • SQLite's serverless (no database server program) is a different meaning from the cloud's.
  • Functions run because of events (HTTP, uploads, queues, timers, database changes) connected by triggers; the fetch-style handler takes a Request and returns a Response.
  • A cold start prepares a new execution environment; warm starts reuse it. Code outside the handler runs once per environment; never keep data in variables.
  • Limits: time, memory, a temporary disk and no lasting state. Pricing: per request and GB-second, with free tiers; set a budget alert.
  • Edge functions run in a CDN's edge locations near the visitor: good for redirects, access checks, A/B tests and small APIs; not for heavy work or many far queries. They are not IoT edge computing, which runs on the device.
  • : هەر هەن، بەڵام دابینکەر کاریان پێدەکات و زیاد و کەمیان دەکات؛ بۆ هەر کار پێدەکات و بەپێی و کات پارە وەردەگرێت.
  • بێ‌ڕاژەکارـی SQLite (هیچ نییە) واتایەکی جیاوازە لە هی هەور.
  • بەهۆی کار دەکەن (HTTP، ، ، ، گۆڕانکاریی ) کە بە دەبەسترێنەوە؛ شێوازی fetch Request وەردەگرێت و Response دەگەڕێنێتەوە.
  • نوێ ئامادە دەکات؛ دووپاتە بەکاری دەهێننەوە. کۆدی دەرەوەی بۆ هەر ژینگەیەک یەکجار کار دەکات؛ هەرگیز لە هەڵمەگرە.
  • سنوورەکان: کات، ، دیسکی کاتی و هیچ دۆخێکی بەردەوام. نرخ: بۆ هەر و GB-چرکەیەک، بە بەشی بێبەرانبەرەوە؛ ئاگادارکەرەوەی بودجە دابنێ.
  • لە نزیک لە سەردانکەر کار دەکەن: بۆ ، پشکنینی ، و APIـی بچووک باشن؛ بۆ کاری قورس یان زۆر دوور نا. ئەمانە IoT نین، کە لەسەر ئامێرەکە کار دەکات.

Next: put the whole course together in Course review and practice.

دواتر: هەموو کۆرسەکە لە پێداچوونەوە و ڕاهێنانی کۆرسـدا پێکەوە کۆ بکەرەوە.

Lesson complete!وانەکە تەواو بوو!

Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.

Key termsزاراوە سەرەکییەکان

Next lessonوانەی داهاتوو

Course review and practiceپێداچوونەوە و ڕاهێنانی کۆرسەکە

References and further readingسەرچاوەکان و خوێندنەوەی زیاتر

This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.

Appearanceڕووکار

Modeدۆخ
Styleشێواز
Coloursڕەنگەکان

Saved on this device only.تەنیا لەسەر ئەم ئامێرە پاشەکەوت دەکرێت.