Updated on 2026-11-06 GMT+08:00

Creating a Spark Engine Endpoint

Scenarios

Before submitting a Spark job, you must create a Spark engine endpoint. This endpoint serves as the primary entry point for establishing a connection with the AI DataLake engine. A Spark engine endpoint also serves as the entry point for compute resources. Through this endpoint, you can interact with the AI DataLake engine to submit data processing and analysis tasks.

After creating an endpoint, you can use it to create and run Spark jobs, such as executing SparkSQL queries, running Spark applications, or cleaning and transforming data. To create an endpoint, you need to configure parameters such as the endpoint type and compute resource allocation mode. Once the configuration is complete, the system automatically allocates the required compute resources. You can then use the Spark engine to process large-scale data.

This section describes how to create a Spark endpoint.

Configuration parameters vary depending on the endpoint type.

Table 1 Endpoint types and configurations

Endpoint Type

Description

Related Link

SparkSQL

SparkSQL endpoints are interactive SQL endpoints provided by the Spark engine that allow you to filter, aggregate, and compute data using SQL statements. They are ideal for interactive scenarios such as data queries, data analysis, ad hoc queries, and data exploration. When executing SQL statements, these endpoints access LakeFormation resources as the current user (an IAM user with policy-assigned permissions). They support three resource allocation modes—reserved, hybrid, and on-demand—and provide Query Profiles for analyzing query performance.

SparkSQL endpoints support built-in images only.

Creating a SparkSQL Endpoint

SparkJob

SparkJob endpoints are batch processing endpoints provided by the Spark engine for large-scale data transformation and complex processing. They are well suited for batch processing scenarios such as ETL jobs, machine learning model training, and large-scale data transformation. When running jobs, these endpoints access LakeFormation resources using the agency configured for the endpoint. They allow you to view submission logs and support three resource allocation modes: reserved, hybrid, and on-demand.

SparkJob endpoints support both built-in and custom images.

Creating a SparkJob Endpoint

To implement endpoint security isolation, we recommend deploying endpoints across different resource pools or workspaces. This establishes security boundaries through resource pool- or workspace-level isolation.

Creating a SparkSQL Endpoint

  1. Log in to the AI DataLake console.
  2. In the upper left corner of the page, select the target workspace.
  3. In the left navigation pane, choose Engine Endpoints > Spark. The Spark engine endpoint list appears.
  4. Click Create Endpoint in the upper right corner of the page and configure the endpoint settings.
  5. Configure the basic information for the endpoint.

    Table 2 Basic endpoint information

    Parameter

    Description

    Endpoint Type

    Set the endpoint type to SparkSQL.

    Endpoint Name

    The endpoint name cannot be changed after the endpoint is created.

    The endpoint name is a unique identifier in the system. It is referenced in API calls and CLI commands and must be unique.

    Naming rules:

    • The name can contain only lowercase letters, digits, and hyphens (-), and must start with a letter and end with a letter or digit.
    • The name can contain a maximum of 63 characters.

    Example: spark-endpoint-001 and my-spark-job

    Endpoint Display Name

    The endpoint display name can be changed after the endpoint is created.

    The endpoint display name appears on the console to help users identify the endpoint.

    Naming rules:

    • The name can contain only letters, digits, and hyphens (-).
    • The name can contain a maximum of 63 characters.

    Example: Spark engine in the production environment and endpoint dedicated to data analysts

    Description

    Enter a description to specify the purpose and background of the endpoint, helping other users understand its application scenarios.

    Tags

    Configure tags to classify, identify, and manage endpoints. For details about tag management, see Managing AI DataLake Tags.

  6. Configure the resource settings for the endpoint.

    Table 3 Endpoint resource settings

    Parameter

    Description

    Resource Allocation

    Select a resource allocation mode.

    When the endpoint resource allocation mode is set to Hybrid or On-demand, the system triggers elastic resource scheduling. In this mode, you authorize AI DataLake to access your task and resource data to perform specific operations on your behalf.

    • Reserved: Uses reserved resource pools to provide exclusive resources. This mode is ideal for stable, continuous workloads, such as production projects and critical tasks.
    • Hybrid: Provides baseline stability and automatic scaling. Reserved resources are used first, and auto scaling is triggered automatically during peak hours. This mode is best for workloads with predictable fluctuations.
    • On-demand: Charges you based on the actual time taken to execute each task. No costs are incurred when no tasks are running. This mode is well-suited for short-term or ad-hoc tasks, including development, testing, and temporary projects.
    CAUTION:

    If the resource allocation mode is set to On-demand and no network exists in the workspace, you must create a network and select it for the endpoint. Each workspace supports only one network. For details about creating a network, see Creating a Network.

    Compute Resource Pool

    After selecting Reserved or Hybrid, select a compute resource pool. You can click Buy Compute Resource to purchase a compute resource pool. For details, see Procedure.

    Specifications

    After selecting compute resources, set the maximum value for Resource Quota (Min-Max). The requirements for the maximum value are as follows:

    • Reserved mode: The maximum value for Resource Quota (Min-Max) cannot exceed the total capacity of the selected compute resource pool. If you need a higher quota, increase the capacity of the resource pool first. For details, see Scaling a Compute Resource Pool.
    • Hybrid mode: The maximum value for Resource Quota (Min-Max) can exceed the total capacity of the selected compute resource pool. Any excess will be automatically scheduled to elastic resources.

    Maximum Resource Quota

    When you select the on-demand resource allocation mode, configure the maximum resource quota to set an upper limit on elastic resource consumption. This prevents uncontrolled resource expansion during sudden traffic spikes, avoiding unexpected cost surges. Additionally, the system uses this maximum quota configuration to efficiently schedule and allocate resources.

  7. Configure an image.

    An image defines the runtime environment for an endpoint or job. SparkSQL endpoints support built-in images only. Click the image selection box. Click the name of a built-in image, select a version, and click OK.
    Creating an image snapshot is recommended to speed up image loading. For details, see Image Acceleration.
    • An image snapshot caches an image version locally. Once created, the snapshot reuses cached image data directly during container startup, eliminating the need to pull the image from the repository. This reduces image pull and container startup times, boosting job execution efficiency.
    • If an image snapshot exists for the selected image version, the snapshot is automatically associated when you select the image. When the endpoint container starts, it automatically uses the snapshot to create resources, requiring no additional manual steps.

  8. Configure the cluster settings for the endpoint.

    The number of CPU cores configured for the driver and executors must be less than the maximum value configured for Resource Quota (Min-Max) or the value configured for Maximum Resource Quota above.

    • Driver
      Table 4 Driver configuration

      Parameter

      Description

      spark.driver.cores

      Driver CPU cores. It specifies the number of vCPUs to allocate for the driver process in a Spark application.

      spark.driver.memory

      Driver memory. It specifies the amount of memory to allocate for the driver process in a Spark application.

    • Executors
      Table 5 Executor configuration

      Parameter

      Description

      spark.executor.cores

      Executor CPU cores. It specifies the number of vCPUs to allocate for each executor process.

      spark.executor.memory

      Executor memory. The amount of memory to allocate for each executor process.

      Executor Range (Min–Max)

      Set the minimum and maximum number of executors. The system dynamically scales the number of executors within this specified range based on the workload. It is recommended to allocate at least one executor to ensure optimal Spark performance.

      Table 6 Endpoint resource settings

      Parameter

      Description

      Clusters (Min–Max)

      The minimum and maximum number of clusters that remain running to support the endpoint.

      • Min: Specifies the minimum number of clusters to keep running. When the auto-stop idle cluster function is enabled, the system ensures that at least this specified number of clusters remain running to guarantee fast SQL execution.

        If this parameter is set to 0, the endpoint creates clusters only when new requests arrive. Because spinning up a new cluster takes time, this can increase the response delay.

        In a production environment, it is recommended that you set this parameter to at least 1 to ensure that there are always clusters ready to execute tasks.

      • Max: Specifies the maximum number of clusters that the endpoint can create. When the number of concurrent SQL queries exceeds the capacity of a single cluster, the system automatically scales out clusters to handle the requests. Set the maximum number of clusters based on your expected concurrent queries.
        • The maximum value must be greater than or equal to the minimum value, and it cannot be less than 2.
        • A larger maximum value provides greater scalability but incurs higher costs.

      Concurrent SQL Queries per Cluster

      The maximum number of concurrent SQL queries that a single cluster can process. If the number of SQL queries exceeds the capacity of a single cluster, the system adds new clusters. If the number of clusters exceeds the configured maximum, new requests are queued.

      If the value is too low, resources may be underutilized. If the value is too high, SQL query execution may slow down.

      Clusters with more memory can support higher concurrency.

      SQL Query Concurrency per Endpoint

      The maximum number of concurrent SQL queries that all clusters of an endpoint can process. Requests exceeding this limit will fail and be rejected.

      • This value must be greater than or equal to the maximum concurrent SQL queries per cluster.
      • If the value is too low, service concurrency will be limited. If the value is too high, costs will increase.

        Recommended configuration: Maximum concurrent SQL queries per endpoint ≥ Concurrent SQL queries per cluster x Maximum number of clusters.

      Auto-stop idle cluster

      Enable or disable the automatic shutdown of idle clusters, and set the idle timeout duration.

      • If this option is selected, the system automatically stops idle clusters while keeping the minimum required clusters running.

        After you configure Cluster Range (Min–Max), the system keeps the minimum required clusters running to ensure fast SQL execution. You are billed only for clusters while they are active. When the auto-stop feature is enabled, the system automatically shuts down idle clusters but keeps the minimum required clusters running, regardless of the resource allocation mode.

        If this option is selected, you must set the idle timeout duration (the period when no SQL queries are running). After a query is executed, the system does not reclaim compute resources immediately. Instead, it enters an idle state (for example, for 10 minutes). If a new query is submitted during this period, the existing resources are reused, reducing scheduling and startup times. If no new queries are submitted within this timeframe, the system automatically stops the idle clusters (except for the minimum required clusters) to release resources and reduce costs. The first job submitted after resources are released may run slowly because the system must dynamically allocate elastic resources. Table 7 describes how cluster shutdowns impact billing across different resource allocation modes.

      • Deselect this option to disable the automatic shutdown of idle clusters.

        Once started, all clusters remain running even if no queries are executing, and you are billed for each cluster's actual uptime.

      If low latency is required in your production environment, you can disable the automatic shutdown of idle clusters. In test environments, it is recommended that you enable this feature to prevent idle resources, improve utilization, and reduce costs.

      Max Cluster Lifespan (h)

      Set the maximum cluster lifespan. When this limit is reached, the cluster automatically terminates after all active SQL queries complete.

      Table 7 Impact of idle cluster auto-stop on billing

      Resource Allocation

      Impact of Idle Cluster Auto-Stop on Billing

      Reserved

      Reserved resource pools are used to provide dedicated resources. No additional charges are incurred, even though the minimum number of clusters runs continuously.

      Hybrid

      Jobs may run on on-demand elastic resources, which can incur usage fees for the minimum number of clusters.

      On-demand

      On-demand resources are billed based on the actual usage duration. Usage fees are incurred as long as the minimum number of clusters runs continuously.

  9. Configure Spark parameters.

    Specify Spark job submission properties in a key=value format.

    Key: Enter the configuration parameter required by the Spark job, such as spark.sql.adaptive.enabled or spark.executor.memory.

    Value: Enter the value for the corresponding key, such as 4294967296. The default unit for memory is bytes.

  10. Configure the storage settings for the endpoint.

    Table 8 Storage settings

    Parameter

    Description

    Temporary File Storage

    Select an existing parallel file system from the drop-down list. If no parallel file system is available, click Create OBS parallel file system to create one. For details, see Creating a Parallel File System.

    Parallel file systems are used to store job logs and temporary data. Files are not automatically deleted after a job completes. We recommend manually clearing resources in the parallel file system periodically or configuring an OBS lifecycle rule to delete outdated storage files automatically, preventing unnecessary storage usage and extra fees. For example, you can use a lifecycle rule to set the retention period (we recommend at least 7 days) by directory. For details, see Creating a Lifecycle Rule.

    Agency

    Configure an agency (such as an IAM agency) with read and write permissions for event logs, error logs, and temporary data.

    Select an existing agency from the drop-down list. If no agency is available, click Create Agency to create one.

  11. Configure the AOM monitoring integration as needed.

    Table 9 Parameters for AOM monitoring integration

    Parameter

    Description

    Monitor AOM

    Select Monitor AOM if needed.

    After AOM monitoring is enabled, application metrics are reported to AOM for centralized management. AOM enables real-time metric collection, custom monitoring, alarm configuration, and O&M data visualization, providing complete visibility into service status. For details about the metrics and their meanings, see Resource and Job Metrics for Spark Endpoints.

    Prometheus Instance

    Select a Prometheus instance from the drop-down list. If no instance is available, click Create Instance.

  12. Configure the network settings.

    If the resource allocation mode is set to On-demand and no network exists in the workspace, you must create a network and select it for the endpoint. Each workspace supports only one network. For details about creating a network, see Creating a Network.

  13. After completing the configuration, click Create Now. The system will begin creating the endpoint.

Once the endpoint is created, you can view its details in the endpoint list. After the status changes to Running, you can submit jobs to the endpoint.

Creating a SparkJob Endpoint

  1. Log in to the AI DataLake console.
  2. In the upper left corner of the page, select the target workspace.
  3. In the left navigation pane, choose Engine Endpoints > Spark. The Spark engine endpoint list appears.
  4. Click Create Endpoint in the upper right corner of the page and configure the endpoint settings.
  5. Configure the basic information for the endpoint.

    Table 10 Basic endpoint information

    Parameter

    Description

    Endpoint Type

    Set the endpoint type to SparkJob.

    Endpoint Name

    The endpoint name cannot be changed after the endpoint is created.

    The endpoint name is a unique identifier within the system and is used in API calls and CLI commands.

    Naming rules:

    • The name can contain only lowercase letters, digits, and hyphens (-), and must start with a letter and end with a letter or digit.
    • The name can contain a maximum of 63 characters.

    Example: spark-endpoint-001 and my-spark-job

    Endpoint Display Name

    The endpoint display name can be changed after the endpoint is created.

    The endpoint display name appears on the console to help users identify the endpoint.

    Naming rules:

    • The name can contain only letters, digits, and hyphens (-).
    • The name can contain a maximum of 63 characters.

    Example: Spark engine in the production environment and endpoint dedicated to data analysts

    Description

    Enter a description to specify the purpose and background of the endpoint, helping other users understand its application scenarios.

    Tags

    Configure tags to classify, identify, and manage endpoints. For details about tag management, see Managing AI DataLake Tags.

  6. Configure the resource settings for the endpoint.

    Table 11 Spark endpoint resource settings

    Parameter

    Description

    Resource Allocation

    Select a resource allocation mode.

    When the endpoint resource allocation mode is set to Hybrid or On-demand, the system triggers elastic resource scheduling. In this mode, you authorize AI DataLake to access your task and resource data to perform specific operations on your behalf.

    • Reserved: Uses reserved resource pools to provide exclusive resources. This mode is ideal for stable, continuous workloads, such as production projects and critical tasks.
    • Hybrid: Provides baseline stability and automatic scaling. Reserved resources are used first, and auto scaling is triggered automatically during peak hours. This mode is best for workloads with predictable fluctuations.
    • On-demand: Charges you based on the actual time taken to execute each task. No costs are incurred when no tasks are running. This mode is well-suited for short-term or ad-hoc tasks, including development, testing, and temporary projects.
    CAUTION:

    If the resource allocation mode is set to On-demand and no network exists in the workspace, you must create a network and select it for the endpoint. Each workspace supports only one network. For details about creating a network, see Creating a Network.

    Compute Resource Pool

    After selecting Reserved or Hybrid, select a compute resource pool. You can click Buy Compute Resource to purchase a compute resource pool.

    Specifications

    After selecting compute resources, set the maximum value for Resource Quota (Min-Max). The requirements for the maximum value are as follows:

    • Reserved mode: The maximum value cannot exceed the total capacity of the selected compute resource pool. If you need a higher quota, increase the capacity of the resource pool first.
    • Hybrid mode: The maximum value can exceed the total capacity of the selected compute resource pool. Any excess will be automatically scheduled to elastic resources.

    Maximum Resource Quota

    When selecting the on-demand resource allocation mode, you must configure the maximum resource quota. This sets an upper limit on elastic resource consumption, preventing uncontrolled resource expansion due to sudden traffic surges and avoiding the exhaustion of cluster compute capacity. Additionally, the system uses this maximum quota configuration to efficiently schedule and allocate resources.

  7. Configure an image.

    An image defines the runtime environment for an endpoint or job. SparkJob endpoints support both built-in and custom images. Click the image selection box. On the Built-in Images or Custom Images tab, click an image name, select an image version, and then click OK.

    If the existing built-in images do not meet your requirements, you can create and register a custom image by referring to Custom Images, and then select it here.

    Custom images allow you to modify the container runtime environment of jobs, thereby enhancing job functionality and performance.

    Creating an image snapshot is recommended to speed up image loading. For details, see Image Acceleration.
    • An image snapshot caches an image version locally. Once created, the snapshot reuses cached image data directly during container startup, eliminating the need to pull the image from the repository. This reduces image pull and container startup times, boosting job execution efficiency.
    • If an image snapshot exists for the selected image version, the snapshot is automatically associated when you select the image. When the endpoint container starts, it automatically uses the snapshot to create resources, requiring no additional manual steps.

  8. Configure the scheduling settings for the endpoint.

    These settings determine the job scheduling policy and the maximum number of concurrent jobs an endpoint can run. They help efficiently schedule jobs in multi-user and multi-task scenarios, improving resource utilization.
    Table 12 Endpoint scheduling settings

    Parameter

    Description

    Job Concurrency per Endpoint

    The maximum number of concurrent jobs an endpoint can run. Requests exceeding this limit will fail and be rejected.

    Job Scheduling Policy

    AI DataLake supports the following job scheduling policies:

    • Random: Jobs are selected at random for processing. In each scheduling cycle, a job is randomly selected for execution, rather than based on its submission order or priority.
    • First-in, first-out (FIFO): Jobs are queued and processed in the order of their arrival. The first job to arrive is processed first, followed sequentially by subsequent jobs.

    For details about the definitions, scheduling characteristics, and application scenarios of job scheduling policies, see Table 13.

    FIFO Concurrency Window (s)

    When FIFO is set as the job scheduling policy, you must also set the time window for concurrent job submission. Jobs submitted within the same time window compete randomly for resources, while jobs submitted in different time windows are allocated resources based on FIFO.

    Table 13 Supported resource scheduling policies

    Category

    Random

    First-in, first-out (FIFO)

    Definition

    The random scheduling policy randomly selects jobs for processing. In each scheduling cycle, a job is randomly selected for execution, rather than based on its submission order or priority.

    The FIFO scheduling policy queues and processes jobs in the order of their arrival. The first job to arrive is processed first, followed sequentially by subsequent jobs.

    Scheduling characteristics

    For jobs submitted to a general queue, all jobs running in the same time period compete for resources simultaneously, and their execution order cannot be guaranteed.

    For jobs submitted to a general queue:

    • Jobs in the same time window compete for resources simultaneously.
    • Jobs in different time windows request resources based on their submission time, ensuring that jobs are executed sequentially across different time windows.

    Applicable scenarios

    This mode is suitable for dynamic scheduling scenarios. Randomly selecting tasks prevents specific tasks from occupying resources for extended periods.

    For example, in interactive scenarios where multiple data engineers submit jobs concurrently, all engineers can track job execution progress.

    This mode is suitable for scenarios where multiple jobs are submitted as a single workload. It focuses on overall throughput and final completion time, rather than the completion time of individual jobs.

    Advantages

    Multiple jobs can run concurrently within the same time window, and their execution order is unpredictable.

    Jobs are executed in the order of their submission.

    Precautions

    Jobs that require extensive resources may keep failing to start due to resource insufficiency.

    A large job may occupy most resources, causing other jobs in the same queue to remain in the waiting state.

    Jobs in different time windows are executed based on their priorities.

  9. Configure Spark parameters.

    Specify Spark job submission properties in a key=value format.

    • Key: Enter the configuration parameter required by the Spark job, such as spark.sql.adaptive.enabled or spark.executor.memory.
    • Value: Enter the value for the corresponding key, such as true or 4g.

  10. Configure the storage settings for the endpoint.

    Table 14 Storage settings

    Parameter

    Description

    Temporary File Storage

    Select an existing parallel file system from the drop-down list. If no parallel file system is available, click Create OBS parallel file system to create one. For details, see Creating a Parallel File System.

    Parallel file systems are used to store job logs and temporary data. Files are not automatically deleted after a job completes. We recommend manually clearing resources in the parallel file system periodically or configuring an OBS lifecycle rule to delete outdated storage files automatically, preventing unnecessary storage usage and extra fees. For example, you can use a lifecycle rule to set the retention period (we recommend at least 7 days) by directory. For details, see Creating a Lifecycle Rule.

    Agency

    Configure an agency (such as an IAM agency) with read and write permissions for event logs, error logs, and temporary data.

    Select an existing agency from the drop-down list. If no agency is available, click Create Agency to create one. For details, see Creating a Custom Agency.

  11. Configure a job agency.

    Before using the Spark engine to run jobs, you must create the required agency on the IAM console and select it here. For details, see Creating a Custom Agency.

    Common scenarios for creating an agency: Enable AI DataLake to read from and write to OBS to transfer logs. Enable AI DataLake to access DEW to obtain data access credentials. Enable AI DataLake to access LakeFormation to obtain metadata.

  12. Configure the AOM monitoring integration as needed.

    Table 15 Parameters for AOM monitoring integration

    Parameter

    Description

    Monitor AOM

    Select Monitor AOM if needed.

    After AOM monitoring is enabled, application metrics are reported to AOM for centralized management. AOM enables real-time metric collection, custom monitoring, alarm configuration, and O&M data visualization, providing complete visibility into service status.

    Prometheus Instance

    Select a Prometheus instance from the drop-down list. If no instance is available, click Create Instance.

  13. Configure the network settings.

    If the resource allocation mode is set to On-demand and no network exists in the workspace, you must create a network and select it for the endpoint. Each workspace supports only one network. For details about creating a network, see Creating a Network.

  14. After completing the configuration, click Create Now. The system will begin creating the endpoint.

    Once the endpoint is created, you can view its details in the endpoint list. After the status changes to Running, you can submit jobs to the endpoint.

Follow-up Operations

After creating a Spark endpoint, you can perform the following operations as needed: