All Products
Search
Document Center

PolarDB:Ray applications

Last Updated:Jul 10, 2026

Traditionally, running artificial intelligence (AI), machine learning (ML), or large-scale data analytics tasks requires moving data from a database to an external compute cluster. This process complicates the system architecture and adds data transfer costs and latency. PolarDB for MySQL integrates Ray applications (also known as PolarDB for Ray), enabling you to run these complex tasks directly within the database using the Python ecosystem and the Ray distributed computing framework. This significantly improves the efficiency of data processing and AI inference while reducing costs.

Note

Ray applications are currently in invitational preview. To request access, please submit a ticket to have this feature enabled.

Features

Ray is an open source distributed computing framework designed for large-scale AI and Python applications. PolarDB deeply integrates this powerful computing capability with the database through built-in Ray applications. This means you can write and run Python code directly in the database. You can use a rich set of AI and ML libraries, such as Pandas, NumPy, Scikit-learn, and PyTorch, to process data stored in the database. You can perform model training, data pre-processing, and complex vector calculations all within the database without moving data between the database and an external computing environment.

Benefits

  • Serverless architecture: Provides stable nodes that never scale in to support regular business operations. Elastic nodes automatically scale based on real-time traffic, balancing stability and cost-effectiveness.

  • High availability: The Ray Head node supports high availability (HA) and disaster recovery to ensure cluster stability.

  • Secure and reliable:

    • Provides runtime isolation through secure containers to ensure a safe code execution environment.

    • Supports multi-tenant data isolation to prevent information leakage between tenants.

    • Ray Dashboard and Ray Job submissions support username/password and JSON Web Token (JWT) authentication to prevent unauthorized access.

  • Integrated metadata management: Resides in the same virtual private cloud (VPC) as the PolarDB cluster. Metadata processed by PolarDB for Ray can be stored directly in the PolarDB cluster, enabling data interaction without extra network configuration.

  • Unified resource pool: Provides a unified CPU resource pool and supports GPU Workers, offering flexible resource support for different types of computing tasks.

  • Storage service: Supports mounting PolarDB File System 2.0 High-Performance Edition storage. You can read and write data directly through the file interface.

  • Open source customization: PolarDB for Ray is a downstream version of open source Ray and is fully compatible with the open source Ray ecosystem. It also provides developers with customized optimizations and enhancements.

Scope

All product editions and series support creating Ray applications, except for Multi-master Cluster (Limitless) Edition.

Billing

  • Component fees: Ray applications are billed for their Head node and each Worker node. The fee is calculated based on the component specifications (CPU and memory) and subscription duration you select.

    Single Component Pricing

    Chinese mainland

    Specification

    CPU and memory

    Subscription (CNY/month)

    Pay-as-you-go (CNY/hour)

    polar.app.g2.medium

    2 cores 4 GB

    250

    0.52

    polar.app.g4.medium

    2 cores 8 GB

    270

    0.56

    polar.app.g8.medium

    2 cores 16 GB

    330

    0.6875

    polar.app.g2.large

    4 cores 8 GB

    475

    0.99

    polar.app.g4.large

    4 cores 16 GB

    630

    1.31

    polar.app.g8.large
    4 cores 32 GB

    660

    1.375

    polar.app.g2.xlarge

    8 cores 16 GB

    1,000

    2.08

    polar.app.g4.xlarge

    8 cores 32 GB

    1,240

    2.58

    polar.app.g8.xlarge
    8 cores 64 GB

    1,320

    2.75

    polar.app.g2.2xlarge

    16 cores 32 GB

    2,000

    4.17

    polar.app.g4.2xlarge

    16 cores 64 GB

    2,400

    5.00

    polar.app.g8.2xlarge
    16 cores 128 GB

    2,640

    5.5

    polar.app.g2.4xlarge

    32 cores 64 GB

    4,000

    8.32

    polar.app.g4.4xlarge

    32 cores 128 GB

    4,320

    8.96

    polar.app.g8.4xlarge
    32 cores 256 GB

    5,280

    11

    polar.app.g4.6xlarge

    48 cores 192 GB

    6,000

    12.48

    polar.app.g8.6xlarge

    48 cores 384 GB

    6,480

    13.44

    polar.app.g2.8xlarge

    64 cores 128 GB

    8,000

    16.64

    polar.app.g4.8xlarge

    64 cores 256 GB

    8,640

    17.92

    polar.app.g8.8xlarge

    64 cores 512 GB

    14,080

    29.32

    polar.app.g8.12xlarge

    88 cores 710 GB

    19,360

    40.31

    polar.app.g8.15xlarge

    120 cores 920 GB

    26,400

    54.98

    polar.app.g8.23xlarge

    180 cores 1440 GB

    39,600

    82.46

    China (Hong Kong)

    Node type

    vCPU / memory

    Subscription (CNY/month)

    Pay-as-you-go (CNY/hour)

    polar.app.g2.medium

    2 vCPUs 4 GB

    400

    0.832

    polar.app.g4.medium

    2 vCPUs 8 GB

    432

    0.896

    polar.app.g8.medium
    2 vCPUs 16 GB

    528

    1.1

    polar.app.g2.large

    4 vCPUs 8 GB

    760

    1.584

    polar.app.g4.large

    4 vCPUs 16 GB

    1,008

    2.096

    polar.app.g8.large
    4 vCPUs 32 GB

    1,056

    2.2

    polar.app.g2.xlarge

    8 vCPUs 16 GB

    1,600

    3.33

    polar.app.g4.xlarge

    8 vCPUs 32 GB

    1,984

    4.13

    polar.app.g8.xlarge
    8 vCPUs 64 GB

    2,112

    4.4

    polar.app.g2.2xlarge

    16 vCPUs 32 GB

    3,200

    6.67

    polar.app.g4.2xlarge

    16 vCPUs 64 GB

    3,840

    8

    polar.app.g8.2xlarge
    16 vCPUs 128 GB

    4,224

    8.8

    polar.app.g2.4xlarge

    32 vCPUs 64 GB

    6,400

    13.31

    polar.app.g4.4xlarge

    32 vCPUs 128 GB

    6,912

    14.34

    polar.app.g8.4xlarge
    32 vCPUs 256 GB

    8,448

    17.6

    polar.app.g4.6xlarge

    48 vCPUs 192 GB

    9,600

    19.97

    polar.app.g8.6xlarge

    48 vCPUs 384 GB

    10,368

    21.5

    polar.app.g2.8xlarge

    64 vCPUs 128 GB

    12,800

    26.62

    polar.app.g4.8xlarge

    64 vCPUs 256 GB

    13,824

    28.67

    polar.app.g8.8xlarge

    64 vCPUs 512 GB

    22,528

    46.91

    polar.app.g8.12xlarge

    88 vCPUs 710 GB

    30,976

    64.5

    polar.app.g8.15xlarge

    120 vCPUs 920 GB

    42,240

    87.97

    polar.app.g8.23xlarge

    180 vCPUs 1800 GB

    63,360

    131.94

    Japan (Tokyo)

    Node type

    vCPU / memory

    Subscription (CNY/month)

    Pay-as-you-go (CNY/hour)

    polar.app.g2.medium

    2 vCPUs 4 GB

    400

    0.832

    polar.app.g4.medium

    2 vCPUs 8 GB

    432

    0.896

    polar.app.g8.medium
    2 vCPUs 16 GB

    528

    1.1

    polar.app.g2.large

    4 vCPUs 8 GB

    760

    1.584

    polar.app.g4.large

    4 vCPUs 16 GB

    1,008

    2.096

    polar.app.g8.large
    4 vCPUs 32 GB

    1,056

    2.2

    polar.app.g2.xlarge

    8 vCPUs 16 GB

    1,600

    3.33

    polar.app.g4.xlarge

    8 vCPUs 32 GB

    1,984

    4.13

    polar.app.g8.xlarge
    8 vCPUs 64 GB

    2,112

    4.4

    polar.app.g2.2xlarge

    16 vCPUs 32 GB

    3,200

    6.67

    polar.app.g4.2xlarge

    16 vCPUs 64 GB

    3,840

    8

    polar.app.g8.2xlarge
    16 vCPUs 128 GB

    4,224

    8.8

    polar.app.g2.4xlarge

    32 vCPUs 64 GB

    6,400

    13.31

    polar.app.g4.4xlarge

    32 vCPUs 128 GB

    6,912

    14.34

    polar.app.g8.4xlarge
    32 vCPUs 256 GB

    8,448

    17.6

    polar.app.g4.6xlarge

    48 vCPUs 192 GB

    9,600

    19.97

    polar.app.g8.6xlarge

    48 vCPUs 384 GB

    10,368

    21.5

    polar.app.g2.8xlarge

    64 vCPUs 128 GB

    12,800

    26.62

    polar.app.g4.8xlarge

    64 vCPUs 256 GB

    13,824

    28.67

    polar.app.g8.8xlarge

    64 vCPUs 512 GB

    22,528

    46.91

    polar.app.g8.12xlarge

    88 vCPUs 710 GB

    30,976

    64.5

    polar.app.g8.15xlarge

    120 vCPUs 920 GB

    42,240

    87.97

    polar.app.g8.23xlarge

    180 vCPUs 1800 GB

    63,360

    131.94

    Korea (Seoul)

    Node type

    vCPU / memory

    Subscription (CNY/month)

    Pay-as-you-go (CNY/hour)

    polar.app.g2.medium

    2 vCPUs 4 GB

    400

    0.832

    polar.app.g4.medium

    2 vCPUs 8 GB

    432

    0.896

    polar.app.g8.medium
    2 vCPUs 16 GB

    528

    1.1

    polar.app.g2.large

    4 vCPUs 8 GB

    760

    1.584

    polar.app.g4.large

    4 vCPUs 16 GB

    1,008

    2.096

    polar.app.g8.large
    4 vCPUs 32 GB

    1,056

    2.2

    polar.app.g2.xlarge

    8 vCPUs 16 GB

    1,600

    3.33

    polar.app.g4.xlarge

    8 vCPUs 32 GB

    1,984

    4.13

    polar.app.g8.xlarge
    8 vCPUs 64 GB

    2,112

    4.4

    polar.app.g2.2xlarge

    16 vCPUs 32 GB

    3,200

    6.67

    polar.app.g4.2xlarge

    16 vCPUs 64 GB

    3,840

    8

    polar.app.g8.2xlarge
    16 vCPUs 128 GB

    4,224

    8.8

    polar.app.g2.4xlarge

    32 vCPUs 64 GB

    6,400

    13.31

    polar.app.g4.4xlarge

    32 vCPUs 128 GB

    6,912

    14.34

    polar.app.g8.4xlarge
    32 vCPUs 256 GB

    8,448

    17.6

    polar.app.g4.6xlarge

    48 vCPUs 192 GB

    9,600

    19.97

    polar.app.g8.6xlarge

    48 vCPUs 384 GB

    10,368

    21.5

    polar.app.g2.8xlarge

    64 vCPUs 128 GB

    12,800

    26.62

    polar.app.g4.8xlarge

    64 vCPUs 256 GB

    13,824

    28.67

    polar.app.g8.8xlarge

    64 vCPUs 512 GB

    22,528

    46.91

    polar.app.g8.12xlarge

    88 vCPUs 710 GB

    30,976

    64.5

    polar.app.g8.15xlarge

    120 vCPUs 920 GB

    42,240

    87.97

    polar.app.g8.23xlarge

    180 vCPUs 1800 GB

    63,360

    131.94

    Singapore

    Node type

    vCPU / memory

    Subscription (CNY/month)

    Pay-as-you-go (CNY/hour)

    polar.app.g2.medium

    2 vCPUs 4 GB

    400

    0.832

    polar.app.g4.medium

    2 vCPUs 8 GB

    432

    0.896

    polar.app.g8.medium
    2 vCPUs 16 GB

    528

    1.1

    polar.app.g2.large

    4 vCPUs 8 GB

    760

    1.584

    polar.app.g4.large

    4 vCPUs 16 GB

    1,008

    2.096

    polar.app.g8.large
    4 vCPUs 32 GB

    1,056

    2.2

    polar.app.g2.xlarge

    8 vCPUs 16 GB

    1,600

    3.33

    polar.app.g4.xlarge

    8 vCPUs 32 GB

    1,984

    4.13

    polar.app.g8.xlarge
    8 vCPUs 64 GB

    2,112

    4.4

    polar.app.g2.2xlarge

    16 vCPUs 32 GB

    3,200

    6.67

    polar.app.g4.2xlarge

    16 vCPUs 64 GB

    3,840

    8

    polar.app.g8.2xlarge
    16 vCPUs 128 GB

    4,224

    8.8

    polar.app.g2.4xlarge

    32 vCPUs 64 GB

    6,400

    13.31

    polar.app.g4.4xlarge

    32 vCPUs 128 GB

    6,912

    14.34

    polar.app.g8.4xlarge
    32 vCPUs 256 GB

    8,448

    17.6

    polar.app.g4.6xlarge

    48 vCPUs 192 GB

    9,600

    19.97

    polar.app.g8.6xlarge

    48 vCPUs 384 GB

    10,368

    21.5

    polar.app.g2.8xlarge

    64 vCPUs 128 GB

    12,800

    26.62

    polar.app.g4.8xlarge

    64 vCPUs 256 GB

    13,824

    28.67

    polar.app.g8.8xlarge

    64 vCPUs 512 GB

    22,528

    46.91

    polar.app.g8.12xlarge

    88 vCPUs 710 GB

    30,976

    64.5

    polar.app.g8.15xlarge

    120 vCPUs 920 GB

    42,240

    87.97

    polar.app.g8.23xlarge

    180 vCPUs 1800 GB

    63,360

    131.94

    Malaysia (Kuala Lumpur)

    Node type

    vCPU / memory

    Subscription (CNY/month)

    Pay-as-you-go (CNY/hour)

    polar.app.g2.medium

    2 vCPUs 4 GB

    400

    0.832

    polar.app.g4.medium

    2 vCPUs 8 GB

    432

    0.896

    polar.app.g8.medium
    2 vCPUs 16 GB

    528

    1.1

    polar.app.g2.large

    4 vCPUs 8 GB

    760

    1.584

    polar.app.g4.large

    4 vCPUs 16 GB

    1,008

    2.096

    polar.app.g8.large
    4 vCPUs 32 GB

    1,056

    2.2

    polar.app.g2.xlarge

    8 vCPUs 16 GB

    1,600

    3.33

    polar.app.g4.xlarge

    8 vCPUs 32 GB

    1,984

    4.13

    polar.app.g8.xlarge
    8 vCPUs 64 GB

    2,112

    4.4

    polar.app.g2.2xlarge

    16 vCPUs 32 GB

    3,200

    6.67

    polar.app.g4.2xlarge

    16 vCPUs 64 GB

    3,840

    8

    polar.app.g8.2xlarge
    16 vCPUs 128 GB

    4,224

    8.8

    polar.app.g2.4xlarge

    32 vCPUs 64 GB

    6,400

    13.31

    polar.app.g4.4xlarge

    32 vCPUs 128 GB

    6,912

    14.34

    polar.app.g8.4xlarge
    32 vCPUs 256 GB

    8,448

    17.6

    polar.app.g4.6xlarge

    48 vCPUs 192 GB

    9,600

    19.97

    polar.app.g8.6xlarge

    48 vCPUs 384 GB

    10,368

    21.5

    polar.app.g2.8xlarge

    64 vCPUs 128 GB

    12,800

    26.62

    polar.app.g4.8xlarge

    64 vCPUs 256 GB

    13,824

    28.67

    polar.app.g8.8xlarge

    64 vCPUs 512 GB

    22,528

    46.91

    polar.app.g8.12xlarge

    88 vCPUs 710 GB

    30,976

    64.5

    polar.app.g8.15xlarge

    120 vCPUs 920 GB

    42,240

    87.97

    polar.app.g8.23xlarge

    180 vCPUs 1800 GB

    63,360

    131.94

    Indonesia (Jakarta)

    Specification code

    CPU and memory

    Subscription (USD/month)

    Pay-as-you-go (USD/hour)

    polar.app.g2.medium

    2 cores 4 GB

    350

    0.728

    polar.app.g4.medium

    2 cores 8 GB

    378

    0.784

    polar.app.g8.medium
    2 cores 16 GB

    462

    0.9625

    polar.app.g2.large

    4 cores 8 GB

    665

    1.386

    polar.app.g4.large

    4 cores 16 GB

    882

    1.834

    polar.app.g8.large
    4 cores 32 GB

    924

    1.925

    polar.app.g2.xlarge

    8 cores 16 GB

    1,400

    2.910

    polar.app.g4.xlarge

    8 cores 32 GB

    1,736

    3.610

    polar.app.g8.xlarge
    8 cores 64 GB

    1,848

    3.850

    polar.app.g2.2xlarge

    16 cores 32 GB

    2,800

    5.840

    polar.app.g4.2xlarge

    16 cores 64 GB

    3,360

    7.000

    polar.app.g8.2xlarge
    16 cores 128 GB

    3,696

    7.700

    polar.app.g2.4xlarge

    32 cores 64 GB

    5,600

    11.65

    polar.app.g4.4xlarge

    32 cores 128 GB

    6,048

    12.54

    polar.app.g8.4xlarge
    32 cores 256 GB

    7,392

    15.400

    polar.app.g4.6xlarge

    48 cores 192 GB

    8,400

    17.47

    polar.app.g8.6xlarge

    48 cores 384 GB

    9,072

    18.82

    polar.app.g2.8xlarge

    64 cores 128 GB

    11,200

    23.30

    polar.app.g4.8xlarge

    64 cores 256 GB

    12,096

    25.09

    polar.app.g8.8xlarge

    64 cores 512 GB

    19,712

    41.05

    polar.app.g8.12xlarge

    88 cores 710 GB

    27,104

    56.43

    polar.app.g8.15xlarge

    120 cores 920 GB

    36,960

    76.97

    polar.app.g8.23xlarge

    180 cores 1800 GB

    55,440

    115.44

    Philippines (Manila)

    Specification code

    CPU and memory

    Subscription (USD/month)

    Pay-as-you-go (USD/hour)

    polar.app.g2.medium

    2 cores 4 GB

    350

    0.728

    polar.app.g4.medium

    2 cores 8 GB

    378

    0.784

    polar.app.g8.medium
    2 cores 16 GB

    462

    0.9625

    polar.app.g2.large

    4 cores 8 GB

    665

    1.386

    polar.app.g4.large

    4 cores 16 GB

    882

    1.834

    polar.app.g8.large
    4 cores 32 GB

    924

    1.925

    polar.app.g2.xlarge

    8 cores 16 GB

    1,400

    2.910

    polar.app.g4.xlarge

    8 cores 32 GB

    1,736

    3.610

    polar.app.g8.xlarge
    8 cores 64 GB

    1,848

    3.850

    polar.app.g2.2xlarge

    16 cores 32 GB

    2,800

    5.840

    polar.app.g4.2xlarge

    16 cores 64 GB

    3,360

    7.000

    polar.app.g8.2xlarge
    16 cores 128 GB

    3,696

    7.700

    polar.app.g2.4xlarge

    32 cores 64 GB

    5,600

    11.65

    polar.app.g4.4xlarge

    32 cores 128 GB

    6,048

    12.54

    polar.app.g8.4xlarge
    32 cores 256 GB

    7,392

    15.400

    polar.app.g4.6xlarge

    48 cores 192 GB

    8,400

    17.47

    polar.app.g8.6xlarge

    48 cores 384 GB

    9,072

    18.82

    polar.app.g2.8xlarge

    64 cores 128 GB

    11,200

    23.30

    polar.app.g4.8xlarge

    64 cores 256 GB

    12,096

    25.09

    polar.app.g8.8xlarge

    64 cores 512 GB

    19,712

    41.05

    polar.app.g8.12xlarge

    88 cores 710 GB

    27,104

    56.43

    polar.app.g8.15xlarge

    120 cores 920 GB

    36,960

    76.97

    polar.app.g8.23xlarge

    180 cores 1800 GB

    55,440

    115.44

    Thailand (Bangkok)

    Specification code

    CPU and memory

    Subscription (USD/month)

    Pay-as-you-go (USD/hour)

    polar.app.g2.medium

    2 cores 4 GB

    350

    0.728

    polar.app.g4.medium

    2 cores 8 GB

    378

    0.784

    polar.app.g8.medium
    2 cores 16 GB

    462

    0.9625

    polar.app.g2.large

    4 cores 8 GB

    665

    1.386

    polar.app.g4.large

    4 cores 16 GB

    882

    1.834

    polar.app.g8.large
    4 cores 32 GB

    924

    1.925

    polar.app.g2.xlarge

    8 cores 16 GB

    1,400

    2.910

    polar.app.g4.xlarge

    8 cores 32 GB

    1,736

    3.610

    polar.app.g8.xlarge
    8 cores 64 GB

    1,848

    3.850

    polar.app.g2.2xlarge

    16 cores 32 GB

    2,800

    5.840

    polar.app.g4.2xlarge

    16 cores 64 GB

    3,360

    7.000

    polar.app.g8.2xlarge
    16 cores 128 GB

    3,696

    7.700

    polar.app.g2.4xlarge

    32 cores 64 GB

    5,600

    11.65

    polar.app.g4.4xlarge

    32 cores 128 GB

    6,048

    12.54

    polar.app.g8.4xlarge
    32 cores 256 GB

    7,392

    15.400

    polar.app.g4.6xlarge

    48 cores 192 GB

    8,400

    17.47

    polar.app.g8.6xlarge

    48 cores 384 GB

    9,072

    18.82

    polar.app.g2.8xlarge

    64 cores 128 GB

    11,200

    23.30

    polar.app.g4.8xlarge

    64 cores 256 GB

    12,096

    25.09

    polar.app.g8.8xlarge

    64 cores 512 GB

    19,712

    41.05

    polar.app.g8.12xlarge

    88 cores 710 GB

    27,104

    56.43

    polar.app.g8.15xlarge

    120 cores 920 GB

    36,960

    76.97

    polar.app.g8.23xlarge

    180 cores 1800 GB

    55,440

    115.44

    Germany (Frankfurt)

    Specification code

    CPU and memory

    Subscription (USD/month)

    Pay-as-you-go (USD/hour)

    polar.app.g2.medium

    2 cores 4 GB

    350

    0.728

    polar.app.g4.medium

    2 cores 8 GB

    378

    0.784

    polar.app.g8.medium
    2 cores 16 GB

    462

    0.9625

    polar.app.g2.large

    4 cores 8 GB

    665

    1.386

    polar.app.g4.large

    4 cores 16 GB

    882

    1.834

    polar.app.g8.large
    4 cores 32 GB

    924

    1.925

    polar.app.g2.xlarge

    8 cores 16 GB

    1,400

    2.910

    polar.app.g4.xlarge

    8 cores 32 GB

    1,736

    3.610

    polar.app.g8.xlarge
    8 cores 64 GB

    1,848

    3.850

    polar.app.g2.2xlarge

    16 cores 32 GB

    2,800

    5.840

    polar.app.g4.2xlarge

    16 cores 64 GB

    3,360

    7.000

    polar.app.g8.2xlarge
    16 cores 128 GB

    3,696

    7.700

    polar.app.g2.4xlarge

    32 cores 64 GB

    5,600

    11.65

    polar.app.g4.4xlarge

    32 cores 128 GB

    6,048

    12.54

    polar.app.g8.4xlarge
    32 cores 256 GB

    7,392

    15.400

    polar.app.g4.6xlarge

    48 cores 192 GB

    8,400

    17.47

    polar.app.g8.6xlarge

    48 cores 384 GB

    9,072

    18.82

    polar.app.g2.8xlarge

    64 cores 128 GB

    11,200

    23.30

    polar.app.g4.8xlarge

    64 cores 256 GB

    12,096

    25.09

    polar.app.g8.8xlarge

    64 cores 512 GB

    19,712

    41.05

    polar.app.g8.12xlarge

    88 cores 710 GB

    27,104

    56.43

    polar.app.g8.15xlarge

    120 cores 920 GB

    36,960

    76.97

    polar.app.g8.23xlarge

    180 cores 1800 GB

    55,440

    115.44

    UK (London)

    Specification code

    CPU and memory

    Subscription (USD/month)

    Pay-as-you-go (USD/hour)

    polar.app.g2.medium

    2 cores 4 GB

    350

    0.728

    polar.app.g4.medium

    2 cores 8 GB

    378

    0.784

    polar.app.g8.medium
    2 cores 16 GB

    462

    0.9625

    polar.app.g2.large

    4 cores 8 GB

    665

    1.386

    polar.app.g4.large

    4 cores 16 GB

    882

    1.834

    polar.app.g8.large
    4 cores 32 GB

    924

    1.925

    polar.app.g2.xlarge

    8 cores 16 GB

    1,400

    2.910

    polar.app.g4.xlarge

    8 cores 32 GB

    1,736

    3.610

    polar.app.g8.xlarge
    8 cores 64 GB

    1,848

    3.850

    polar.app.g2.2xlarge

    16 cores 32 GB

    2,800

    5.840

    polar.app.g4.2xlarge

    16 cores 64 GB

    3,360

    7.000

    polar.app.g8.2xlarge
    16 cores 128 GB

    3,696

    7.700

    polar.app.g2.4xlarge

    32 cores 64 GB

    5,600

    11.65

    polar.app.g4.4xlarge

    32 cores 128 GB

    6,048

    12.54

    polar.app.g8.4xlarge
    32 cores 256 GB

    7,392

    15.400

    polar.app.g4.6xlarge

    48 cores 192 GB

    8,400

    17.47

    polar.app.g8.6xlarge

    48 cores 384 GB

    9,072

    18.82

    polar.app.g2.8xlarge

    64 cores 128 GB

    11,200

    23.30

    polar.app.g4.8xlarge

    64 cores 256 GB

    12,096

    25.09

    polar.app.g8.8xlarge

    64 cores 512 GB

    19,712

    41.05

    polar.app.g8.12xlarge

    88 cores 710 GB

    27,104

    56.43

    polar.app.g8.15xlarge

    120 cores 920 GB

    36,960

    76.97

    polar.app.g8.23xlarge

    180 cores 1800 GB

    55,440

    115.44

    US (Silicon Valley)

    Instance type

    CPU and memory

    Subscription (USD/month)

    Pay-as-you-go (USD/hour)

    polar.app.g1.tiny

    1 core 1 GB

    13.2

    0.024

    polar.app.g2.small

    1 core 2 GB

    21.6

    0.048

    polar.app.g2.medium

    2 cores 4 GB

    43.2

    0.096

    polar.app.g4.medium

    2 cores 8 GB

    324

    0.672

    polar.app.g8.medium
    2 cores 16 GB

    396

    0.825

    polar.app.g2.large

    4 cores 8 GB

    570

    1.188

    polar.app.g4.large

    4 cores 16 GB

    756

    1.572

    polar.app.g8.large
    4 cores 32 GB

    792

    1.65

    polar.app.g2.xlarge

    8 cores 16 GB

    1,200

    2.50

    polar.app.g4.xlarge

    8 cores 32 GB

    1,488

    3.10

    polar.app.g8.xlarge
    8 cores 64 GB

    1,584

    3.30

    polar.app.g2.2xlarge

    16 cores 32 GB

    2,400

    5.00

    polar.app.g4.2xlarge

    16 cores 64 GB

    2,880

    6.00

    polar.app.g8.2xlarge
    16 cores 128 GB

    3,168

    6.60

    polar.app.g2.4xlarge

    32 cores 64 GB

    4,800

    9.98

    polar.app.g4.4xlarge

    32 cores 128 GB

    5,184

    10.75

    polar.app.g8.4xlarge
    32 cores 256 GB

    6,336

    13.20

    polar.app.g4.6xlarge

    48 cores 192 GB

    7,200

    14.98

    polar.app.g8.6xlarge

    48 cores 384 GB

    7,776

    16.13

    polar.app.g2.8xlarge

    64 cores 128 GB

    9,600

    19.97

    polar.app.g4.8xlarge

    64 cores 256 GB

    10,368

    21.50

    polar.app.g8.8xlarge

    64 cores 512 GB

    16,896

    35.18

    polar.app.g8.12xlarge

    88 cores 710 GB

    23,232

    48.37

    polar.app.g8.15xlarge

    120 cores 920 GB

    31,680

    65.98

    polar.app.g8.23xlarge

    180 cores 1800 GB

    47,520

    98.95

    US (Virginia)

    Instance type

    CPU and memory

    Subscription (USD/month)

    Pay-as-you-go (USD/hour)

    polar.app.g1.tiny

    1 core 1 GB

    13.2

    0.024

    polar.app.g2.small

    1 core 2 GB

    21.6

    0.048

    polar.app.g2.medium

    2 cores 4 GB

    43.2

    0.096

    polar.app.g4.medium

    2 cores 8 GB

    324

    0.672

    polar.app.g8.medium
    2 cores 16 GB

    396

    0.825

    polar.app.g2.large

    4 cores 8 GB

    570

    1.188

    polar.app.g4.large

    4 cores 16 GB

    756

    1.572

    polar.app.g8.large
    4 cores 32 GB

    792

    1.65

    polar.app.g2.xlarge

    8 cores 16 GB

    1,200

    2.50

    polar.app.g4.xlarge

    8 cores 32 GB

    1,488

    3.10

    polar.app.g8.xlarge
    8 cores 64 GB

    1,584

    3.30

    polar.app.g2.2xlarge

    16 cores 32 GB

    2,400

    5.00

    polar.app.g4.2xlarge

    16 cores 64 GB

    2,880

    6.00

    polar.app.g8.2xlarge
    16 cores 128 GB

    3,168

    6.60

    polar.app.g2.4xlarge

    32 cores 64 GB

    4,800

    9.98

    polar.app.g4.4xlarge

    32 cores 128 GB

    5,184

    10.75

    polar.app.g8.4xlarge
    32 cores 256 GB

    6,336

    13.20

    polar.app.g4.6xlarge

    48 cores 192 GB

    7,200

    14.98

    polar.app.g8.6xlarge

    48 cores 384 GB

    7,776

    16.13

    polar.app.g2.8xlarge

    64 cores 128 GB

    9,600

    19.97

    polar.app.g4.8xlarge

    64 cores 256 GB

    10,368

    21.50

    polar.app.g8.8xlarge

    64 cores 512 GB

    16,896

    35.18

    polar.app.g8.12xlarge

    88 cores 710 GB

    23,232

    48.37

    polar.app.g8.15xlarge

    120 cores 920 GB

    31,680

    65.98

    polar.app.g8.23xlarge

    180 cores 1800 GB

    47,520

    98.95

  • Storage fee: Data and files generated by Ray applications do not incur extra charges. However, data written by a Ray Job to a PolarDB for MySQL cluster or PolarDB file system storage is subject to corresponding storage space fees.

  • Traffic and bandwidth: No fees are charged.

Quick start

1. (Optional) Create a PolarDB for MySQL cluster

If you do not have a cluster that meets the availability requirements, or if your existing cluster cannot be modified for business reasons, create another cluster in the PolarDB console to try out Ray applications.

2. Create a Ray application

  1. Log on to the PolarDB console. On the cluster details page, click AI Capabilities > AI Applications in the navigation pane on the left. Then, click Create AI Application.

  2. On the application purchase page, select the appropriate configurations as needed:

    Configuration item

    Description

    Billing Method

    • Subscription: An upfront payment mode. When you create an application, you select resources with defined specifications and pay for the application in advance. The longer the subscription duration, the larger the discount. This mode is suitable for scenarios with stable, long-term business requirements.

    • Pay-as-you-go: A pay-as-you-go billing method. When you create an application, you select resources with defined specifications but do not need to pay in advance. This mode bills you based on your actual usage duration and is suitable for scenarios with flexible business requirements.

    Engine

    Fixed at PolarDB.

    Region

    Select the geographic location where the application is located.

    Note
    • You cannot change the region after you purchase the application.

    • The application must be in the same region as the PolarDB for MySQL cluster. Therefore, select the same region as the cluster.

    • We recommend that you create the application and the ECS instances that need to connect to it in the same region. Otherwise, they cannot communicate over the internal network (private network) and must use the public network (Internet), which prevents optimal performance.

    Architecture

    Fixed at AI Application.

    Ecosystem

    For the database ecosystem, select MySQL.

    Source PolarDB Cluster

    Select the PolarDB cluster for which you want to create the application.

    AI Application

    The AI application type. Select Ray.

    Component Set

    A Ray application can contain one Head component and multiple Worker components, which form the application's component set.

    • Head Component: A managed Ray Head node.

    • CPU Worker Component: A managed Ray Worker node.

    Note
    • The minimum and maximum number of Head Components can only be 1.

    • The minimum number of CPU Worker Components can be set to 0. The minimum number is the number of stable Ray Worker nodes. The difference between the maximum and minimum numbers determines the maximum number of Worker nodes for the Ray application in its serverless form.

    • The GPU Worker component is currently in invitational preview. To request access, please submit a ticket to have this feature enabled.

    AI Application Name

    You can enter a custom name for the application.

    Note

    The name cannot start with http:// or https:// and must be 2 to 256 characters in length.

    Storage Type

    Fixed at AI Cache.

    AI Cache Instance ID/Name

    (Optional) You can attach a separate AI Cache instance to the Ray application.

    Note
    • AI Cache is currently in invitational preview. To request access, please submit a ticket to have this feature enabled.

    • Only High-Performance Edition AI Cache instances are supported.

    Network Type

    Fixed at VPC.

    VPC Network

    Automatically populated with the VPC of the source PolarDB cluster. No manual entry is required.

    Zone and vSwitch

    Configure the vSwitch for the VPC. We recommend selecting the same vSwitch as the primary zone of the PolarDB for MySQL cluster for optimal network performance.

    Note

    If the existing vSwitches do not meet your requirements, you can create a vSwitch.

    Security Group

    Configure the security group for the application.

    Quantity

    Select the number of applications to purchase.

    Note

    This is configurable only when Billing Method is set to Subscription.

    Duration

    Select the subscription duration for the application.

    Note

    This is configurable only when Billing Method is set to Subscription.

    Auto-renewal

    Configure whether to enable auto-renewal. We recommend enabling auto-renewal to avoid business interruptions caused by forgetting to renew.

    Note

    This is configurable only when Billing Method is set to Subscription.

  3. After the purchase is successful, return to the AI Applications page of the cluster to view the newly created application.

    Note

    The system takes 3 to 5 minutes to create the application. Please wait.

3. Connect to the Ray application

  • Configure the application whitelist: On the AI Applications list page, click your application ID to go to the application details page. On the Whitelist tab, Add Whitelist, Select Security Groups, or Configure an existing whitelist group.

    Note
    • The application whitelist is independent of the cluster whitelist and must be configured separately.

    • If your ECS instance needs to access the application, view the IP address of the ECS instance on the ECS Instance Details page and add it to the IP whitelist.

      • If your ECS instance and the application are in the same VPC, you can add the private IP address of the ECS instance or its VPC CIDR block.

      • If your ECS instance and the application are not in the same VPC, you can add the public IP address of the ECS instance or the security group to which the ECS instance belongs.

    • If your local server, computer, or another cloud server needs to access the application, add its public IP address to the IP whitelist.

  • Obtain the endpoint: On the AI Applications list page, click your application ID to go to the application details page. On the Topology tab, view the public endpoint or private endpoint.

    Note
    • You must apply for a public endpoint separately. Click the Apply button to submit a request.

    • The public endpoint provides only an IP address and port, not a domain name. If you need a domain name, you can attach one yourself.

  • Obtain the application configuration information: On the AI Applications list page, click your application ID to go to the application details page. On the Configuration tab, view the relevant configuration information.

4. Develop the application

You can access the application directly over the Internet. On the AI Applications list page, click Develop Application to go to the public endpoint of the Ray Dashboard. Alternatively, enter the public IP address and port of the application in your browser's address bar to access the Ray Dashboard.

Note

5. Submit a Ray Job using an SDK

You can use the Ray software development kit (SDK) to programmatically submit a Ray Job.

  1. Prepare the environment

    Note

    First, install the Python 3 environment on your local machine.

    Install the Ray SDK:

    pip install ray    
  2. Prepare the code files
    In your working directory, create two Ray application scripts. One is for business processing and the other is for submitting the job. The following is an example of the working directory structure:

    - working-dir/
     - script.py # Your Ray business logic script
     - ray_job_submit.py # The script used to submit the job

    The following are example scripts:

    script.py

    import ray
    import time
    
    
    @ray.remote
    def retrieve_task(item, db):
        time.sleep(item / 10.)
        return item, db[item]
    
    
    if __name__ == "__main__":
        database = [
            "Learning", "Ray", "Flexible", "Distributed", "Python", "for",
            "Machine", "Learning"
        ]
        ray.init()
        db_object_ref = ray.put(database)
        retrieve_refs = [
            retrieve_task.remote(item, db_object_ref) for item in [0, 2, 4, 6]
        ]
        result = [print(data) for data in ray.get(retrieve_refs)]
    

    ray_job_submit.py

    import os
    import json
    import base64
    import hmac
    import hashlib
    import requests
    
    from datetime import timezone, timedelta, datetime
    from requests.auth import HTTPBasicAuth
    from ray.job_submission import JobSubmissionClient
    
    # Your Ray Dashboard address
    address = os.getenv("RAY_DASHBOARD_ADDRESS")
    
    # You can directly use 'secret.jwt.anonKey' for authentication
    token = os.getenv("RAY_ANON_TOKEN")
    
    # You can also use 'secret.jwt.secret' to generate a JWT
    secret = os.getenv("RAY_JWT_SECRET")
    header = {"alg": "HS256", "typ": "JWT"}
    
    now = datetime.now(tz=timezone.utc)
    payload = {
      "sub": "anon",
      "iat": int(now.timestamp()),
      "exp": int((now + timedelta(hours=12)).timestamp()),
      "iss": "ray-dashboard",
      "aud": "ray-dashboard-client"
    }
    
    header_encoded = base64.urlsafe_b64encode(
      json.dumps(header,
                 separators=(',', ':')).encode()).decode('utf-8').rstrip('=')
    payload_encoded = base64.urlsafe_b64encode(
      json.dumps(payload,
                 separators=(',', ':')).encode()).decode('utf-8').rstrip('=')
    
    message = f"{header_encoded}.{payload_encoded}"
    signature = hmac.new(secret.encode(), message.encode(),
                         hashlib.sha256).digest()
    signature_encoded = base64.urlsafe_b64encode(signature).decode('utf-8').rstrip(
      '=')
    token = f"{message}.{signature_encoded}"
    
    # You can also obtain a JWT for authentication by sending a POST request to /api/auth/token. You must provide a username and password.
    username = os.getenv('RAY_USERNAME')
    password = os.getenv('RAY_PASSWORD')
    response = requests.post(f'{address}/api/auth/token',
                             auth=HTTPBasicAuth(username, password),
                             timeout=5)
    
    if response.status_code == 200:
      token_data = response.json()
      token = token_data['access_token']
    else:
      print(f"❌ Failed to get JWT: {response.status_code}")
    
    client = JobSubmissionClient(address,
                                 headers={"Authorization": f"Bearer {token}"})
    
    job_id = client.submit_job(
      # Entrypoint shell command to execute
      entrypoint="python script.py",
      # Path to the local directory that contains the script.py file
      runtime_env={"working_dir": "./"})
    
    print(job_id)
  3. Configure and run the script

    1. On the Ray Application Configuration page, you can view the following information and then set it as environment variables or replace it in the submit_job.py script.

      Variable

      Corresponding configuration item

      Example value

      RAY_DASHBOARD_ADDRESS

      The endpoint of the Ray application. Select the public or private endpoint based on your environment.

      http://123.xxx.xxx.xxx:8265

      RAY_ANON_TOKEN

      secret.jwt.anonKey

      eyJhbGciOi...

      RAY_JWT_SECRET

      secret.jwt.secret

      tNhVxysSRD...

      RAY_USERNAME

      secret.dashboard.username

      admin

      RAY_PASSWORD

      secret.dashboard.password

      UTLof$rMVM...

    2. In your working directory, run the submission script:

      python ray_job_submit.py
    3. After the script is successfully run, you can log on to the Ray Dashboard and view the running status of the submitted job on the Jobs page.image