0Pricing
Serverless AWS Lambda Development · บทเรียน

การประมวลผลแบบเรียลไทม์ด้วย Kinesis

ใช้ Amazon Kinesis Data Streams และ Kinesis Firehose เพื่อรับข้อมูล ประมวลผล และส่งมอบสตรีมข้อมูลขนาดใหญ่แบบเรียลไทม์ด้วยฟังก์ชัน Lambda

การประมวลผลแบบเรียลไทม์ด้วย Kinesis เป็นบทเรียน Serverless AWS Lambda Development ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Serverless AWS Lambda Development และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Serverless AWS Lambda Development มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Real-time Data Matters

In today's fast-paced world, many applications need to react to data instantly. This is known as real-time data processing.

  • Immediate insights: Analyze data as it arrives.
  • Quick responses: Trigger actions without delay.
  • Enhanced user experience: Personalize content on the fly.

Think of fraud detection, live dashboards, or IoT device monitoring.

Introducing Amazon Kinesis

Amazon Kinesis is a powerful suite of services designed for collecting, processing, and analyzing streaming data in real-time. It helps you handle massive volumes of data efficiently.

Key Kinesis services include:

  • Kinesis Data Streams (KDS): For custom applications needing granular control.
  • Kinesis Firehose: For easy delivery to data stores like S3 or Redshift.

Kinesis Data Streams (KDS)

Kinesis Data Streams (KDS) is like a continuous pipeline for high-throughput data. It captures data from various sources and makes it available for processing by different applications.

KDS organizes data into shards. A shard is a base unit of throughput. Data producers write to shards, and data consumers read from them.

Producing Data to KDS

Applications send data to KDS using operations like PutRecord or PutRecords. Each record includes a partition key, which KDS uses to group data and route it to a specific shard.

A good partition key ensures even distribution of data across shards, preventing hot spots and maximizing throughput.

Lambda as a KDS Consumer

AWS Lambda functions are excellent consumers for Kinesis Data Streams. You can configure a Lambda event source mapping to automatically invoke your function whenever new data records are available in a KDS stream.

Lambda polls the stream, reads records in batches, and passes them to your function for processing. This makes building real-time processors very efficient.

Processing Kinesis Records

Here's a simple Python Lambda function that processes records from a Kinesis Data Stream. It iterates through the records in the event and prints their data.

Try running this example:

import base64
import json

def lambda_handler(event, context):
    for record in event['Records']:
        # Kinesis data is base64 encoded
        payload = base64.b64decode(record['kinesis']['data']).decode('utf-8')
        print(f"Processed record: {payload}")
        
    return {'statusCode': 200}

Kinesis Firehose for Delivery

Kinesis Firehose is a fully managed service for delivering real-time streaming data to destinations like Amazon S3, Amazon Redshift, Amazon OpenSearch Service, or HTTP endpoints.

Unlike KDS, Firehose requires almost no administration. You simply create a delivery stream, specify your source and destination, and Firehose handles all the scaling, buffering, and delivery.

Firehose Destinations

Firehose is designed for simplified data delivery. It automatically batches, compresses, and encrypts data before sending it to your chosen destination.

Common destinations include:

  • Amazon S3: For long-term storage and data lakes.
  • Amazon Redshift: For data warehousing and analytics.
  • Amazon OpenSearch Service: For logging and search.
  • HTTP endpoints: For custom integrations.

Transform Data with Firehose & Lambda

Kinesis Firehose can integrate with Lambda to transform incoming data before it's delivered to its final destination. This is incredibly useful for cleaning, enriching, or reformatting data on the fly.

You configure a Lambda function within your Firehose delivery stream, and Firehose invokes it for each batch of records, expecting transformed records in return.

Kinesis Service Comparison

Which statements accurately describe the differences or uses of Kinesis Data Streams (KDS) and Kinesis Firehose?

Recap & Next Steps

You've learned about Amazon Kinesis, a key service for real-time data processing.

  • Kinesis Data Streams (KDS): Offers flexible, shard-based streaming for custom applications, often consumed by Lambda.
  • Kinesis Firehose: Provides a managed solution for delivering streaming data to various destinations, with optional Lambda transformation.

These services, combined with Lambda, enable powerful event-driven architectures for handling massive data streams in real-time.

คำถามที่พบบ่อย

บทเรียน “การประมวลผลแบบเรียลไทม์ด้วย Kinesis” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การประมวลผลแบบเรียลไทม์ด้วย Kinesis” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Serverless AWS Lambda Development ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Serverless AWS Lambda Development มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การประมวลผลแบบเรียลไทม์ด้วย Kinesis”

ใช้ Amazon Kinesis Data Streams และ Kinesis Firehose เพื่อรับข้อมูล ประมวลผล และส่งมอบสตรีมข้อมูลขนาดใหญ่แบบเรียลไทม์ด้วยฟังก์ชัน Lambda คุณปฏิบัติ Serverless AWS Lambda Development ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Serverless AWS Lambda Development หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Serverless AWS Lambda Development บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “การประมวลผลแบบเรียลไทม์ด้วย Kinesis” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Serverless AWS Lambda Development นี้ได้ไหม

ได้ บทเรียน Serverless AWS Lambda Development ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การสร้างไมโครเซอร์วิสขับเคลื่อนด้วยเหตุการณ์
  2. การผสานรวมกับ Amazon EventBridge
  3. การประมวลผลแบบเรียลไทม์ด้วย Kinesis
  4. รูปแบบ Saga สำหรับธุรกรรมแบบกระจาย
← กลับไปที่ Serverless AWS Lambda Development