Skip to content

Glue run concurrent jobs.

0

We have a job (Jupyter notebook job) version 4 that we are trying to run in concurrent mode changing some of the parameters and running via AWS CLI like below

aws glue start-job-run --job-name "country-job" --arguments='--ISO=DNK, --DAYS=2' --profile glue-eu
aws glue start-job-run --job-name "country-job" --arguments='--ISO=NOR, --DAYS=2' --profile glue-eu

Added the below to the job %%configure including the magic "max_concurrent_runs": 4

%%configure
{
    "region": "eu-west-1",
    "idle_timeout": "480",
    "glue_version": "4.0",
    "number_of_workers": 10,
    "execution_class": "FLEX",
    "iam_role": "arn:aws:iam::ABC:role/AWSGlueServiceRole-searchlogs-s3",
    # "profile": "glue-profile",
    "session_id_prefix": "ABC",
    "worker_type": "G.1X",
    "max_concurrent_runs": 4
}

But keeps failing with the error below An error occurred (ConcurrentRunsExceededException) when calling the StartJobRun operation: Concurrent runs exceeded for country-job

Do I need to set the job any diferently ? Thanks

3 Answers
0
Accepted Answer
import boto3
import json
from datetime import datetime


def jobProperties():
    global client, job
    # Create a Glue client
    client = boto3.client('glue', region_name='eu-west-1')
    # Get the current job configuration
    response = client.get_job(JobName='my-job')
    job = response['Job']

    # Function to convert datetime objects to strings
    def datetime_converter(o):
        if isinstance(o, datetime):
            return o.isoformat()

    # Serialize the job configuration to JSON
    job_json = json.dumps(job, indent=2, default=datetime_converter)
    print(job_json)


jobProperties()


def updatejob() -> None:
    # Define the updated job parameters
    updated_job = {
        'Description': 'A job that filters geocode querys per country metadata matches',  # Change the description
        'GlueVersion': '4.0',  # Change the Glue version to '4.0'
        'Command': job['Command'],  # Ensure the Command property is included
        'Role': job['Role'],        # Include the IAM role
        'Timeout': 480,             # Set the desired timeout in minutes
        'NumberOfWorkers': 20,       # change number of workers
        'WorkerType': 'G.1X',        # change worker type
        'MaxRetries': 0,             # change max retries
        'ExecutionClass': 'FLEX',  # Include the ExecutionClass
        "ExecutionProperty": {"MaxConcurrentRuns": 4}
    }

    # Unknown parameter in JobUpdate: "MaxConcurrentRuns",
    # must be one of:
    # Description,
    # LogUri,
    # Role,
    # ExecutionProperty,
    # Command,
    # DefaultArguments,
    # NonOverridableArguments,
    # Connections,
    # MaxRetries,
    # AllocatedCapacity,
    # Timeout,
    # MaxCapacity,
    # WorkerType,
    # NumberOfWorkers,
    # SecurityConfiguration,
    # NotificationProperty,
    # GlueVersion,
    # CodeGenConfigurationNodes,
    # ExecutionClass,
    # SourceControlDetails

    # Update the job with the new timeout
    response = client.update_job(
        JobName='my-job',
        JobUpdate=updated_job
    )

    print(response)

jobProperties()
updatejob()



answered 2 years ago

0

Your Magic looks good and it will allow you to run 4 instance of the job concurrently.

  1. Check the concurrency is configured from job property with below command, and the output with 4 MaxConcurrentRuns : aws glue get-job --job-name "country-job" --profile glue-eu
"ExecutionProperty": {
            "MaxConcurrentRuns": 4
        }
  1. Check the run instance not crossing 4 from "Runs" or Glue Monitoring console.
  2. Finally, remember after the Glue job completes (SUCCEEDED or FAILED), it needs few seconds (around 5-10 seconds) to completely cleanup resources, until then it considered running. This is because the job metering stopped for customer, but it can still conflict with concurrency. So either slow down on the request for new run or have little higher concurrency count.
AWS

answered 3 years ago

  • Thanks , I did run the get-job command and im seeing in fact that the the value is in fact = 1 "ExecutionProperty": { "MaxConcurrentRuns": 1 },

    How can this be if on my Jupyter magic && configure I have it like = 4 ( "max_concurrent_runs": 4 ) , how do you set this on your jupyter notebook runs ?

    %%configure { "region": "eu-west-1", "idle_timeout": "480", "glue_version": "4.0", "number_of_workers": 10, "execution_class": "FLEX", "iam_role": "arn:aws:iam::ABC:role/AWSGlueServiceRole-searchlogs-s3", # "profile": "glue-profile", "session_id_prefix": "ABC", "worker_type": "G.1X", "max_concurrent_runs": 4 }

0

Hi Jorge Vidinha! Did you figure this out by any chance? I am running into the same issue.

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.