ทำความเข้าใจรูปแบบการทำงานของ Serverless
เจาะลึกการทำงานจริงของฟังก์ชันแบบ Serverless ได้แก่ รูปแบบการเรียกใช้ การเริ่มทำงานแบบเย็น การทำงานพร้อมกัน และธรรมชาติไร้สถานะของฟังก์ชัน
ทำความเข้าใจรูปแบบการทำงานของ Serverless เป็นบทเรียน Serverless Backend with AWS Lambda & API Gateway ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Serverless Backend with AWS Lambda & API Gateway และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Serverless Backend with AWS Lambda & API Gateway มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Functions as the Unit of Compute
In serverless, the function is the unit of deployment and scaling. The platform provisions compute only when an event arrives, and scales to zero when idle.
Event-Driven Invocation
Functions run in response to events — an HTTP request, a queue message, a file upload, a schedule. The event payload lands in your handler.
Synchronous vs Asynchronous
Invocations are synchronous (caller waits for the result) or asynchronous (event is queued, processed later, and retried on failure).
A Minimal Handler
A handler takes an event and returns a response — the platform manages everything around it. Run this to see it in action.
def handler(event, context):
name = event.get("name", "world")
return {"message": "Hello, " + name}
print(handler({"name": "Ada"}, None))Cold Starts
The first call on fresh capacity hits a cold start: the platform fetches code, boots a runtime, and initializes. Warm calls afterward are much faster.
Reducing Cold Start Impact
Tame cold starts by keeping packages small, picking fast-starting runtimes, and using provisioned concurrency on latency-critical paths.
Concurrency and Scaling
Each concurrent event runs in its own instance. The platform scales out automatically, so 1000 simultaneous requests can mean 1000 parallel executions.
The Execution Environment
An instance handles one request, then gets reused for the next. Code outside the handler runs once per environment — perfect for setting up shared connections.
db = connect() # runs once per warm environment
def handler(event, context):
return db.query(event["id"])Statelessness
Functions are stateless: never count on in-memory data surviving between calls, since instances come and go. Persist state in a database, cache, or object store.
Timeouts and Limits
Functions cap out on duration, memory, and payload size. Break long work into steps or another service — and note that more memory also means more CPU.
Cost Model
You pay for invocations × duration × memory. Idle functions cost nothing, which makes serverless economical for spiky or low-volume workloads.
Quick Check
Test your understanding of the serverless execution model.
Recap
Recap of the execution model: event-driven sync/async calls, cold starts you can mitigate, automatic concurrency, environment reuse, statelessness, and pay-per-use.
เรียนรู้ Serverless Backend with AWS Lambda & API Gateway ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 12
- บทเรียน
- 48
คำถามที่พบบ่อย
บทเรียน “ทำความเข้าใจรูปแบบการทำงานของ Serverless” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ทำความเข้าใจรูปแบบการทำงานของ Serverless” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Serverless Backend with AWS Lambda & API Gateway ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Serverless Backend with AWS Lambda & API Gateway มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ทำความเข้าใจรูปแบบการทำงานของ Serverless”
เจาะลึกการทำงานจริงของฟังก์ชันแบบ Serverless ได้แก่ รูปแบบการเรียกใช้ การเริ่มทำงานแบบเย็น การทำงานพร้อมกัน และธรรมชาติไร้สถานะของฟังก์ชัน คุณปฏิบัติ Serverless Backend with AWS Lambda & API Gateway ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Serverless Backend with AWS Lambda & API Gateway หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Serverless Backend with AWS Lambda & API Gateway บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “ทำความเข้าใจรูปแบบการทำงานของ Serverless” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Serverless Backend with AWS Lambda & API Gateway นี้ได้ไหม
ได้ บทเรียน Serverless Backend with AWS Lambda & API Gateway ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ไร้เซิร์ฟเวอร์คืออะไร
- ภาพรวมบริการหลักของ AWS
- ฟังก์ชัน Lambda แรกของคุณ (ไพธอน)
- ทำความเข้าใจรูปแบบการทำงานของ Serverless