All Products
Search
Document Center

Resource Orchestration Service:Deploy a Spark cluster

Last Updated:Sep 15, 2026

You can use Resource Orchestration Service (ROS) public templates to create multiple ECS instances on your existing VPC, automatically install JDK, Hadoop, Scala, and Apache Spark, and quickly build a distributed Spark cluster for large-scale data processing, machine learning model training, and ETL batch processing scenarios.

Overview

This solution uses Alibaba Cloud Resource Orchestration Service (ROS) public templates to create multiple ECS instances on your existing VPC network, automatically installing JDK, Hadoop, Scala, and Apache Spark to quickly set up a distributed Spark cluster environment. This is suitable for large-scale data processing, machine learning model training, and ETL batch processing scenarios that require multi-node parallel computing.

What is an Apache Spark cluster

Apache Spark is a general-purpose computing engine designed for large-scale data processing. A Spark cluster consists of one Master node and multiple Worker nodes:

Node role

Responsibilities

Master

Cluster management node responsible for resource scheduling, task distribution, and cluster monitoring. Provides Web UI (port 8080) for users to view cluster status

Worker

Compute node that receives tasks assigned by Master and executes actual data processing. The number of Worker nodes can be dynamically adjusted by Auto Scaling Group

The sample template installs the following software versions:

Component

Description

Version

JDK

Java Development Kit, Java runtime environment

1.8.0

Hadoop

Distributed system infrastructure providing HDFS distributed storage

2.7.7

Scala

Programming language, Spark core framework is built on Scala

2.12.1

Spark

General big data computing engine supporting SQL queries, stream processing, and machine learning

2.1.0

Cluster edition vs. standalone edition

Comparison dimension

standalone edition

Cluster edition (this solution)

Number of nodes

1 ECS instance

1 Master + N Workers (3-10 instances)

Computing capability

Limited by single-machine resources

Multi-node parallel, horizontally scalable

Elastic scaling capability

None

Worker nodes managed by Auto Scaling Group, automatic scaling

Applicable scenarios

Development/testing, learning/verification

Production-level batch processing, large-scale data analysis

Feature: deployment on an existing VPC

Unlike other ROS deployment solutions, this template requires using your existing VPC, vSwitches, and security groups without creating new network resources. This design is suitable for:

  • Standardized network environments where you need to add Spark clusters to existing VPCs

  • Multiple projects sharing one VPC to avoid duplicate network resource creation

Resources created

No.

Resource name

ROS resource type

Quantity

Purpose

1

ECS cloud server instance

ALIYUN::ECS::Instance

1

Spark Master node, bound with EIP, running cluster management service

2

Auto Scaling group

ALIYUN::ESS::ScalingGroup

1

Manages Spark Worker nodes, automatically adds/removes instances based on requirements

3

RAM role

ALIYUN::RAM::Role

1

Issues short-term STS access tokens for secure authorization of Auto Scaling operations

4

CloudOps Orchestration Service (OOS) template

ALIYUN::OOS::Template

2

Creates lifecycle hooks to automatically execute initialization/cleanup scripts when Worker nodes are created/released

Results after deployment

After successful template execution, you will obtain:

  • One Spark Master ECS instance (bound with elastic public IP, providing cluster management Web UI)

  • Multiple Spark Worker ECS instances (managed by Auto Scaling Group, default 2 instances)

  • All nodes installed with JDK 1.8.0, Hadoop 2.7.7, Scala 2.12.1, Spark 2.1.0

  • Master and Worker nodes automatically configured for cluster networking

  • SparkWebSiteURL provided in stack Outputs for accessing Spark management console

Note

To access SparkWebSiteURL from the internet, add an inbound rule to your security group to allow port 8080. For more information, see Security groups.

Architecture diagram

                          User access
                            ↓
                     EIP → Master ECS (port 8080)
                        ↙      ↓      ↘
                Worker-1   Worker-2   Worker-N
                   ↑          ↑          ↑
              Auto Scaling Group management (ESS ScalingGroup)
                             ↑
                    OOS lifecycle hooks
              (automatically install Spark and join cluster during creation)

Prerequisites

Before using this template, confirm the following conditions:

  1. Account permissions: Your Alibaba Cloud account must have permissions to create resources for ECS, VPC, EIP, ESS (Auto Scaling), RAM, and OOS products.

  2. Existing network resources: You must have pre-created VPC, vSwitches, and security groups. For instructions on how to create them, see VPCs and vSwitches.

Deployment process

Deployment parameters

This template requires using your existing VPC network resources. Configure the following parameters during deployment:

Parameter name

Type

Description

Example value

Existing VPC Instance ID

String

VPC instance ID. For instructions on how to query it, see VPCs and vSwitches.

vpc-bp1m6fww66xbntjyc****

VSwitch Zone

String

Zone where the vSwitch resides

China (Hangzhou) Zone K

VSwitch ID

String

vSwitch ID. For instructions on how to query it, see VPCs and vSwitches.

vsw-bp183p93qs667muql****

Business security group ID

String

ECS security group ID. For instructions on how to query it, see Security groups.

sg-bp15ed6xe1yxeycg7o****

Instance specification

String

ECS instance specification (shared by the Master and Workers); 4 vCPUs and 8 GB of RAM or more is recommended.

ecs.e-c1m2.xlarge

Instance image ID

String

ECS instance image

centos_7

Instance password

String

The password for the ECS instance. The password must be 8 to 30 characters in length and contain uppercase letters, lowercase letters, digits, and special characters.

-

Disk type

String

System disk type:

  • cloud_efficiency (Ultra Cloud Disk)

  • cloud_ssd (Standard SSD)

For more information, see Disks

cloud_efficiency

System disk size

Number

The size of the system disk, in GB. Valid values: 20 to 500.

40

Number of instances

Number

Total number of Spark cluster nodes (including Master), range 3-10

3

Deployment methods

Method 1: Deploy via ROS public template (recommended)

  1. Log on to the ROS console.

  2. In the left-side navigation pane, choose Templates > Public Templates.

  3. Enter Spark in the search box to find the template: Spark Cluster Edition (Existing VPC)Click Create Stack.

  4. On the Configure Parameters page, enter a Stack Name and configure the parameters described in the preceding table.

  5. Click Next: Check and Confirm, and then click Create.

  6. In the left-side navigation pane, choose Resource stack. On the Stacks page, click the ID of the stack that you created, and then check the stack status on the Stack Information tab. Wait until the status changes to CREATE_COMPLETE.

  7. Click the Output tab of the stack to obtain SparkWebSiteURL.

  8. Access this URL in your browser to log on to the Spark management console and complete deployment.

Method 2: Deploy via ROS IaC Code

IaC Code 是面向云基础设施的 AI 基础设施即代码助手,可根据自然语言描述生成 ROS 模板并部署,使用方式参见IaC Code快速入门。

# Prompt
Deploy a Spark distributed cluster environment in an existing VPC.
Requirements:
1. Use existing VPC, vSwitches, and security groups (do not create new network resources).
2. Create 1 Master ECS node bound with elastic public IP.
3. Create Auto Scaling Group to manage Worker nodes, starting with 2 Workers.
4. Use CentOS 7 image for all nodes.
5. Automatically install JDK 1.8, Hadoop 2.7.7, Scala 2.12.1, Spark 2.1.0 via UserData scripts.
6. Automatically configure cluster networking between Master and Worker nodes.
7. Use OOS templates to create lifecycle hooks for automatic Spark installation and joining cluster when Workers scale out.
8. Open inbound port 8080 in security group.
9. Output `SparkWebSiteURL` in the stack Outputs.

Post-deployment operations

Verify Spark cluster

  1. Obtain SparkWebSiteURL from the Output tab of the stack.

  2. Access this URL in your browser to verify Spark management console.

  3. In Spark Web UI, verify Worker node count matches "Number of instances - 1"

  4. Connect to the Master node and verify:

    java -version                  # Check JDK version
    hadoop version                 # Check Hadoop version
    spark-shell --version          # Check Spark version
    
    # Check registered Worker nodes
    cat $SPARK_HOME/conf/slaves    # View list of registered Worker nodes

FAQ

Q1: Deployment fails with error "The specified InstanceType is not available"

Cause: The selected ECS instance type is unavailable in the specified zone.

Solution:

  • Change the zone where your vSwitch resides and redeploy

  • Check which instance types are available in the target zone on the ECS pricing page.

  • Spark clusters have high memory requirements. It is recommended to choose at least 4 vCPUs and 8 GB RAM for the Master node, and at least 2 vCPUs and 4 GB RAM for each Worker node.

Q2: Deployment succeeds but cannot access SparkWebSiteURL

Troubleshooting steps:

  1. Check security group: Ensure inbound rules allow TCP port 8080

  2. Check EIP association: Verify elastic IP is associated to Master ECS instance

  3. Connect to the Master and check service status:

    # Check Spark Master process
    ps -ef | grep spark
    # Check port 8080 listening
    netstat -tlnp | grep 8080
    # Manually start Spark cluster if not running
    $SPARK_HOME/sbin/start-all.sh
  4. View UserData execution logs: cat /var/log/messages | grep cloud-init

Q3: Worker nodes not registered to Master

Troubleshooting steps:

  1. View registered Worker list in Spark Web UI (port 8080)

  2. SSH login to Worker nodes and check if Spark processes are running

  3. Verify Worker nodes are in same VPC/vSwitch as Master node

  4. View Worker logs: cat $SPARK_HOME/logs/spark-*-worker-*.out

Related documentation