Pair your devices with a code and playback position follows you: pause on this device, hit resume on the other. Position is saved to the site every minute and on pause.
Open this panel on your other device and enter the same code.
Starts this lesson and continues through 11 more to the end of the course.
Every batch pipeline on this stack is a Glue job, a Spark job on EMR, or a Lambda function. They share the Glue Data Catalog, they land in S3, and they fail differently. The interview question is never "what is Glue" — it's "why Glue over EMR here, and what breaks when you re-run it". That second clause is this lesson.
PySpark itself — lazy evaluation, the Python/JVM boundary, UDFs, skew — is module PS0. This lesson assumes it and does not repeat it.
"Design, develop, and maintain scalable ETL pipelines using AWS Glue, EMR (PySpark), and Lambda functions" plus "optimize PySpark jobs on EMR" and "build serverless data processing workflows using AWS Lambda" is one competency, not three: choose the engine by data volume, runtime, and restart semantics, then make every job safe to re-run. The grader wants to hear you size a Glue worker, explain a bookmark, submit to EMR two different ways, and know the Lambda ceiling without looking it up.
From the Jobs API
(verified 2026-10-30), JobCommand.Name is one of glueetl (Spark ETL), pythonshell,
gluestreaming, or glueray. A DPU is "4 vCPUs of compute capacity and 16 GB of memory".
WorkerType |
DPU | vCPU / memory / disk |
|---|---|---|
G.1X |
1 | 4 vCPU, 16 GB, 94 GB |
G.2X |
2 | 8 vCPU, 32 GB, 138 GB |
G.4X |
4 | 16 vCPU, 64 GB, 256 GB |
G.8X |
8 | 32 vCPU, 128 GB, 512 GB |
G.12X |
12 | 48 vCPU, 192 GB, 768 GB |
G.16X |
16 | 64 vCPU, 256 GB, 1024 GB |
R.1X … R.8X |
1–8 "M-DPU" | memory-optimised: 4 vCPU/32 GB up to 32 vCPU/256 GB |
⚠️ The same page's WorkerType enum lists only Standard | G.1X | G.2X | G.025X | G.4X | G.8X | Z.2X, while its prose lists G.12X, G.16X and the R.* family. The docs are internally
inconsistent — I could not verify from this page whether G.12X/G.16X/R.* are accepted by
CreateJob in every Region. Try it in yours before promising it.
Sizing rules copied from the same page: Python shell jobs take 0.0625 or 1 DPU (default
0.0625); Spark jobs via MaxCapacity take 2–100 DPUs (default 10) with no fractional allocation;
and "For Glue version 2.0 or later jobs, you cannot specify a Maximum capacity. Instead, you should
specify a Worker type and the Number of workers" — never set MaxCapacity together with
WorkerType/NumberOfWorkers. ExecutionClass is STANDARD | FLEX; FLEX needs Glue 3.0+ and
glueetl, and is "appropriate for time-insensitive jobs whose start and completion times may vary".
ExecutionProperty.MaxConcurrentRuns defaults to 1 — a second StartJobRun while one is
running returns ConcurrentRunsExceededException unless you raise it or set JobRunQueuingEnabled.
Timeout: Timeout is in minutes, must be under 10,080 (7 days), and defaults to 2,880 min for
Glue 4.0 and earlier, 480 min for Glue 5.0 and later. Jobs upgraded to 5.0 that used to run
nine hours will now hit TIMEOUT unless you set it explicitly.
From AWS Glue versions (verified 2026-10-30):
| Glue | Spark | Python | Note |
|---|---|---|---|
| 6.0 | 4.1.1 | 3.13 | EMRFS removed, S3A only; AWS SDK v2 only |
| 5.1 | 3.5.6 | 3.11 | default when no version is specified |
| 5.0 | 3.5.4 | 3.11 | DynamicFrame-based Lake Formation table ACL not supported — use Spark-native FGAC |
| 4.0 | 3.3.0 | 3.10 |
From Tracking processed data using job bookmarks
(verified 2026-10-30): bookmarks are "implemented for JDBC data sources, the Relationalize
transform, and some Amazon S3 sources." For S3 sources Glue "check[s] the last modified time of the
objects"; for JDBC it uses the primary key "provided that it is sequentially increasing or
decreasing (with no gaps)". State is read at job.init and "saved atomically when job.commit is
invoked". The job argument is --job-bookmark-option with values job-bookmark-enable,
job-bookmark-disable (the default — "always process the entire dataset"), and
job-bookmark-pause with job-bookmark-from / job-bookmark-to run IDs
(job parameters).
⚠️ Three documented traps, verbatim from the bookmarks page:
datasource0 from
path A to path B without changing transformation_ctx and Glue "will use the old bookmark
state", skipping files in B.Reset with aws glue reset-job-bookmark --job-name my-job-name.
StartJobRun
(verified 2026-10-30) takes JobName (required), Arguments, Timeout, WorkerType,
NumberOfWorkers, JobRunQueuingEnabled, and JobRunId ("The ID of a previous JobRun to retry").
The page warns: "Job arguments may be logged. Do not pass plaintext secrets as arguments."
aws glue start-job-run \
--job-name orders-daily \
--arguments '{"--job-bookmark-option":"job-bookmark-enable","--run_date":"2026-10-30"}'
aws glue get-job-run --job-name orders-daily --run-id jr_0123... \
--query 'JobRun.{State:JobRunState,Secs:ExecutionTime,DPUSecs:DPUSeconds,Err:ErrorMessage,Attempt:Attempt}'
JobRunState values: STARTING | RUNNING | STOPPING | STOPPED | SUCCEEDED | FAILED | TIMEOUT | ERROR | WAITING | EXPIRED. DPUSeconds is your cost line. Documented StartJobRun errors include
ConcurrentRunsExceededException and ResourceNumberLimitExceededException.
"The Data Catalog is a drop-in replacement for the Apache Hive Metastore" and "Each AWS account has one AWS Glue Data Catalog per AWS Region" (components). That one sentence is why Glue, EMR, Athena, and Redshift Spectrum can read the same table definition.
spark-submitFrom Add a Spark step (verified 2026-10-30): "Client mode launches the driver program on the cluster's primary instance, while cluster mode launches your driver program on the cluster." Driver logs land in step logs for client mode and in container logs for cluster mode — that determines where you look first.
aws emr add-steps --cluster-id j-2AXXXXXXGAPLF \
--steps Type=Spark,Name="Spark Program",ActionOnFailure=CONTINUE,\
Args=[--class,org.apache.spark.examples.SparkPi,/usr/lib/spark/examples/jars/spark-examples.jar,10]
For PySpark, Args carries --deploy-mode cluster and the s3:// path to your .py. The
steps page:
"up to 256 PENDING and RUNNING steps in a cluster"; from EMR 7.14.0 the maximum per request is 100
steps; from 5.28.0 you can cancel running steps and run steps in parallel.
Instance fleets
(verified 2026-10-30): "a maximum of five Amazon EC2 instance types per fleet", target capacities
for On-Demand and Spot measured in vCPU or weighted units, Spot allocation strategies
price-capacity optimized, capacity-optimized, capacity-optimized-prioritized, lowest-price, or diversified. Per fleet you set a provisioning timeout with TimeoutAction =
SWITCH_TO_ON_DEMAND or TERMINATE_CLUSTER:
LaunchSpecifications={SpotSpecification='{TimeoutDurationMinutes=120,TimeoutAction=SWITCH_TO_ON_DEMAND}'}
⚠️ "This only applies for provisioning clusters, not resizing them. If the timeout period ends during the cluster resizing process, unprovisioned Spot requests will be nullified without transferring to On-Demand capacity." A fleet that scales up on Spot at 2am and can't get capacity simply stays small.
Managed scaling
(verified 2026-10-30): EMR 5.30.0+ (not 6.0.0); "only works with YARN applications, such as Spark,
Hadoop, Hive, and Flink. It doesn't support … Presto and HBase." Parameters: MinimumCapacityUnits,
MaximumCapacityUnits, optional MaximumOnDemandCapacityUnits (splits On-Demand vs Spot) and
MaximumCoreCapacityUnits (splits core vs task). "You cannot scale the primary node." Keep
spark.dynamicAllocation.enabled on — the page recommends it for scaling to work well.
StartJobRunEMR Serverless
"automatically determines the resources that the application needs … and releases the resources
when the jobs finish"; you can pre-initialize capacity for sub-second starts. The
API
(verified 2026-10-30) requires applicationId, executionRoleArn, and a clientToken
idempotency token (1–64 chars, "must be unique for each request"); mode is BATCH | STREAMING;
executionTimeoutMinutes max is 10,080 for BATCH from EMR 7.11 and "Setting a value of 0 to disable
the timeout is no longer supported". The CLI example from the
Spark jobs page:
aws emr-serverless start-job-run \
--application-id application-id \
--execution-role-arn job-role-arn \
--job-driver '{
"sparkSubmit": {
"entryPoint": "s3://us-east-1.elasticmapreduce/emr-containers/samples/wordcount/scripts/wordcount.py",
"entryPointArguments": ["s3://amzn-s3-demo-destination-bucket/wordcount_output"],
"sparkSubmitParameters": "--conf spark.executor.cores=1 --conf spark.executor.memory=4g --conf spark.driver.cores=1 --conf spark.driver.memory=4g --conf spark.executor.instances=1"
}
}'
From Use the Glue Data Catalog with Spark on EMR
(verified 2026-10-30): EMR 5.8.0+ for Hive metastore, 6.5.0+ for Iceberg, 7.5.0+ as Iceberg REST
catalog; cross-account via hive.metastore.glue.catalogid (EMR 5.16.0+).
[{"Classification": "spark-hive-site",
"Properties": {"hive.metastore.client.factory.class":
"com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory"}}]
Same page: the Catalog stores a million objects free, then "USD$1 for each 100,000 objects over a million" — an object is a table, partition, or database.
From Lambda quotas (verified 2026-10-30). The page says these "can't be changed" except as noted — i.e. not adjustable:
| Resource | Quota |
|---|---|
| Memory | 128 MB – 10,240 MB, 1-MB increments; 1,769 MB ≈ one vCPU |
| Timeout | 900 s (15 min); up to 5,400 s only for Lambda Managed Instances on async/ESM invokes |
/tmp |
512 MB – 10,240 MB |
| Payload | 6 MB request/response (sync); 1 MB (async); 200 MB streamed response |
| Deployment package | 50 MB zipped; 250 MB unzipped incl. layers; container image 10 GB |
| Environment variables | 4 KB aggregate |
| Layers | 5 |
An S3 event carries key + size, not bytes, so the 1 MB async limit never bites on S3 triggers —
the 15-minute wall and 10 GB /tmp do. If one file can't be processed in 15 minutes on 10 GB of
RAM, it is a Glue or EMR job.
S3 notifications: "Amazon S3 invokes
your function asynchronously." ⚠️ "If your Lambda Event Function uses the same bucket that triggers
it, it could cause the function to run in a loop … use two buckets, or configure the trigger to only
apply to a prefix." Retry behaviour:
"Lambda retries function errors twice" for async, and "ensure that your function's code can handle
the same event multiple times without causing duplicate transactions". Key the output on the event's
s3.object.key + eTag, write to a deterministic path, and configure a dead-letter queue.
| Pick | When | Avoid when |
|---|---|---|
| Lambda | Per-object work finishing well inside 15 min; glue code between services | Any job needing a shuffle, >10 GB RAM, or >15 min |
| Glue (Spark) | Serverless Spark with Catalog, bookmarks, crawlers; teams without cluster ops | You need custom Spark/Hadoop versions, non-YARN apps, or long-running shared clusters |
| EMR Serverless | Open-source Spark/Hive without cluster ops; you control spark-submit conf |
You need Spot-specific cost engineering or daemon services on nodes |
| EMR on EC2 | Fleets + Spot + managed scaling, bootstrap actions, Presto/HBase/Flink, persistent clusters | Sporadic small jobs where cluster start time dominates |
A Glue job reads s3://raw/orders/ with job-bookmark-enable and appends Parquet to
s3://curated/orders/. Run 1 processes 90 files. Run 2 fails at minute 40 with a transient S3 500
after writing half its output — job.commit() never ran, so the bookmark is still at run 1. Run 3
reprocesses all of run 2's input and appends again. Now curated/orders holds run 2's partial
output plus run 3's full output: duplicates, with a green SUCCEEDED.
Evidence to gather: get-job-runs showing run 2 FAILED and run 3 SUCCEEDED;
get-job-bookmark --job-name showing the run ID the state advanced from; a SELECT key, COUNT(*) … HAVING COUNT(*) > 1 in Athena. Fix the cause, not the symptom: write to a run-scoped prefix and
promote atomically, or overwrite the affected partitions (partitionOverwriteMode=dynamic), so that
a re-run replaces rather than appends. The bookmark page says this in its own words: Glue "does not
clean the target files". That is your job.
WorkerType=G.2X, NumberOfWorkers=10, and MaxCapacity=20 in CreateJob. What happens?StartJobRun fails with ConcurrentRunsExceededException. Why, and two fixes?StartJobRun field makes the call safe to retry, and what is its constraint?SWITCH_TO_ON_DEMAND save you?ExecutionProperty.MaxConcurrentRuns defaults to 1 and the previous run is still active. Raise
MaxConcurrentRuns, or pass JobRunQueuingEnabled=true so the run queues instead of erroring.clientToken — required, 1–64 chars, pattern [A-Za-z0-9._-]+, unique per logical request.MaximumOnDemandCapacityUnits in managed
scaling to guarantee a floor.get-job-run on a run that hit TIMEOUT after a 5.0 upgrade.