With runner-mode docker, GetDashboardForJobRun's link for a Spark run's attempt that has ended now opens a Spark History Server over the run's event logs, and GetResourceDashboard's link does the same for a session that has ended, as "For completed jobs, the application UI is a persistent application user interface such as the Spark History Server" and "After a session ends, the Spark History Server remains available". A run's or session's driver keeps its event logs where the release's image writes them, /var/log/spark/apps, on a Docker volume of its own, for the 30 days EMR Serverless keeps logs in managed storage. The server runs in a container of the release's image that starts as its link is first opened, answering 503 until it is up, and stops once no link to it is valid. A history goes 30 days after its run or session ended, or once it has gone, which Floci checks as it starts and every hour; a restart keeps the histories and a reset removes them. A run whose logs are not kept in managed storage keeps no event logs and still gets Floci's page, as do Hive runs, histories that have gone and every link in the immediate mode.
46 KiB
EMR Serverless
EMR Serverless is an AWS service that provides serverless data analytics environments. Floci provides an emulator for the management-plane API (REST JSON) which covers the lifecycle of an Application, of the job runs submitted to it and of its Spark Connect sessions.
Configuration
| Key | Description | Default |
|---|---|---|
floci.emrserverless.enabled |
Whether the EMR Serverless API is enabled | true |
floci.emrserverless.port |
The port the service is exposed on | 4566 |
floci.services.emrserverless.job-run-duration-seconds |
How long a BATCH job run stays RUNNING before it succeeds; 0 makes it SUCCESS as soon as it starts |
0 |
floci.services.emrserverless.runner-mode |
immediate moves job runs and sessions through their states without running anything; docker runs each job run, and each session's Spark Connect server, in a container (see Running Spark job runs, Running Hive job runs and Running a session's Spark Connect server) |
immediate |
floci.services.emrserverless.docker-network |
Docker network for job run containers | the global default |
floci.services.emrserverless.image-template |
Image for a docker job run whose application names no custom image, %s standing for the release label |
public.ecr.aws/emr-serverless/spark/%s:latest, or spark4/ in place of spark/ for an emr-spark-* release |
floci.services.emrserverless.hive-image-template |
Image for a docker Hive job run whose application names no custom image, %s standing for the release label |
public.ecr.aws/emr-serverless/hive/%s:latest |
floci.services.emrserverless.executor-containers |
How many executors a docker Spark job run may have at once, each in a container of its own (see Executors under Running Spark job runs); 0, the default, runs a run's executors in its driver's container, in Spark's local mode |
0 |
floci.services.emrserverless.honour-architectures |
Run a docker job run's driver and executors for its application's architecture (see Architecture under Running Spark job runs); false runs them on the Docker host's own platform |
false |
floci.services.emrserverless.reconcile-containers-on-startup |
Remove the drivers and executors a previous run of this Floci left on the Docker daemon before the first job run starts; turn it off when two Floci instances share a daemon with the same port and no resource namespace | true |
Endpoints
The emulator implements the standard AWS emr-serverless service endpoints:
POST /applications(CreateApplication)GET /applications(ListApplications)GET /applications/{applicationId}(GetApplication)PATCH /applications/{applicationId}(UpdateApplication)DELETE /applications/{applicationId}(DeleteApplication)POST /applications/{applicationId}/start(StartApplication)POST /applications/{applicationId}/stop(StopApplication)POST /applications/{applicationId}/jobruns(StartJobRun)GET /applications/{applicationId}/jobruns(ListJobRuns)GET /applications/{applicationId}/jobruns/{jobRunId}(GetJobRun)DELETE /applications/{applicationId}/jobruns/{jobRunId}(CancelJobRun)GET /applications/{applicationId}/jobruns/{jobRunId}/attempts(ListJobRunAttempts)GET /applications/{applicationId}/jobruns/{jobRunId}/dashboard(GetDashboardForJobRun)POST /applications/{applicationId}/sessions(StartSession)GET /applications/{applicationId}/sessions(ListSessions)GET /applications/{applicationId}/sessions/{sessionId}(GetSession)DELETE /applications/{applicationId}/sessions/{sessionId}(TerminateSession)GET /applications/{applicationId}/sessions/{sessionId}/endpoint(GetSessionEndpoint)GET /applications/{applicationId}/dashboard(GetResourceDashboard)POST /tags/{resourceArn}(TagResource)DELETE /tags/{resourceArn}?tagKeys=...(UntagResource)GET /tags/{resourceArn}(ListTagsForResource)
The tagging operations work on application, job run and session ARNs, as CreateApplication, StartJobRun and
StartSession return them (arn:aws:emr-serverless:<region>:<account>:/applications/<id>,
.../applications/<id>/jobruns/<id> and .../applications/<id>/sessions/<id>). They share the tags those calls
store, so GetApplication, GetJobRun and GetSession always report the current set. Following the EMR Serverless
user guide, a resource holds at most 50 tags, and aws: in any case is reserved as the prefix of a tag key or value.
Once an application is deleted, its ARN and its runs' and sessions' ARNs answer ResourceNotFoundException too,
while GetApplication, GetJobRun and GetSession still report them.
Applications, job runs, sessions, creation client tokens, and tags are scoped to the request's AWS Region. An application, run or session created in one Region is not returned by list, get, or tag requests signed for another.
ListApplications refuses a states filter naming a state that does not exist, or more than 7, and a
maxResults outside 1 to 50, with the ValidationException AWS's validation layer answers.
CreateApplication stores every configuration UpdateApplication does, runtimeConfiguration,
monitoringConfiguration, schedulerConfiguration, diskEncryptionConfiguration,
interactiveConfiguration, identityCenterConfiguration and jobLevelCostAllocationConfiguration
among them, and GetApplication returns each as it was written.
UpdateApplication answers with the updated application, as GetApplication reports it.
UpdateApplication changes any setting of a CREATED or STOPPED application, and of a STARTED one its
maximumCapacity and its custom images, imageConfiguration and workerTypeSpecifications, as the user guide's
"Updating Running Applications" describes. For every other setting the API reference's "An application has to be in
a stopped or created state in order to be updated" holds: a STARTED application's update naming one, even beside
those or with its current value, is refused with ValidationException, "Application must be in a stopped or created
state in order to be updated.", and so is an image change on an application with initialCapacity ("Custom image
updates on running applications are not supported on applications with pre-initialized capacity configured"). A run
already going keeps the image and the maximum capacity it was launched with, and a new run, or a new attempt of a
run, takes the application's current ones: "New workloads submitted after the update automatically will use the new
image, while existing workloads continue with the original image". On a release up to 7.13 whose
applicationLevelDigestResolution is left true, or any whose image configuration sets it true, "Custom images are
resolved to a digest at application start; that digest is used for all jobs until the application restarts": a new
run keeps the image the application resolved as it started (see Image under job runs) until it starts again,
unless the update turns that image configuration's applicationLevelDigestResolution to false, after which each run
resolves the image it is given.
DeleteApplication leaves the application in TERMINATED state. GetApplication continues to
report that state so lifecycle waiters can observe it, while an unfiltered ListApplications
omits the terminated application. A terminated application cannot be started or stopped again.
Job runs
In the default immediate runner mode, job runs are metadata only: nothing executes. A run follows
the job run states and GetJobRun's response shape, and settles when it is read. In the docker
runner mode a Spark run executes; see Running Spark job runs.
-
Lifecycle: a run is
RUNNINGfrom the moment it is submitted. With the defaultjob-run-duration-secondsof0, aBATCHrun isSUCCESSas soon as it starts; a positive duration keeps itRUNNINGthat long. A run whose duration would pass itsexecutionTimeoutMinutes(720 when not given, as AWS reports it) isCANCELLEDat the timeout. ASTREAMINGrun staysRUNNINGuntil it is cancelled. -
Auto-start: a run submitted to a
CREATEDorSTOPPEDapplication starts the application, asautoStartConfiguration.enableddefaults totrue. With auto-start turned off, the run is refused withValidationExceptionuntil the application is started. A run on a terminated application is refused. -
Idempotency:
clientTokenis the idempotency token. Repeating a request with the same token returns the original run; reusing the token with a different request answersConflictException(HTTP 409) "Request did not match the original". The two are compared as the run each would start holds them:executionTimeoutMinutesleft out or 720, andtagsleft out or empty, count as the same; a member the run would hold otherwise, such as amodegiven where the original left it out, or a tag with an empty value, does not. -
Execution timeout:
executionTimeoutMinutesis 0 to 1,000,000, 0 meaning no timeout. From releaseemr-7.11.0, aBATCHrun's timeout must be 1 to 10080 minutes (7 days), as the model and the 7.11.0 release notes say; a run outside that is refused withValidationException. The AWS runtime for Apache Spark's releases,emr-spark-8.0.0on, hold theirBATCHruns to it too: the notes apply it "from this release onwards", and the release list puts them after EMR Serverless 7.14.0. -
CancelJobRun moves a run that has not finished to
CANCELLED. A finished run answersValidationException"Job run is not in a cancellable state". -
StopApplication refuses an application with a run that has not finished, a
STREAMINGrun or aCANCELLINGone included, as the API reference says "All scheduled and running jobs must be completed or cancelled before stopping an application." It answersValidationException, the one error the model declares for this, with that sentence as its message: AWS's own message is not recorded, so the wording is Floci's reading. It terminates the application's sessions (see Sessions). -
ListJobRuns returns the newest runs first, the later of two started within the same millisecond first too, filtered by
states,createdAtAfter,createdAtBeforeandmode, at most 50 per page. With severalstates, the runs are grouped by state in the order the filter names them. A state or mode that does not exist, or more than 8 states, is refused withValidationException. An unknown application has no runs. AnextTokenresumes only the listing it came from, with the same application and filters. -
Attempts: a run starts as attempt 1, and in the
immediatemode, where none fails, it stays its only one. In thedockermode a run whose driver fails is tried again on release 7.1.0 or later, as the user guide's "Job resiliency" gives it: aBATCHrun until it has maderetryPolicy.maxAttemptsattempts (1 by default, no retry), and aSTREAMINGrun until it has failedmaxFailedAttemptsPerHourtimes within an hour (5 by default). Either outside 1 to 10, the user guide's "Accepted values", is refused withValidationException, and either not an integer withSerializationException. Each new attempt isSCHEDULEDagain and runs its driver from the beginning; a cancelled run, one past its timeout, and one Floci's own shutdown stopped are not tried again.GetJobRunwithoutattemptreturns the latest attempt, withattemptan earlier one as it ended (FAILED, with itsstateDetails), and an attempt the run never made answersResourceNotFoundException; one below 1 or not an integer isValidationException.ListJobRunAttemptslists every attempt, oldest first, each with its own creation and update times. No source says whether a run's timeout spans its attempts; Floci applies it to each. -
createdByis the caller's ARN, asGetCallerIdentityreports it.releaseLabelandnetworkConfigurationcome from the application. -
Dashboard:
GetDashboardForJobRungives "a URL that you can use to access the application UIs for a job run", for the latest attempt or theattemptasked for, checked asGetJobRunchecks it, and, as AWS's, "The URL is valid for one hour after you generate it". "For jobs in a running state, the application UI is a live user interface such as the Spark or Tez web UI. For completed jobs, the application UI is a persistent application user interface such as the Spark History Server or persistent Tez UI." Withrunner-modeset todocker, a Spark run's link opens both for real, through Floci, each on a host of its own,http://<secret>-<port>.emr-serverless-ui.<Floci's host and port>/, the secret 26 random letters and digits that only this link holds, so the host itself is the link's authority, as the UI takes no AWS credentials. Floci's host must resolve its subdomains:localhostandlocalhost.floci.iodo, and Floci's TLS certificate names*.emr-serverless-ui.localhostand*.emr-serverless-ui.localhost.floci.io. A link's host answers with a403page once its hour has passed, or when it was given before Floci restarted.- While the attempt runs, the link, on port 4040, opens its driver's Spark UI: port 4040 of its container, which
Docker publishes on the host's loopback interface alone, or which Floci, in a container on the same network,
reaches there. The release's image turns the UI off; Floci turns it on before the run's own settings, so a run
that turns it off again has none. Until the driver runs, and then until its Spark has started the UI, or for good
where the run turned it off, the host answers with a
503page asking to try again, and once the attempt has ended, with a404one. - Once the attempt has ended, the link, on port 18080, opens a Spark History Server over the run's event logs,
for the 30 days EMR Serverless keeps them: "By default, EMR Serverless stores application logs securely in Amazon
EMR managed storage for a maximum of 30 days". The run's driver writes its event logs where the release's image
says (
spark.eventLog.dir,file:///var/log/spark/apps), on a Docker volume of the run's own, every attempt's there, and the server runs in a container of the release's image that starts as its link is first opened, the host answering with a503page until it answers, and stops once no link to it is valid. The server lists the run's applications, one per attempt, rather than opening the attempt's. A history goes 30 days after its run ended, or once its run has gone, which Floci checks as it starts and every hour; a restart keeps the histories, and a reset removes them all. Each history and its server carry the owner label of the Floci that keeps them, so another Floci sharing the Docker daemon leaves them alone. Where Docker cannot tell whether a history is kept, its host answers with the503page too, rather than taking the history for gone. - Otherwise, the link opens a page Floci serves at
/_aws/emr-serverless/dashboardon its own address (base-url, orhostname): for a run whose logs are not kept in managed storage, itsmanagedPersistenceMonitoringConfiguration, or else its application's, withenabledfalse, as with logs in S3 alone the application UI is "Not supported" ("Otherwise, you can't use the built-in application UIs"), so Floci keeps none of its event logs; for a run that turns its event logs off (spark.eventLog.enabled) or sends them elsewhere (spark.eventLog.dir), as nothing is kept for a history server to read; for a Hive run, as Floci runs no Tez UI; once a history has gone; and in theimmediatemode. The page shows the attempt's state, its times, where its driver's logs go in S3 and in CloudWatch Logs, and whether they are kept in managed storage, kept as the attempt was admitted, so a later change to the application's monitoring configuration does not move them. Its link names the run and is signed with a key Floci makes as it starts: one changed, or past its hour, or given before Floci restarted, opens a403page asking for a new one, and one whose run has gone a404.
Like the rest of Floci, no link asks for credentials. AWS's link, by a user's report, opens a limited number of times ("This URL has already been used the maximum number of times. Please generate a new URL."); Floci's open as often as asked within their hour.
accessSystemProfileLogs, for jobs on Lake Formation, changes nothing. - While the attempt runs, the link, on port 4040, opens its driver's Spark UI: port 4040 of its container, which
Docker publishes on the host's loopback interface alone, or which Floci, in a container on the same network,
reaches there. The release's image turns the UI off; Floci turns it on before the run's own settings, so a run
that turns it off again has none. Until the driver runs, and then until its Spark has started the UI, or for good
where the run turned it off, the host answers with a
Sessions
A session is "a managed connection between your local PySpark client and a Spark driver running on Amazon EMR
Serverless", through Spark Connect. With runner-mode set to docker, Floci runs that driver, a Spark Connect server,
in a container, and a client reaches it through Floci (see Running a session's Spark
Connect server). With the default immediate mode, Floci keeps a session
and its lifecycle but runs no driver for it.
- Starting:
StartSessionneeds a Spark application onemr-7.13.0or later, or on the AWS runtime for Apache Spark (emr-spark-8.0.0on), whoseinteractiveConfiguration.sessionEnabledistrue. As for a job run, aCREATEDorSTOPPEDapplication is started unless its auto-start is off, when the session is refused, and so is one on a terminated application. Each of these refusals isValidationExceptionin Floci's own wording, as AWS's is not recorded.clientTokenis the idempotency token, compared as for a job run:idleTimeoutMinutesleft out or 60,tagsleft out or empty, andconfigurationOverrideswithout aruntimeConfigurationcount as the same. An application holds at most 25 sessions that have not ended, as "Each EMR Serverless application supports up to 25 concurrent sessions by default"; a 26th is refused withServiceQuotaExceededException(HTTP 402). OfconfigurationOverrides, onlyruntimeConfigurationis kept: "Only runtime configuration overrides are supported." AruntimeConfigurationwith a member of the wrong JSON type is refused withSerializationException, and a configuration without itsclassificationwithValidationException.releaseLabelandnetworkConfigurationcome from the application, andcreatedByis the caller's ARN. - States: in the
immediatemode a session isIDLEas soon as it starts, withstartedAtandidleSinceset; in thedockermode it goes throughSUBMITTED,STARTINGandIDLE, thenBUSYand back (see below). It isTERMINATEDonce it has been idle for itsidleTimeoutMinutes(0 to 1,000,000, 60 when not given, as "Default timeout is set to 1 hour"), or once 24 hours have passed since it started, as "Each session has a hard limit of 24 hours by default", whichever comes first. No source says what an idle timeout of0does; Floci reads it as no idle timeout, as for a job run'sexecutionTimeoutMinutes. Floci never reportsSTARTED. - TerminateSession ends a session with no server at once as
TERMINATED; one whose server runs isTERMINATINGuntil its container has stopped, as "After you terminate a session, it enters the TERMINATING state and then the TERMINATED state". A session that has already ended is refused withValidationException, in Floci's own wording. - StopApplication terminates the application's sessions that have not ended, with
stateDetailssaying so. The API reference requires a stopping application's job runs to have ended but names no such requirement for sessions, and once an application is stopped "no resources are running on the application"; AWS's own handling is not recorded. - GetSessionEndpoint answers for a session that has not ended with Floci's own address as its endpoint, such as
http://localhost:4566, and a fresh authentication token that expires in an hour, as "Authentication tokens are time-limited to 1 hour". AWS's endpoint is anhttps://URL without a port; a Spark Connect URL holds no path, so Floci's is its address alone, port included, and the token names the session. A session that has ended, or isTERMINATING, is refused withValidationException, in Floci's own wording. - ListSessions returns the newest sessions first, as
ListJobRunsorders runs, filtered bystates,createdAtAfterandcreatedAtBefore, at most 50 per page, grouped by state asListJobRunsgroups runs. - GetResourceDashboard takes a
resourceTypeofSESSION, the only one, and gives a link likeGetDashboardForJobRun's, valid for an hour: "While a session is active, the URL opens the live Apache Spark UI", and "After a session ends, the Spark History Server remains available". Withrunner-modeset todocker, a link given before the session has ended, or begun to, opens its Spark Connect server's Spark UI, and one given after, for 30 days, a Spark History Server over its kept event logs, as a run's link opens its driver's (see Running a session's Spark Connect server); any other, one given while the session isTERMINATINGamong them, opens a page about the session on Floci's address.accessSystemProfileLogschanges nothing.
A state machine drives applications and job runs through the emr-serverless: integrations, .sync
included; see Step Functions: Amazon EMR Serverless tasks.
Running a session's Spark Connect server
With runner-mode set to docker, each session runs a Spark Connect server in a container, as a job run's driver runs:
in the release's image, or the application's custom image, on the same Docker network, with the execution role's
credentials, and with its executors in containers of their own when executor-containers is above 0. Its
spark-defaults are the application's runtime configuration, then the session's runtimeConfiguration, merged as a
job run's applicationConfiguration is. Floci sets spark.connect.grpc.binding.port itself and drops a
spark.connect.grpc.binding.address, as that setting "is reserved by EMR Serverless and cannot be overridden by users".
The server's port is published on the Docker host's loopback interface only, and clients reach it through Floci.
-
Connecting: build the connection string from
GetSessionEndpoint's answer as AWS's guide does, with the token in thex-aws-proxy-authparameter, but keep the endpoint's port:endpoint = emr.get_session_endpoint(applicationId=app_id, sessionId=session_id) scheme, address = endpoint["endpoint"].split("://", 1) # http, localhost:4566 tls = ";use_ssl=true" if scheme == "https" else "" spark = SparkSession.builder.remote( f"sc://{address}/{tls};x-aws-proxy-auth={endpoint['authToken']}").getOrCreate()Floci serves plain HTTP unless its TLS is on, so
use_ssl=truegoes only with anhttps://endpoint, and then the client has to trust Floci's CA (GRPC_DEFAULT_SSL_ROOTS_FILE_PATHfor PySpark). The endpoint isfloci.base-url, as every URL Floci hands out is, so where Floci is reached through another port, as a container's mapped port, setfloci.base-urlto that address. As AWS says, the client's PySpark must match the release's Spark (3.5.6 foremr-7.13.0). -
Tokens: a call whose token Floci did not give, or which has expired, fails with gRPC's
UNAUTHENTICATED, as "When a token expires, gRPC calls fail with an authentication error". A call to a session that is notIDLEorBUSY, or, in theimmediatemode, to any session, fails withUNAVAILABLE, in Floci's own wording. -
States: a session is
SUBMITTEDuntil its container runs,STARTINGuntil the server answers, thenIDLE, withstartedAtandidleSinceset. No source says when a session isBUSY: Floci makes itBUSYwhile a call runs on its server, andIDLEagain once none does, its idle timeout counting from then. A server that does not answer within 10 minutes, or stops on its own, fails its session withstateDetailssaying so (why it did not answer, or its exit code); one Floci stopped running when it restarted fails too, and its container, if one is left, goes. The 24 hours count from when the server answers. -
Logs: no source gives where a session's driver logs go, so Floci sends the server's output to its own log only, not to the application's monitoring configuration.
-
Spark UI:
GetResourceDashboard's link opens the server's Spark UI on a host of its own, as a run's link opens its driver's (see Dashboard under job runs): port 4040 of the server's container, published on the host's loopback interface alone. Its host answers with a503page until the server's container runs, and with a404one once the session has ended. The server keeps its event logs on a volume of the session's own, so once the session has ended a new link opens a Spark History Server over them, for 30 days, as a run's does.
Running Spark job runs
With runner-mode set to docker (FLOCI_SERVICES_EMRSERVERLESS_RUNNER_MODE=docker), a Spark job
run executes. Floci starts one container per run from the application's custom image, if it names one
(see Image below), or else from the release's image, the base image AWS publishes for customizing
EMR Serverless images (public.ecr.aws/emr-serverless/spark/<release>, and spark4/<release> for the
AWS runtime for Apache Spark releases, emr-spark-8.0.0 on), and runs
spark-submit in it, in Spark's local mode by default: the container holds the driver and its executors.
With executor-containers above 0, each executor runs in a container of its own instead, as each has a
worker of its own on EMR Serverless (see Executors below).
-
Executors: with
executor-containersabove0, Floci starts an executor's container as the driver asks for one, of the same image as the driver's or the application's for its executors (see Image), on the same network, with the same credentials and trust store. Its worker offers the run'sspark.executor.coresandspark.executor.memory, which Floci reads from the running driver, so they come from the image'sspark-defaults, the run's configuration or itssparkSubmitParametersalike: 4 cores and 14 GB unless the run says otherwise. How many run follows Spark's dynamic allocation, on by default, which starts withspark.dynamicAllocation.initialExecutors(3) and releases an idle executor afterspark.dynamicAllocation.executorIdleTimeout, when its shuffle data allows: Floci removes the container of an executor Spark released. With dynamic allocation off,spark.executor.instancesstart. A run has at mostexecutor-containersexecutors at once, and none that would take the workers of its application's runs, their drivers' among them, past the application'smaximumCapacity, which "is cumulative across all workers at any given point in time" and of which "no new resources will be created once any one of the defined limits is hit": a worker counts its cores, its memory with Spark's overhead rounded up to a whole GB, and its disk,spark.emr-serverless.executor.diskorspark.emr-serverless.driver.disk, 20 GB by default. The overhead is the run'sspark.executor.memoryOverhead(or the driver's), else that share of the memory itsspark.executor.memoryOverheadFactorgives, elsespark.emr-serverless.memoryOverheadFactor's, else 10%, and at least 384 MB. The master's address, the run's secret and the UI's kill links (see below) come after the run's own options, so none of them replaces these. Every executor's container goes with its driver, however the run ends, as does one that ended before it, and a hard stop's leftovers go as its driver's do. Withexecutor-containersat0, the default, or on the host's network or another container's network namespace, where two runs' ports would meet, the executors run in the driver's container instead, in Spark's local mode. -
States: a run is
SCHEDULEDwhile its image is pulled and its container starts (the first run of a release pulls its image, 3.5 to 4.3 GB unpacked; a pull still downloading afterfloci.docker.image-pull-timeout-seconds, five minutes by default, is tried again, three attempts in all, so on a slow connection raise it or rundocker pullon the image first, or the run isFAILEDwith "Could not pull image"), andRUNNINGonce the Spark driver runs, which setsstartedAt. It isSUCCESSwhen the driver exits with code 0 andFAILEDotherwise, with the exit code instateDetails.CancelJobRun, or aBATCHrun passing itsexecutionTimeoutMinutes, makes itCANCELLINGuntil the driver is stopped, thenCANCELLED, as the job run states describe. A run Floci was running when it stopped isFAILEDonce it is read again. Floci's shutdown and a state reset stop every driver, one whose image is still being pulled included, and a driver a hard stop left running is removed the first time job runs are used after Floci restarts, unlessreconcile-containers-on-startupis off. -
What
spark-submitgets: theentryPoint, itsentryPointArgumentsand thesparkSubmitParameters, after thespark-defaultsproperties of the application'sruntimeConfiguration, or the run's own inconfigurationOverrides.applicationConfiguration, which replace the application's wholespark-defaultsclassification. Fromemr-spark-8.1.0the two are merged by property instead, the run's winning.s3://ands3a://paths reach Floci's S3 through S3A, on releases before 7.10.0 too, wheres3://would otherwise be EMRFS; the entry point and its files can be read from there. The Glue Data Catalog client is pointed at Floci's Glue, with the run's account as itshive.metastore.glue.catalogid(fromemr-7.10.0the client would otherwise ask STS for it), which aspark.hadoop.hive.metastore.glue.catalogidin thespark-defaultsreplaces. -
Driver environment and archives: a
spark.emr-serverless.driverEnv.<KEY>property, from thespark-defaultsabove or a--confinsparkSubmitParameters, which wins, is an environment variable of the container, replacing one of Floci's own of that name, such as the user guide'sJAVA_HOMEfor Java 17. Each archive ofspark.archives(whichspark-submit's--archivessets, winning over a--conf) that is in Floci's S3 is unpacked into the container's working directory,/home/hadoopin the release's image, before the driver starts, under the name that follows its#, or else its file's name: a.jaror.zipis unzipped, a.tar.gz,.tgzor.taruntarred, and any other file copied, as Spark unpacks one. So the user guide's Python virtual environment runs as it is written there:--conf spark.archives=s3://amzn-s3-demo-bucket/EXAMPLE-PREFIX/pyspark_venv.tar.gz#environment --conf spark.emr-serverless.driverEnv.PYSPARK_DRIVER_PYTHON=./environment/bin/python --conf spark.emr-serverless.driverEnv.PYSPARK_PYTHON=./environment/bin/python --conf spark.executorEnv.PYSPARK_PYTHON=./environment/bin/pythonFloci reads each archive as the run's account. One it cannot read fails the run before its driver starts, with "Job run could not start" naming it, and one that does not unpack fails the run as a driver's failure does. Spark also unpacks every archive itself, into its own files folder, where
SparkFiles.getfinds it, and, with executors in containers of their own, into each executor's working directory. Aspark.executorEnv.<KEY>needs nothing more from Floci: Spark gives these variables to its executors, in the driver's JVM in local mode, and the Python workers they start. -
Credentials: the container gets a session for the run's execution role when IAM knows the role, otherwise the account's placeholder credentials, and
AWS_ENDPOINT_URLpointing at Floci, so the job's own SDK clients reach Floci too. -
HTTPS: with TLS on, the container also gets Floci's CA bundle as a Java trust store,
/etc/floci-ca-bundle.p12, which every JVM in it uses throughJAVA_TOOL_OPTIONS, each saying so on its standard error (Picked up JAVA_TOOL_OPTIONS: ...); a trust store the job names itself, with-Djavax.net.ssl.trustStore, replaces it. So the job trusts Floci over HTTPS, and withFLOCI_DNS_SPOOF_AWS_ENDPOINTSon as well, which leads AWS's own endpoint names to Floci, SDK clients that ignoreAWS_ENDPOINT_URL, the AWS SDK for Java 1.x's for one, reach Floci unchanged. -
Output: the driver's output goes to Floci's log, prefixed
emr-serverless:<jobRunId>. With an S3 log destination, the run'ss3MonitoringConfigurationor else the application's, its standard output and error also go to Floci's S3 once the run ends, gzipped, asstdout.gzandstderr.gzunder<logUri>/applications/<applicationId>/jobs/<jobRunId>/SPARK_DRIVER/, withattempts/<n>/beforeSPARK_DRIVER/for aSTREAMINGrun, or aBATCHrun whoseretryPolicyallows more than one attempt, on release 7.1.0 or later, each attempt's logs under its own number. A cancelled run's logs hold what its driver wrote until it was stopped. Logs that cannot be written, to a bucket that does not exist say, leave the run as it ended. -
CloudWatch Logs: with CloudWatch logging enabled, the run's
cloudWatchLoggingConfigurationor else the application's ("enabled": falseat the run turns it off), the driver's standard output and error go line by line, while it runs, to the log streams<prefix>/applications/<applicationId>/jobs/<jobRunId>/SPARK_DRIVER/stdoutand.../stderrin Floci's CloudWatch Logs, withattempts/<n>/beforeSPARK_DRIVERas for S3. The log group islogGroupName,/aws/emr-serverlessby default, and<prefix>thelogStreamNamePrefix, if any; both are created as needed, in the run's account and Region. AlogTypessends only the driver's types it names, and none of the driver's output when it names onlySPARK_EXECUTOR. -
Image: an application's custom image runs in place of the release's: the
Driverworker type'simageConfigurationinworkerTypeSpecificationsfor the driver and theExecutorworker type's for the executors in containers of their own (local mode runs them in the driver's container), or else the application'simageConfiguration, which applies to every worker type. An<account>.dkr.ecr.<region>.amazonaws.com/<repository>:<tag>URI leads to Floci's ECR, as a Lambda function's or an ECS task's image does, so the image is pushed to a repository there; therepositoryUriFloci's ECR hands out works too. The image is pulled again for every run, so a tag pushed again is what the next run gets; when the pull fails the image the Docker daemon already has runs, one built locally under that URI included, and without one the run isFAILEDwith "Job run could not start".CreateApplicationrefuses an image configuration without animageUri, andCreateApplicationandUpdateApplicationan image whose ECR repository, AWS-shaped or arepositoryUrifrom Floci's ECR, is in another Region, both withValidationExceptionin Floci's own wording. An update that leavesimageUriout removes that image configuration. Without a custom image,image-templatenames another image than the release's, such as a mirror or a dated tag of it:registry.internal/emr-serverless/spark/%s:20250425.GetJobRunreports the image configurations each attempt applies, as its application had them when the attempt was made: itsimageConfiguration, and its worker types' inworkerTypeSpecifications(those the application resolved as it started, with that digest), as AWS's do when digests are resolved for each run ("To identify which image version each job is running, the GetJobRun API response returns the resolvedImageDigest for that specific job"). The driver's configuration, its worker type's or else the application's, has theresolvedImageDigestof the image the attempt pulled for the driver, its manifest digest in Floci's ECR; the executors' has theirs, or the driver's where the two share one. No other has a digest, even one naming the same image, such as theExecutorimage while local mode runs the executors in the driver's container, or a Hive run'sTezTaskimage. Nor does one built locally under that URI, nor any without thedockerrunner mode, which pulls no image. -
Architecture: a run's containers, its driver's and its executors', run on the Docker host's own platform by default. With
honour-architectureson (FLOCI_SERVICES_EMRSERVERLESS_HONOUR_ARCHITECTURES=true) they run the image for its application'sarchitecture,linux/amd64forX86_64andlinux/arm64forARM64, the release's images being published for both and a custom image pulled for that platform; an application that names none still runs on the host's own, where on EMR Serverless "x86_64 is the default option". It is off by default, as Lambda's is, because tools such as Terraform nameX86_64unless told otherwise, which on an arm64 host would move every run to emulation. A host of another architecture runs the image under emulation, which Docker Desktop has and a Linux host gets from QEMU'sbinfmt_mischandlers; without it the driver cannot start ("exec format error") and the run fails. Floci does not fall back to the host's platform when the setting is on.
Running Hive job runs
With runner-mode set to docker, a Hive application's job run executes too. Floci starts one container per
run from the application's custom image, if it names one, or else from the release's Hive image, the base image
AWS publishes for customizing EMR Serverless Hive images (public.ecr.aws/emr-serverless/hive/<release>), and
runs hive in it, with Tez in local mode, in Hive's JVM: the container holds the Hive driver and its Tez tasks.
The custom image is the HiveDriver worker type's imageConfiguration in workerTypeSpecifications, or else the
application's imageConfiguration; a TezTask image is not used, as Tez's tasks run in the driver's container.
- States, credentials, HTTPS and the image: as for a Spark run, above, the driver being
hive. The first run of a release pulls its Hive image, 2.7 GB unpacked. Without a custom image,hive-image-templatenames another image than the release's:registry.internal/emr-serverless/hive/%s:20250425. - What
hivegets: the properties of thecore-site,tez-siteandhive-siteclassifications, each a--hiveconf, from the application'sruntimeConfigurationor the run's ownconfigurationOverrides.applicationConfiguration, which replaces the application's whole classification; then the run'sinitQueryFileandquery, which Hive reads from Floci's S3 and runs in that order; then itsparameters, split as a shell would split them, so a--hiveconfthere takes priority over the classifications, as the user guide ranks them. Before them all come Floci's own settings, which any of them replaces: S3A on Floci's S3 fors3://, the Glue Data Catalog client, the image's metastore, on Floci's Glue with the run's account as itshive.metastore.glue.catalogid(ahive-siteone names another account's catalog), and Tez in local mode.emrfs-siteis not applied, ass3://goes through S3A rather than EMRFS. - Scratch and warehouse folders:
hive.exec.scratchdirandhive.metastore.warehouse.dir, which the user guide makes mandatory, are used as the run sets them, in Floci's S3. Hive runs as the image'shadoopuser, in its home folder; Tez in local mode copies its session's staging folder, which Hive puts under the scratch folder, to the same path in the container, so Floci makes that pathhadoop's before Hive starts. - Output: the driver's standard output, where Hive prints a query's results, and its standard error, where the
Hive CLI prints its progress and errors, go to Floci's log, prefixed
emr-serverless:<jobRunId>. With an S3 log destination they also go tostdout.gzandstderr.gzunder<logUri>/applications/<applicationId>/jobs/<jobRunId>/HIVE_DRIVER/once the run ends, and with CloudWatch logging to the log streams.../HIVE_DRIVER/stdoutand.../HIVE_DRIVER/stderrwhile it runs, as a Spark run's go underSPARK_DRIVER; alogTypestakes the driver's types from itsHIVE_DRIVERentry.
Limitations and Differences from AWS
- Jobs do not execute by default: in the
immediaterunner modeStartJobRunrecords a job run and moves it through its states, but nothing runs. In thedockermode a Spark run executes in Spark's local mode in one container unlessexecutor-containersis above0(see Executors below), and a Hive run with Tez in local mode in one container: in local mode, worker counts and sizes, initial and maximum capacity are not applied. A driver's failure isFAILEDin Floci's own wording. Of the monitoring configuration, the S3 log destination gets the driver'sstdout.gzandstderr.gzonce a run ends (no event logs, rotated files or uploads while it runs), and CloudWatch Logs the driver's output while it runs (no executor logs, which local mode does not have and executors' containers take with them, noHIVE_LOG,TEZ_AMorTEZ_TASKlogs of a Hive run, whose own log stays in its container, andencryptionKeyArnis ignored). - Executors: with
executor-containersabove0, a Spark run's executors run in containers of their own, but at mostexecutor-containersof them, rather than as many as dynamic allocation asks for, and a container's memory and cores are not limited to its worker's size, which only Spark's settings follow.initialCapacityis not applied: no worker is waiting, so each starts as the run asks for it. Spark's master is Spark's own standalone master, in the driver's container, where EMR Serverless has its own (spark.masterreadsspark://...), and the driver's UI, which the release's image turns off, is on, with its kill links off, as Floci follows the driver through it: a run that turns it off again (spark.ui.enabled=false) gets a single executor container 30 seconds after its driver starts, whose worker offers 32 cores and 256 GB, as Floci cannot read the run's own sizes, and which, like its driver's, counts for nothing against the application'smaximumCapacity. - A driver that is not its application's type: AWS documents no answer for a
hiverun on a Spark application, or asparkSubmitrun on a Hive application. In thedockermode Floci records such a run, then fails it without running, in Floci's own wording, as its application's image could not run it. - Mandatory Hive properties: Floci does not refuse a Hive run without
hive.exec.scratchdirorhive.metastore.warehouse.dir. Hive then keeps its scratch files and its managed tables' data in the container, which go with it. - Unsourced errors: AWS documents neither the error for a run submitted to an application whose auto-start is off nor the one for a run on a terminated application; Floci answers both with
ValidationException. The same holds for aBATCHtimeout outside 1 to 10080 minutes onemr-7.11.0or later (ValidationException) and forGetJobRunnaming an attempt a run never made (ResourceNotFoundException), both in Floci's own wording. A run needs ajobDriver, as everyJobRuncarries one, andjobDriveris a union, so a run without a driver, or with one that sets bothsparkSubmitandhiveor neither, is refused withValidationExceptiontoo, in Floci's own wording. - Archives: only the archives of
spark.archivesthat are in S3 are unpacked into the driver's working directory; Spark alone unpacks the others, into its own files folder. Floci reads an archive itself, whatever the execution role may read, though Spark's own read of it uses the role's credentials. - Custom images: Floci does not check an
imageUriagainst the model's pattern, which would refuse the repository URIs Floci's own ECR hands out, nor that the image was built from its release's base image (AWS refuses one that was not fromemr-7.14.0andemr-spark-8.1.0on), nor the image's size. An image that cannot be pulled fails the run, not the request that names it. An image's digest is resolved as the application starts where itsapplicationLevelDigestResolutionis true, or left unset on EMR 7.13 or earlier, as the user guide's table has it, and AWS's "Custom images are resolved to a digest at application start; that digest is used for all jobs until the application restarts": the application's image configuration gets the digest of the image in Floci's ECR as itsresolvedImageDigest, and each run pulls the image by it until the application starts again; a stopped application reports none. An image outside ECR, one in another account's repository (Floci does not check that the application may pull it), or one Floci's ECR does not hold or cannot read without Docker, has no digest to read and is resolved for each run, as every image is from 7.14 on; any other answer from Floci's ECR failsStartApplicationwithInternalServerException; such a run's digest comes from its attempt's own pull (see Image above), and a job run's image configurations carry noapplicationLevelDigestResolution. - Not emulated: the "EMR Serverless Job Run Retry" event, as Floci sends no EMR Serverless events, queuing (
QUEUED),totalResourceUtilizationandbilledResourceUtilization(of a job run or a session), andshutdownGracePeriodInSeconds(accepted and ignored: a cancelled run's driver is stopped at once). - Instant Start/Stop: Floci marks the application
STARTEDorSTOPPEDimmediately without provisioning actual compute capacity in the background. - Sessions in the
immediatemode run nothing: a session is kept with its lifecycle, but no Spark driver runs for it, and a Spark Connect call to it is refused; thedockermode runs one (see Running a session's Spark Connect server).