Streaming and Analytics on AWS: Kinesis, Firehose, Glue, Athena, EMR, QuickSight and Data Lake Design
The Analytics Pipeline
text
Sources ─► INGEST ─────────► STORE ───────► PROCESS ─────────► ANALYZE / SERVE
apps, IoT Kinesis, Firehose S3 data lake Glue ETL, EMR, Athena, Redshift,
databases DMS, MSK, Snow (raw → curated) Lambda, Flink QuickSight, OpenSearch, SageMaker
Streaming Ingest: Kinesis
| Service | What it does | Key points |
|---|---|---|
| Kinesis Data Streams (KDS) | Real-time stream you read yourself (custom consumers). Data kept 24 hours up to 365 days, can be replayed | Shards: each gives about 1 MB/s or 1,000 records/s in and 2 MB/s out. On-demand mode scales automatically. Partition key decides the shard (avoid hot shards). Multiple consumers, enhanced fan-out |
| Kinesis Data Firehose (Amazon Data Firehose) | Fully managed delivery of streams into S3, Redshift, OpenSearch, Splunk, HTTP endpoints | Near real-time (buffer by size and time, minimum about 60 seconds, lower with newer options). Optional Lambda transform, convert to Parquet/ORC, compress. No storage or replay, no code for consumers |
| Managed Service for Apache Flink | Real-time SQL/Java/Python processing on streams | Windowing, aggregations, anomaly detection |
| Kinesis Video Streams | Stream video from devices | Camera, ML analysis |
| Amazon MSK (Managed Streaming for Apache Kafka) | Managed Kafka clusters, MSK Serverless | Use when you already use Kafka or need its ecosystem |
KDS vs Firehose: Need custom processing, replay or multiple consumers → Data Streams. Just load streaming data into S3/Redshift/OpenSearch with little work → Firehose.
python
import boto3, json
kinesis = boto3.client("kinesis")
kinesis.put_record(StreamName="clicks", Data=json.dumps({"user": "u42", "page": "/cart"}).encode(), PartitionKey="u42")
bash
aws kinesis create-stream --stream-name clicks --stream-mode-details StreamMode=ON_DEMAND
aws firehose create-delivery-stream --delivery-stream-name clicks-to-s3 --delivery-stream-type DirectPut \
--extended-s3-destination-configuration RoleARN=arn:aws:iam::123456789012:role/firehose-role,BucketARN=arn:aws:s3:::acme-lake,Prefix=raw/clicks/dt=!{timestamp:yyyy-MM-dd}/,ErrorOutputPrefix=errors/,BufferingHints={SizeInMBs=64,IntervalInSeconds=120},CompressionFormat=GZIP
S3 Data Lake Layout
text
s3://acme-lake/
├─ raw/ exactly as received (JSON, CSV) keep forever, cheap class
├─ curated/ cleaned, typed, Parquet, partitioned dt=2026-11-17/region=ap-south-1/
└─ analytics/ aggregated tables for dashboards
Rules: use columnar formats (Parquet/ORC), compress (Snappy/ZSTD), partition by common filters (date, region),
aim for files of 128 MB to 1 GB, separate raw from curated, encrypt with KMS, control access with Lake Formatio
AWS Glue
| Part | Purpose |
|---|---|
| Data Catalog | A central metadata store (databases, tables, schemas) used by Athena, Redshift Spectrum, EMR and Glue |
| Crawlers | Scan S3 or databases, infer the schema and create or update catalog tables and partitions |
| ETL jobs | Serverless Apache Spark (or Python shell, Ray) jobs to transform data. Job bookmarks process only new data. Glue Studio visual editor |
| Glue DataBrew | No-code data preparation |
| Glue Data Quality, Workflows, triggers | Quality rules and job orchestration |
python
# Glue ETL job (PySpark): convert raw JSON to partitioned Parquet
import sys
from awsglue.context import GlueContext
from pyspark.context import SparkContext
from pyspark.sql.functions import to_date, col
glue = GlueContext(SparkContext.getOrCreate())
df = glue.create_dynamic_frame.from_catalog(database="lake", table_name="raw_clicks").toDF()
df = df.withColumn("dt", to_date(col("ts"))).dropDuplicates(["event_id"])
df.write.mode("append").partitionBy("dt").parquet("s3://acme-lake/curated/clicks/")
Amazon Athena
- Serverless SQL directly on S3 data. Pay per data scanned (about 5 USD per TB, check current price)
- Uses the Glue Data Catalog. Supports CSV, JSON, Parquet, ORC, Avro and open table formats such as Iceberg
- Cut cost and time: use Parquet/ORC, compression, partitions, and select only needed columns (columnar formats scan less)
- Query logs from ALB, CloudTrail, VPC Flow Logs, S3 access logs very easily
- Federated queries reach RDS, DynamoDB, Redshift and others using Lambda connectors
- Use workgroups to set query result locations, cost limits and permissions
sql
CREATE EXTERNAL TABLE IF NOT EXISTS lake.clicks (
event_id string, user_id string, page string, ts timestamp)
PARTITIONED BY (dt date)
STORED AS PARQUET
LOCATION 's3://acme-lake/curated/clicks/';
MSCK REPAIR TABLE lake.clicks;
SELECT page, count(*) AS views
FROM lake.clicks
WHERE dt BETWEEN date '2026-11-01' AND date '2026-11-17'
GROUP BY page ORDER BY views DESC LIMIT 20;
Amazon EMR
- Managed big data clusters: Spark, Hadoop, Hive, Presto/Trino, HBase, Flink. Run on EC2, EKS or EMR Serverless
- Use when you need full control of the frameworks, custom libraries or very large jobs. For simple ETL prefer Glue; for SQL on S3 prefer Athena
- Save money with Spot Instances for task nodes, keep core nodes On-Demand, use transient clusters that stop after the job
- Data stays in S3 (EMRFS) so clusters can be created and destroyed freely
Visualization and Governance
| Service | Purpose |
|---|---|
| Amazon QuickSight | Serverless BI dashboards. SPICE in-memory engine, embedded analytics, ML insights, per-user or capacity pricing |
| AWS Lake Formation | Build and govern a data lake: central permissions at database, table, column and row level, tag-based access, cross-account sharing |
| Amazon OpenSearch Service | Search, log analytics, dashboards (Kibana-style), near real-time |
| Amazon SageMaker | Machine learning on the lake |
| Redshift Spectrum / Redshift | Warehouse analytics combined with S3 data |
| AWS Data Exchange | Subscribe to third-party datasets |
| AWS DMS and zero-ETL | Continuous replication from databases into the lake or Redshift |
Reference Architectures
| Scenario | Pipeline |
|---|---|
| Clickstream dashboard (near real-time) | Web/app → Kinesis Data Streams → Firehose → S3 (Parquet) → Athena → QuickSight; or → OpenSearch for live dashboards |
| Daily batch analytics | Databases → DMS → S3 raw → Glue ETL → S3 curated → Redshift Spectrum / Athena → QuickSight, orchestrated by Step Functions or MWAA (Airflow) |
| IoT telemetry | Devices → IoT Core → Kinesis/Firehose → S3 and Timestream |
| Log analysis | CloudWatch Logs / ALB logs → Firehose → S3 → Athena, or OpenSearch |
| Governed enterprise lake | S3 + Glue Catalog + Lake Formation permissions + Athena/Redshift/EMR consumers |
| Large Spark/ML processing | S3 → EMR (Spot task nodes) → S3 → SageMaker |
Cost and Performance Tips
- Parquet + partitioning + compression often cut Athena cost by 90 percent or more
- Right-size shards or use on-demand mode; avoid one hot partition key
- Use S3 lifecycle on raw data and Intelligent-Tiering for unknown access
- Stop idle EMR/Redshift clusters, or use serverless versions
- Keep small files under control (compact them) because many tiny files slow queries
- Apply least-privilege with Lake Formation and encrypt the lake with KMS
Practice Tasks
- Create a Firehose delivery stream to S3 and send test records with a script
- Run a Glue crawler on the raw bucket, then query the table in Athena
- Convert JSON to Parquet and compare the bytes scanned by the same Athena query
- Calculate shards needed for 5,000 records per second of 1 KB each
- Draw a pipeline for ALB logs to a QuickSight dashboard
Conclusion
Ingest with Kinesis Data Streams (custom, replay) or Firehose (load to S3, easy), store in an S3 data lake (raw and curated, Parquet, partitioned), catalog and transform with Glue, query with Athena, process big jobs on EMR, visualize with QuickSight and govern with Lake Formation.
Quick Summary: pipeline diagram; KDS vs Firehose + shard math; lake layout; Glue catalog/crawler/ETL; Athena cost tips; EMR spot; QuickSight/Lake Formation/OpenSearch; reference architectures.

