VAYULearn
Colour theme
Investigate a failure
VAYU Learn

AWS Data Engineering

AWS Glue Deep Dive: ETL at Scale Without Managing Servers

DataForge AWS Data Engineering Series - Blog 5 of 20

AWS Data EngineeringSpark & PySpark

The Glue job ran every night for four months. Same code, same data volume, roughly the same runtime — until one night it ran twice as long and processed twice the data it should have.

Nobody had changed the job. Nobody had changed the source data pipeline. The data engineer checked the obvious things first — cluster size, DPU allocation, source file count — all normal. The actual cause: the job bookmark, the mechanism Glue uses to track which files it already processed, had silently reset. The job reprocessed four months of historical data alongside the new day’s data, doubling every downstream table and requiring a full day of cleanup to identify and remove the duplicates.

This is the Glue story that catches almost every team that relies on it for incremental processing: bookmarks feel automatic until the moment they aren’t, and when they fail, they fail silently — the job succeeds, the data is just wrong.

Glue is AWS’s flagship serverless ETL service, and it’s the compute service most data engineering teams reach for first. Understanding how it actually works under the hood — not just how to click through the console to create a job — is what separates teams that trust their Glue pipelines from teams that quietly reprocess data they didn’t mean to.

Let’s go deep.


TL;DR

AWS Glue is serverless Apache Spark — you write a script, AWS provisions the compute (measured in DPUs), runs your job, and tears the infrastructure down when it’s done. The convenience comes with specific mechanisms you need to understand precisely: job bookmarks for incremental processing, DynamicFrames vs standard Spark DataFrames, the DPU cost model, and connection configuration for reaching resources outside AWS’s managed network. Getting these wrong doesn’t crash your job — it produces jobs that “succeed” while quietly reprocessing data, missing new data, or costing far more than the workload requires.

By the end of this article you’ll be able to:

  • Explain exactly how job bookmarks track processed files and the specific conditions that reset them
  • Choose correctly between DynamicFrames and DataFrames for a given transformation
  • Calculate real Glue job costs using the DPU model and identify where costs run away
  • Configure Glue Connections correctly to reach VPC resources, building on Blog 4’s networking foundation

Series context: This is the first deep dive into the compute layer introduced in Blog 1. Blog 7 will cover exactly when Glue is the right choice versus EMR or Athena — this article assumes you’ve already decided Glue is appropriate and need to run it correctly.

Job bookmarks track what’s already processed - until a renamed variable, a deleted job, or a partition change silently resets them. Four conditions, zero errors, one outcome: the job says SUCCESS while quietly reprocessing or skipping data.

What Glue Actually Is

Glue is managed Apache Spark with AWS-specific extensions layered on top. When you submit a Glue job, AWS provisions a Spark cluster behind the scenes, runs your script on it, and terminates the cluster when the job completes. You never see the cluster, never SSH into a node, never configure Spark’s cluster manager directly.

What you write:
A Python or Scala script using either:
- PySpark (standard Spark DataFrame API)
- Glue's DynamicFrame API (Glue-specific abstraction)
What AWS provisions:
A Spark cluster sized according to your DPU configuration
Started fresh for each job run
Terminated when the job completes
What you're billed for:
DPU-hours consumed during the job's actual runtime,
plus a fixed startup allocation (historically ~10 minutes
minimum billing, reduced in newer Glue versions)

The core trade-off, stated precisely: Glue removes cluster management at the cost of some Spark configuration control and predictable cold-start latency. This trade-off is correct for the majority of periodic ETL workloads and wrong for workloads that need fine-grained Spark tuning or run continuously.


DPUs: The Billing Unit That Determines Everything

A DPU (Data Processing Unit) is Glue’s unit of compute capacity — roughly equivalent to 4 vCPUs and 16GB of memory. Every cost calculation, every performance decision, starts with understanding what a DPU actually buys you.

Glue job configuration:
Worker type: G.1X, G.2X, G.4X, or G.8X
Number of workers: how many DPU-equivalent workers to provision
G.1X:  1 DPU per worker  (4 vCPU, 16GB)  — general purpose
G.2X: 2 DPU per worker (8 vCPU, 32GB) — memory-intensive jobs
G.4X: 4 DPU per worker (16 vCPU, 64GB) — very memory-intensive
G.8X: 8 DPU per worker (32 vCPU, 128GB) — largest single-node jobs
Pricing (approximate, varies by region):
~$0.44 per DPU-hour
Example: 10 workers, G.1X, running for 30 minutes
10 DPU x 0.5 hours x $0.44/DPU-hour = $2.20 per run

The DPU sizing decision that most teams get wrong: defaulting to more workers instead of considering worker type. A job that’s memory-bound (large shuffles, wide transformations, big broadcast joins) often runs faster and cheaper on fewer G.2X workers than on more G.1X workers, because the memory-bound operations were spilling to disk on the smaller worker type — the same disk spill diagnostic pattern covered in the Databricks series’ Spark tuning article applies directly here.


How Job Bookmarks Actually Work: The Mechanism

This is the mechanism worth understanding precisely, because the opening scenario’s silent data duplication traces directly back to a gap in this understanding.

Job bookmarks are Glue’s mechanism for tracking which source data has already been processed, enabling incremental runs that only process new data.

First run of a job with bookmarks enabled:
Source: s3://bucket/raw/events/
Files present: file_001.json through file_500.json
Job processes: all 500 files
Bookmark state saved: {last_processed: file_500,
timestamp: run_1_completion_time,
transformation_context: "read_from_s3"}
Second run (new files arrived):
Source: s3://bucket/raw/events/
Files present: file_001.json through file_650.json
(500 old + 150 new)
Job checks bookmark state
Job processes: ONLY file_501.json through file_650.json
Bookmark state updated: {last_processed: file_650, ...}

What actually resets a bookmark - the conditions that produce the opening scenario:

Condition 1: Job definition is deleted and recreated
Bookmarks are tied to the JOB NAME and the specific
transformation_ctx string used in the code. A new job
with the same name but a different transformation_ctx
parameter starts with no bookmark history.
Condition 2: transformation_ctx string is changed in the code
glueContext.create_dynamic_frame.from_catalog(
database="db", table_name="tbl",
transformation_ctx="read_events" <- this string
)
Changing "read_events" to "read_events_v2" during a
code refactor silently creates a NEW bookmark state,
disconnected from history.
Condition 3: --job-bookmark-option is explicitly reset
Running the job with job-bookmark-disable or
job-bookmark-pause (without a resume) skips bookmark
tracking for that run, and depending on configuration,
can affect subsequent runs' starting state.
Condition 4: Source partitioning changes in a way Glue's
bookmark mechanism doesn't recognize as a continuation
A restructured S3 prefix pattern can appear as an
entirely new source to the bookmark system.

The critical operational fact: none of these conditions produce an error. The job runs successfully every time — it just processes a different set of files than intended, either reprocessing everything (duplicates, the opening scenario) or skipping data it should have caught (silent gaps, the more dangerous variant because it produces missing data with no signal at all).

# Correct bookmark-aware read pattern
datasource = glueContext.create_dynamic_frame.from_catalog(
database="raw_db",
table_name="events",
transformation_ctx="datasource_events_read" # NEVER change
# this string
# without a
# deliberate
# bookmark reset
)

DynamicFrames vs DataFrames: The Choice That Adds or Removes Complexity

Glue offers two ways to work with data: its own DynamicFrame abstraction, or standard Spark DataFrames. This choice affects every line of transformation code you write.

DynamicFrame:
Glue-specific abstraction built on top of Spark
Schema is inferred per-record, not enforced upfront
Handles semi-structured, messy, schema-inconsistent data
Provides Glue-specific transforms: ResolveChoice,
Relationalize, ApplyMapping
Slightly slower than native DataFrames for well-structured data
DataFrame (standard PySpark):
Standard Spark API, portable to any Spark environment
Schema is defined or inferred once, upfront
Better performance for structured, consistent data
Full access to standard Spark/PySpark ecosystem
No Glue-specific dependency lock-in
Conversion is trivial and common:
dynamic_frame.toDF() # DynamicFrame -> DataFrame
DynamicFrame.fromDF(df, ...) # DataFrame -> DynamicFrame

The practical pattern most production Glue jobs use: read with DynamicFrame (to handle schema inconsistency in raw Bronze data gracefully), convert to DataFrame immediately for the actual transformation logic (better performance, standard Spark patterns, easier to test), convert back to DynamicFrame only if writing to a target that specifically benefits from Glue’s write-side handling (like automatic partition management for certain catalog-integrated writes).

# The common production pattern
dyf = glueContext.create_dynamic_frame.from_catalog(
database="raw_db", table_name="events",
transformation_ctx="datasource_read"
)

df = dyf.toDF() # convert to standard DataFrame

# Standard PySpark transformation logic here —
# same patterns covered in the Databricks series
df_transformed = df.filter(col("event_type").isNotNull()) \
.withColumn("event_date",
to_date(col("event_ts")))

# Convert back only if needed for the write step
dyf_out = DynamicFrame.fromDF(df_transformed, glueContext,
"dyf_out")

glueContext.write_dynamic_frame.from_options(
frame=dyf_out,
connection_type="s3",
connection_options={"path": "s3://bucket/silver/events/"},
format="parquet"
)

Where DynamicFrames earn their complexity: ResolveChoice specifically handles the case where a column's type varies across records in raw JSON (a revenue field that's sometimes an integer, sometimes a string, sometimes null) — a common Bronze-layer reality that standard DataFrame schema inference handles less gracefully.


Glue Connections: Reaching Beyond S3

Glue jobs default to reaching S3 and other AWS services directly. Reaching anything inside a VPC — an RDS database, an on-premises system via VPN — requires a Glue Connection, which builds directly on the networking concepts from Blog 4.

Glue Connection configuration:
Connection type: JDBC, Network, Kafka, MongoDB, etc.
VPC: which VPC to bridge into
Subnet: which subnet (must have route to the target)
Security groups: must allow the connection's traffic
What happens when a job uses a VPC connection:
Glue provisions Elastic Network Interfaces (ENIs) in
your specified subnet
These ENIs give the Glue job's Spark executors a
presence inside your VPC
Traffic from Glue to your VPC resources flows through
these ENIs, subject to the same security group and
route table rules covered in Blog 4

The specific Glue connection trap: if the subnet specified in the connection has no route to the target (missing NAT Gateway, missing VPC endpoint, missing VPN route — exactly the failure modes from Blog 4), the job doesn’t fail immediately. It hangs until the connection timeout is reached, then fails with a generic connection error that gives no indication the root cause is networking rather than credentials or Glue configuration.

# JDBC connection through a Glue Connection
df = glueContext.create_dynamic_frame.from_options(
connection_type="postgresql",
connection_options={
"url": "jdbc:postgresql://db-host:5432/mydb",
"dbtable": "public.orders",
"user": secret_user,
"password": secret_password,
"connectionName": "my-vpc-connection" # references
# the Glue
# Connection
# object
},
transformation_ctx="jdbc_read_orders"
)

Glue Crawlers: Automated Catalog Registration

Crawlers scan data in S3 (or other sources) and automatically populate the Glue Data Catalog with table definitions — schema, partition structure, file format.

What a crawler does:
Scans a specified S3 path (or JDBC source)
Infers schema from a sample of files
Detects partition structure from the key hierarchy
Creates or updates a table in the Glue Data Catalog
Crawler cost:
~$0.44 per DPU-hour, prorated to actual runtime
Minimum billing increments apply

The crawler frequency trap covered briefly in Blog 1, worth detailing here: running crawlers on a fixed schedule (“every hour, to keep the catalog fresh”) costs money continuously regardless of whether new data actually arrived. The efficient pattern triggers crawlers only when needed — via EventBridge on S3 object creation events, or by skipping crawlers entirely for pipelines where the schema is known and stable, using explicit CREATE TABLE DDL or Glue API calls instead.

Inefficient pattern:
Crawler scheduled hourly, 24 runs/day
Cost: 24 x crawler runtime x DPU rate, every day,
whether or not new data arrived
Efficient pattern:
S3 PutObject event -> EventBridge rule -> triggers
crawler only when new files actually land
Cost: proportional to actual data arrival frequency

What crawlers get wrong that requires manual correction: schema inference from a sample can misjudge column types when early files in the sample don’t represent the full data variety — a numeric column that’s NULL in the sampled files gets inferred as string instead of the correct numeric type. Production pipelines often need either a larger crawler sample size configuration or an explicit schema override applied after crawler runs.


Glue Workflows and Triggers: Orchestration Within Glue

Before reaching for Step Functions (Blog 11), Glue itself provides basic orchestration through Workflows and Triggers — useful for pipelines that stay entirely within Glue’s ecosystem.

Glue Workflow components:
Triggers: schedule-based, on-demand, or event-based
(job completion triggering the next job)
Jobs: the actual ETL steps
Crawlers: catalog registration steps
Simple workflow example:
Trigger 1 (scheduled) -> Crawler (scan raw data)
-> Job A (bronze to silver)
Trigger 2 (job completion) -> Job B (silver to gold)
-> Crawler (catalog gold table)

When Glue Workflows are sufficient vs when you need Step Functions: Glue Workflows handle linear-to-moderately-branched pipelines that only involve Glue jobs and crawlers. They don’t provide the conditional branching, error handling granularity, or cross-service orchestration (invoking Lambda, Redshift, SNS notifications) that Step Functions provides. A pipeline that’s “Glue job A, then Glue job B, then done” is fine in a Workflow. A pipeline that needs “if data quality check fails, send an alert and stop; otherwise continue” needs Step Functions.


Architecture Flow: A Complete Glue Pipeline

S3 Bronze Layer
|
| EventBridge detects new file
v
Crawler triggered (only on new data)
|
v
Glue Data Catalog updated
|
v
Glue Job triggered
|
+-- Read: DynamicFrame from Catalog
| (transformation_ctx: NEVER changed
| without deliberate bookmark reset)
|
+-- Bookmark check: only new files since
| last successful run
|
+-- Convert to DataFrame for transformation
|
+-- Transform: standard PySpark logic
|
+-- Connection (if needed): VPC-routed access
| to RDS/on-prem, subject to
| Blog 4's networking rules
|
+-- Write: Parquet, partitioned, to S3 Silver
(Blog 2'
s file layout principles apply)
|
v
Bookmark state updated on success
|
v
S3 Silver Layer

Failure Modes You’ll See in Production

Job bookmark silently reset by a code refactor. The opening scenario. A developer renames a variable during cleanup, which happens to change the transformation_ctx string passed to the bookmark-tracked read operation. The job runs successfully, reprocesses months of historical data, and duplicates every downstream table — with no error anywhere in the process.

Job bookmark silently skipping data instead of duplicating it. The inverse and more dangerous failure. A bookmark state points to a “last processed” marker that’s ahead of where it should be — caused by a failed run that still updated bookmark state before erroring, or a manual bookmark reset that overshot. New data that should have been processed is silently skipped. Nothing errors. The Gold table is just missing data, and nobody notices until a downstream consumer asks why numbers look low.

DPU over-provisioning for small, frequent jobs. A job processing 500MB of data runs with 20 G.1X workers because that’s what a template configuration used. The job actually needs 2–3 workers. Cost is 7–10x higher than necessary, and because Glue’s minimum billing increment applies per run, this waste compounds across every scheduled execution.

Crawler misinferring schema from a non-representative sample. A crawler samples the first N files in a prefix, all of which happen to have NULL in a numeric column. The column is cataloged as string. Downstream Athena queries that try numeric operations on this column fail or silently produce wrong results through implicit casting, and the root cause traces back to a crawler configuration nobody revisited.

Glue Connection pointing to a subnet with no route (Blog 4’s failure mode, Glue-specific version). A Glue Connection is configured against a subnet that has no NAT Gateway or VPC endpoint. The job doesn’t fail immediately — it hangs for the full connection timeout period (often 10+ minutes) before failing with a generic timeout error that doesn’t indicate the root cause is a missing route, not a Glue misconfiguration.

DynamicFrame ResolveChoice masking a genuine data quality problem. A team uses ResolveChoice with make_type to force a column with mixed types into a single type, silently coercing bad data (a string "N/A" forced into a numeric column becomes null or zero) instead of flagging it for investigation. The transformation "succeeds" while quietly discarding information that should have triggered a data quality alert.


Trade-offs: What Glue Optimizes For

Glue optimizes for:

  • Zero cluster management — no provisioning, patching, or scaling decisions
  • Native integration with the Glue Data Catalog and other AWS services
  • Incremental processing via bookmarks, without building custom watermark tracking
  • Pay-per-job-run pricing with no idle cost between runs

Glue doesn’t optimize for:

  • Cold start latency — every job run pays a startup cost before processing begins
  • Fine-grained Spark configuration control — less tunable than EMR for advanced performance work
  • Debuggability of bookmark state — bookmark issues produce no errors, only silent behavior changes
  • Continuous/streaming workloads — Glue is fundamentally built for periodic batch runs, not always-on processing

The honest trade-off: Glue trades Spark configuration control and cold-start latency for operational simplicity. For the majority of periodic ETL workloads at small-to-moderate scale, this trade favors Glue clearly. At very large scale, or for workloads needing precise Spark tuning, that trade starts favoring EMR — the exact decision Blog 7 covers in depth.


Real-World Constraints

Glue job timeout defaults. Glue jobs have a configurable timeout, defaulting to a long window for Spark jobs in current Glue versions, but teams often set this explicitly lower for cost control. A job that occasionally runs longer than expected (due to unexpected data volume) hits this timeout and fails partway through — worth setting deliberately rather than accepting whatever default your Glue version ships with.

Glue version and Spark version coupling. Each Glue version (2.0, 3.0, 4.0, 5.0) ships with a specific Spark version and specific pre-installed Python library versions. Code written and tested against one Glue version’s Spark/library combination can behave differently — or fail to import dependencies — when the job is later migrated to a newer Glue version. This is the same library conflict category covered in the Databricks series’ troubleshooting article, AWS-specific version.

Maximum concurrent DPU capacity per account. AWS accounts have a default limit on concurrent DPUs across all running Glue jobs, raisable via support request. A data platform running many concurrent Glue jobs during a batch window can hit this limit, causing jobs to queue rather than run immediately — a scaling constraint that only becomes visible once pipeline volume grows past what the account was originally provisioned for.


What This Means for the Rest of the Series

Blog 6 (Redshift): Glue jobs commonly write the S3 data
that Redshift's COPY command loads —
the Parquet output pattern from this
article feeds directly into Blog 6
Blog 7 (Glue vs EMR vs Athena): builds directly on the
DPU cost model and Spark
control trade-offs from
this article
Blog 11 (Step Functions): most Glue jobs in production are
orchestrated by Step Functions,
not run standalone — this article's
jobs are the building blocks Blog 11
assembles into full pipelines

Summary: The Engineering Lesson

Glue’s promise — write a script, let AWS handle the infrastructure — is real and valuable. The cost of that promise is that several mechanisms operating underneath your script (bookmarks, DPU allocation, connection routing) fail silently rather than loudly, and silent failure is the most expensive kind because nobody knows to look for it.

The four-month bookmark reset from the opening scenario cost a full day of cleanup — not because Glue is unreliable, but because bookmark state is invisible until something goes wrong with it, and the job’s “success” status gave no signal that anything had changed.

Understanding a managed service well enough to know where its automation can fail silently is not optional for production use — it’s the entire job.

The mechanisms in this article — bookmark tracking, DPU sizing, DynamicFrame vs DataFrame, connection routing — are what turn “the job ran” into “the job ran correctly, and I know why.”


Next in Series

Blog 6 - Amazon Redshift: The Warehouse That Data Engineers Actually Operate

Glue moves and transforms data. Redshift is where a large share of that data ends up for high-concurrency analytical querying. The decisions that determine Redshift performance — distribution keys, sort keys — are made once at table creation and are expensive to change later, which makes getting them right the first time far more valuable than optimizing after the fact.

We’ll go deep on the internals that determine whether a Redshift query takes 2 seconds or 2 minutes, the COPY command’s relationship to the S3 file layout from Blog 2, and the operational maintenance (vacuum, analyze) that most teams skip until performance degrades.


Comment Below

What’s the most confusing Glue failure you’ve debugged — one where the job reported success but something was still wrong?

Was it a job bookmark reset by an innocent code refactor, silently reprocessing months of data? A crawler that misjudged a column’s type from an unrepresentative sample, breaking downstream queries in a way that looked like an Athena problem? A DPU configuration copied from a template that was ten times larger than the job actually needed?

And - how long before the “successful” job’s actual behavior was discovered?


Tags: aws-data-engineering, aws-glue, etl, pyspark, job-bookmarks, dynamicframe, glue-crawler, spark, dataforge