Wednesday, 22 July 2026

Building a Real-Time IoT Telemetry Pipeline on AWS:

 IoT Core → Kinesis → Lambda → ECS Fargate

Ingesting live IoT data without crashing or burning money isn't easy. In this post, we walk through a battle-tested AWS setup using IoT Core for ingestion, Kinesis for ordered streaming, Lambda for fast data checks, and ECS Fargate to power your live dashboards.

The Real Challenge with Scaling IoT Ingestion
If you're dealing with just one smart sensor or connected device, building a pipeline is easy. You hook up an API endpoint, ingest the data, and call it a day.

Where things actually get tricky is when you scale up to thousands of devices sending data at the exact same time.

Some devices drop offline, others blast rapid-fire updates, and suddenly you're facing classic distributed system problems:
  • How do you keep bad actors out? You need a way to authenticate every single device cleanly at scale.
  • How do you keep data in order? Time-series data doesn't make sense if readings arrive out of sequence.
  • How do you keep costs down? You don't want to pay for idle servers when traffic dips at night.
  • How do you keep things decoupled? Your analytics team, alerting systems, and raw storage shouldn't all break when one component fails.
To solve this, we rely on a classic four-stage AWS architecture: Ingest -> Stream -> Process -> Serve. Let’s break down how it all fits together.

What the Architecture Looks Like


How the Services Work Together

1. AWS IoT Core (Inbound Device Traffic)
First up, devices need to talk to the cloud. We use MQTT over TLS because it's super lightweight on bandwidth and battery life.

Each device gets its own X.509 certificate. This is huge for security if a device in the field gets tampered with, you can revoke its specific certificate instantly without taking down the rest of your fleet.

We also make heavy use of Device Shadows. Since field devices drop offline all the time due to bad cellular coverage or power-saving modes, the Device Shadow holds onto the last known state in JSON format. That way, your apps aren't left guessing what happened while a device was disconnected.

Once data hits IoT Core, SQL-based IoT Rules route incoming payloads straight into Kinesis, skipping the need for custom ingestion logic or API gateways.

2. Amazon Kinesis Data Streams (The Streaming Backbone)
You might ask: Why Kinesis instead of SQS or SNS?

Two main reasons: Ordering and Fan-out.
  1. Ordering: Kinesis guarantees that data within a shard stays strictly in sequence. If device #102 sends temperature readings every second, you need to read them in the exact order they were captured.
  2. Fan-out: A single stream can feed multiple downstream services at the same time. You can have one Lambda function checking for emergency alerts while another process dumps raw data into S3 for long-term storage—without duplicating data requests.
3. AWS Lambda (Fast, Event-Driven Processing)
Once Kinesis grabs the data stream, AWS Lambda kicks in. Lambda pulls records off the stream in small batches to run light validations, schema transforms, or quick anomaly checks (like checking if a sensor reading spiked above an alert threshold).

Lambda is a perfect fit here because the workload is stateless and bursty. It scales up instantly as stream volume grows, and you only pay for the exact milliseconds your code runs.

However, Lambda isn't built for long-running connections or sitting idle waiting for incoming requests. That's where Fargate comes in.

4. Amazon ECS on AWS Fargate (Backend Services & Dashboards)
Finally, you need a backend to serve data to your web applications, mobile apps, or live dashboard feeds.

Instead of running long-lived jobs on Lambda, we run containerized apps on ECS with Fargate. Fargate handles persistent tasks—like maintaining continuous WebSocket connections or serving REST APIs—without forcing you to manage EC2 instances or patch operating systems.

Lambda vs. Fargate: Which Should You Use Where?

Feature
AWS Lambda (Processing Layer)
ECS on AWS Fargate (Backend Layer)
Workload Type
Short-lived,event-driven, stateless
Sustained,long-running, connection-heavy
Best Used For
Input validation, record filtering, instant alerts
WebSockets, REST APIs, live dashboard servers
Scaling Logic
Automatic based on incoming stream records
Target tracking auto-scaling (CPU / Memory)
Cost Strategy
Pay per request & execution millisecond
Pay per vCPU & memory assigned per hour

Pro Tips for Getting This Right in Production
  • Design Your Partition Keys Carefully: Always set partition keys on Kinesis using a well-distributed ID like device_id. If you pick a poor partition key, you'll create hot shards—flooding one partition while others stay completely empty.
  • Keep Lambda Functions Single-Purpose: Don't write monster Lambda functions that validate data, call external APIs, write to databases, and send emails all at once. Break them up. Single-purpose Lambdas start faster and are much easier to debug when things go wrong.
  • Rely on Device Shadows Early: Don't treat device connectivity as a given. Build your UI and APIs to read from Device Shadows so your users always see reliable, cached state data even when field devices drop off.
  • Enforce Strict IAM Roles: Make sure your execution roles follow least privilege. Your processing Lambdas should only have read access to specific Kinesis streams and write access to designated output destinations.
Frequently Asked Questions

Why use MQTT instead of standard HTTP for IoT devices?
MQTT is much lighter on network overhead than HTTP. If your devices run on batteries or unreliable cellular networks, MQTT uses significantly less data and power to stay connected.

Why not just use SQS instead of Kinesis?
SQS is great for message queues, but it doesn't guarantee strict record ordering across standard queues, and it isn't designed for multiple consumers reading the exact same payload at the same time (fan-out). Kinesis handles both out of the box.

Can I run the entire backend on Fargate instead of using Lambda?
You can, but it usually ends up costing more. Using Lambda to process event-driven batches from Kinesis keeps compute costs low, leaving Fargate to handle long-running API connections and dashboards.

💡 Cloud.in FinOps Tip: Keep an eye on your Write Provisioned Through put Exceeded metric. If you set up Application Auto Scaling on your Kinesis shards early, you won't end up paying for unused shards capacity during off-peak hours.

Planning an IoT Project on AWS?
Building a scalable IoT pipeline isn't just about stringing services together—it's about balancing stream capacity, security controls, and long-term operating costs.

At Cloud.in, we help teams design, build, and optimize scalable AWS environments tailored to their workloads.

The blog is written by Ashirwad Khairnar, Senior Cloud Engineer, Cloud.in

No comments:

Post a Comment

Building a Real-Time IoT Telemetry Pipeline on AWS:

 IoT Core → Kinesis → Lambda → ECS Fargate Ingesting live IoT data without crashing or burning money isn't easy. In this post, we walk t...