Building Serverless ETL Jobs with AWS Glue
This lesson explains how AWS Glue runs serverless Apache Spark and Python jobs for extract, transform and load (ETL), billed only while jobs run and with no clusters to manage.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish Spark, Spark Streaming and Python shell jobs.
- Use DynamicFrames, job bookmarks and other Glue features.
- Identify supported formats and authoring tools.
- Monitor and troubleshoot Glue jobs.
Job types and workers
AWS Glue runs three types of job. Spark jobs, written in PySpark or Scala, spread large-scale batch ETL across many workers. Spark Streaming jobs read Kinesis or Kafka continuously and process records in small batches. Python shell jobs run a plain Python script on a single small worker, for small tasks such as calling an API or running a SQL statement, where Spark would be wasteful. The following table summarises the job types.
| Job type | Use for |
|---|---|
| Spark (PySpark or Scala) | Large-scale batch ETL |
| Spark Streaming | Reading Kinesis or Kafka continuously |
| Python shell | Small tasks that do not need Spark |
The following list describes the workers on which jobs run and the related cost options.
- Jobs run on workers measured in DPUs: general-purpose G.1X and G.2X, memory-heavy G.4X and G.8X, and small workers for streaming.
- Auto scaling adds and removes workers during a run.
- Flex execution runs non-urgent jobs on spare capacity at a lower price, with possibly longer start times.
- Newer Glue versions (mapping to Spark and Python versions) start faster and perform better.
Which Glue job type?
Key programming features
Several Glue features solve common ETL problems. DynamicFrames are Glue's version of Spark DataFrames that tolerate inconsistent schemas, such as a column that is sometimes a number and sometimes text; resolveChoice decides how to handle such mixed types. Job bookmarks remember which data a job has already processed, so each run handles only new files or rows, which makes incremental processing simple.
Pushdown predicates filter by partition before reading, so a job reads only the partitions it needs. groupFiles combines many small input files into larger groups, which avoids the overhead of processing each tiny file separately. The hashfield and hashpartitions options split a JDBC read across workers, so a large database table is read in parallel. The following table summarises the features.
| Feature | What it does |
|---|---|
| DynamicFrames | Handle inconsistent schemas; resolveChoice fixes mixed types |
| Job bookmarks | Remember what was processed, so each run handles only new data |
| Pushdown predicates | Read only the partitions needed |
| groupFiles | Combine many small input files |
hashfield, hashpartitions | Parallelise JDBC reads |
Glue programming features
Formats and authoring
AWS Glue jobs read and write the common data lake formats, namely CSV, JSON, Parquet, ORC and Avro, and support the open table formats Apache Iceberg, Apache Hudi and Delta Lake, which add upserts, deletes and time travel to lake tables.
Jobs can be authored in several ways. AWS Glue Studio provides a visual editor in which sources, transformations and targets are connected as a diagram, and it generates the job's code, which suits common transformations and teams less familiar with Spark. Developers can instead write scripts directly, or develop interactively in notebooks. Glue connections let jobs reach JDBC databases inside a VPC and software-as-a-service sources.
Formats and authoring
Monitoring and troubleshooting
Glue offers several views into a job: the history of job runs, CloudWatch job metrics, observability metrics that reveal skew and memory pressure across workers, continuous logging while a job runs, and the Spark UI, which shows each stage and task. Three problems account for most failures and slow jobs. Out-of-memory errors mean a worker ran out of memory, fixed with larger or more workers. Data skew means a few workers receive far more data than others, because some key values are very common; repartitioning or salting the key spreads the work. Many small files slow every stage, fixed by compacting them or reading with groupFiles. The following table summarises the fixes.
| Problem | Fix |
|---|---|
| Out-of-memory errors | Larger or more workers |
| Data skew | Repartitioning or salting |
| Many small files | Compaction or groupFiles |
The following diagram shows how run time changes once the job reads only new data.

Fixing Glue jobs
A nightly job that reprocesses everything
A Glue job converting daily CSV files to Parquet takes longer every night, because it reads every file in the bucket, including all previous days.
| Fix | Effect |
|---|---|
| Enable job bookmarks | The job processes only files added since its last successful run |
| Use a push-down predicate on the date partition | Reads only the needed partitions from the catalogue |
| Use Flex execution for this non-urgent job | Lower cost per DPU-hour |
| Enable auto scaling of workers | Uses only the workers each run needs |
Run time drops from hours to minutes and stays flat as data accumulates. If the job ever needs to reprocess history, the bookmark can be reset for that run.
Which Glue feature lowers the cost of jobs that are not urgent?
Show answer
Flex execution, which runs jobs on spare capacity at a lower price, with less predictable start times.
Exam Tips
Remember for the exam
- To process only new data on each run, use job bookmarks.
- For cheaper non-urgent jobs, use Flex execution.
- Out-of-memory errors call for a larger worker type (G.2X or above) or repartitioning.
- To read only the partitions you need, use pushdown predicates.
- With many small input files, use groupFiles or compact them first.
- For upserts and time travel in the lake, use Iceberg, Hudi or Delta Lake with Glue.