# IoT ingestion into Postgres

> 5,000 devices send a reading every minute. Where does the money go? For ingest-and-report, Postgres wins. The expensive part is the front door, not the database. Fix REST and per-message invocations, and the bill drops from about $1,100 to $215–410.

- A decision guide from The Stack by Nicolas Dao (Cloudless Labs, Sydney)
- Web page: https://cloudlesslabs.com/stack/guides/iot-ingestion/. The whole stack in one file: https://cloudlesslabs.com/stack/brief.md
- Tools: [AWS IoT Core](https://cloudlesslabs.com/stack/aws-iot-core/index.md) (Use when it fits (Proposed: research-backed, not yet confirmed by Nic)), [Amazon SQS](https://cloudlesslabs.com/stack/aws-sqs/index.md) (My default), [API Gateway](https://cloudlesslabs.com/stack/aws-api-gateway/index.md) (Use when it fits), [Amazon SNS](https://cloudlesslabs.com/stack/aws-sns/index.md) (Use when it fits), [Neon (serverless Postgres)](https://cloudlesslabs.com/stack/neon/index.md) (My default), [Aurora PostgreSQL](https://cloudlesslabs.com/stack/aws-aurora/index.md) (Use when it fits), [Cloudflare Durable Objects](https://cloudlesslabs.com/stack/cloudflare-durable-objects/index.md) (Use when it fits)

216M messages a month, Sydney, Postgres already running for other workloads.

| Design | Monthly |
|---|---|
| API Gateway REST → SNS → Lambda → Postgres | $1,014–1,109 (REST alone $756, SNS $107.50, Lambda $88) |
| HTTP API → SQS → batched Lambda → Postgres | ~$410 |
| IoT Core Basic Ingest → SQS → batched Lambda → Postgres | ~$215–230 (MQTT devices with certificates) |
| Durable Objects + history to R2 | ~$70–235, but no SQL across devices |

- Keep Postgres: SQL across devices, one system, Sydney residency, compute shared with other workloads.
- Fix the front door (HTTP API or IoT Core instead of REST) and batch into Lambda through SQS.
- Watch storage: about 260 GB of growth a month, roughly $340 a month after a year.
- Durable Objects only win when devices need live sessions: commands sent down, per-device real-time state, live dashboards.

## Related

- [Device and IoT data](https://cloudlesslabs.com/stack/use-cases/iot.md): the use case this guide works through
- [AWS IoT Core](https://cloudlesslabs.com/stack/aws-iot-core/index.md): the full entry (verdict, pricing, gotchas)
- [Amazon SQS](https://cloudlesslabs.com/stack/aws-sqs/index.md): the full entry (verdict, pricing, gotchas)
- [API Gateway](https://cloudlesslabs.com/stack/aws-api-gateway/index.md): the full entry (verdict, pricing, gotchas)
- [Amazon SNS](https://cloudlesslabs.com/stack/aws-sns/index.md): the full entry (verdict, pricing, gotchas)
- [Neon (serverless Postgres)](https://cloudlesslabs.com/stack/neon/index.md): the full entry (verdict, pricing, gotchas)
- [Aurora PostgreSQL](https://cloudlesslabs.com/stack/aws-aurora/index.md): the full entry (verdict, pricing, gotchas)
- [Cloudflare Durable Objects](https://cloudlesslabs.com/stack/cloudflare-durable-objects/index.md): the full entry (verdict, pricing, gotchas)
- [Every decision guide](https://cloudlesslabs.com/stack/brief.md): listed at the end of the brief
- [Map of every Markdown file on cloudlesslabs.com, with what each one answers](https://ask.cloudlesslabs.com)
