Skip to content

Manage the RAI Native App's Compute Resources

The RelationalAI (RAI) Native App requires compute resources to evaluate queries from RAI Python models. This section provides an overview of these compute resources and how they are managed. For information on costs associated with these resources, see Cost Management.

The RAI Native App utilizes an X-SMALL Snowflake warehouse for Snowflake interoperability. This warehouse is named RELATIONAL_AI_ERP_WAREHOUSE and is fully managed by the native app. It is automatically provisioned when you activate the app and suspended when you deactivate the app.

See the Snowflake documentation for information on warehouses.

Snowflake compute pools are collections of compute resources that are managed as a shared pool. The RAI Native App uses compute pools to host engines that process queries from RAI Python models.

When you install the RAI Native App, the following compute pools are automatically provisioned:

NameSnowflake Instance FamilySupported Cloud PlatformsDescription
RELATIONAL_AI_ERP_COMPUTE_POOLCPU_X64_XSAWS, AzureUsed for internal app operations.
RELATIONAL_AI_COMPILE_CACHE_SPCSHIGHMEM_X64_MAWS, AzureUsed for internal app operations.
RELATIONAL_AI_HIGHMEM_X64_SHIGHMEM_X64_SAWS, AzureRuns engines that execute queries from RAI Python models.
RELATIONAL_AI_HIGHMEM_X64_MHIGHMEM_X64_MAWS, AzureRuns engines that execute queries from RAI Python models.
RELATIONAL_AI_HIGHMEM_X64_LHIGHMEM_X64_LAWS onlyRuns engines that execute queries from RAI Python models.
RELATIONAL_AI_HIGHMEM_X64_SLHIGHMEM_X64_SLAzure onlyRuns engines that execute queries from RAI Python models.
RELATIONAL_AI_CPU_X64_SCPU_X64_SAWS, AzureReserved for future use.
RELATIONAL_AI_CPU_X64_MCPU_X64_MAWS, AzureReserved for future use.

These compute pools are fully managed by the RAI Native App. They are automatically suspended when you deactivate the app and resumed when you activate the app.

Engines are virtual machines that process queries and other transactions from RAI Python models. They are hosted in the compute pools managed by the RAI Native App. Like Snowflake virtual warehouses, engines can be independently created for workload isolation or scaling purposes.

Every RAI Python model requires a logic engine to process rules and queries. When a user queries a model using the Python API, the RAI Native App resumes the user’s configured logic engine if it is suspended, or automatically creates a new engine for the user if one does not exist.

By default, each user has a dedicated engine. This ensures transactions are isolated per user by default, though a user may run multiple concurrent transactions on their engine.

If you need fine-grained control over resource allocation, you can create and manage engines manually using SQL, Python, or the RAI CLI. RAI models can then be configured to use specific engines using configuration keys:

Configuration KeyDescription
engineName of the engine to use. Defaults to the user’s Snowflake username with dots replaced by underscores—for example, w.riker@relational.ai becomes w_riker.
engine_sizeSize of the engine. Defaults to HIGHMEM_X64_S. See Engine Sizes for details.

Solver engines process transactions sent using the relationalai Python package’s SolverModel API. When a user calls SolverModel.solve(), their solver engine resumes if suspended, or a new one is created using the configured solver engine name.

If you have enabled the CDC Service, an engine named CDC_MANAGED_ENGINE is automatically provisioned whenever changes to a data stream are detected. This engine processes changes to Snowflake tables and views shared with the RAI Native App for use in RAI models. It is suspended automatically after 30 minutes of inactivity or when you disable the CDC Service.

By default, the CDC_MANAGED_ENGINE is provisioned in the app’s HIGHMEM_X64_S compute pool. However, you may alter the CDC engine size if needed.

An engine’s size refers to the instance family of the compute pool it is hosted on. Different instance families provide varying levels of CPU, memory, and storage resources. The RAI Native App currently supports the following engine sizes:

Engine SizeSupported Engine TypesSupported Cloud PlatformsDescription
HIGHMEM_X64_SCDC, Logic, SolverAWS, AzureOptimized for small workloads
HIGHMEM_X64_MCDC, Logic, SolverAWS, AzureOptimized for medium workloads
HIGHMEM_X64_LCDC, LogicAWS onlyOptimized for large workloads
HIGHMEM_X64_SLCDC, LogicAzure onlyOptimized for large workloads

By default, new engines automatically suspend after one hour of inactivity. You may also manually suspend an engine to save costs when it is not in use. While suspended, an engine does not consume compute resources. Transactions sent to a suspended engine will fail until the engine is resumed.

To change the inactivity window for an engine:

  1. Set the auto_suspend_mins option when creating a new engine.

  2. Use the api.alter_engine_auto_suspend_mins() procedure to update the auto-suspend time for an existing engine. See Change Engine Auto-Suspend Time for details.

  3. Set the auto_suspend_mins configuration key in a user’s raiconfig.toml file or a Config object. If unset, the default value of 60 minutes applies. Changes to this key take effect the next time the user creates a model.

Suspended engines automatically resume via the RAI Python API when users execute a query. You can also manually resume a suspended engine.

Each engine supports up to 8 concurrent transactions and has a queue capacity of 128 transactions with first-in/first-out priority. However, engines may process resource-intensive transactions, like large-scale graph algorithms, sequentially.

By default, each user has a dedicated engine created for them automatically the first time they create a model. This ensures transactions are isolated per user by default, though a user can run multiple concurrent transactions on their engine.

Concurrent transactions on the same engine may impact each other’s performance. To avoid coordination issues, especially when resource-intensive transactions are involved, consider creating a dedicated engine for each workload.

You can determine if an engine is overloaded by monitoring it for a large number of transactions in the QUEUED or CREATED state. See Monitor Engine Transactions for details.

You can manage engines using SQL, Python, or the RAI CLI.

To create an engine, pass strings with the desired engine name and size to the api.create_engine() procedure:

CALL relationalai.api.create_engine(
'my_engine',
'HIGHMEM_X64_S', -- Change to HIGHMEM_X64_M for a larger engine.
{'auto_suspend_mins': 60}, -- Auto-suspend after 60 minutes of inactivity.
NULL
);
/*+----------+
| Success. |
+----------+ */

Engine names must be between 3 and 50 characters long and can contain only a-z, A-Z, 0-9, and _ characters. Note that it may take several minutes for the engine to be provisioned and ready for use.

To delete an engine, pass the engine name to the api.delete_engine() procedure:

-- Delete the engine named 'my_engine'.
CALL relationalai.api.delete_engine('my_engine');
/*+-----------+----------------------+
| NAME | MESSAGE |
|-----------+----------------------|
| my_engine | deleted successfully |
+-----------+----------------------+ */

When an engine is deleted, all current and queued transactions are cancelled. Any new transactions submitted to the engine will fail.

To list all engines, query the api.engines view:

SELECT * FROM relationalai.api.engines;
/*+------------------------+--------------+------+-------+-----------------------+--------------------------------+-------------------------------+-----------------------------+-------------------------+
| NAME | ID | SIZE | STATUS | CREATED_BY | CREATED_ON | UPDATED_ON | COMPUTE_POOL | VERSION |
|------------------------+--------------+------+--------+----------------------+--------------------------------+-------------------------------+-----------------------------+-------------------------|
| CDC_MANAGED_ENGINE | b7c1d8f9a2b3 | S | READY | SYSTEM | 2024-10-27 15:22:15.500 -0700 | 2024-10-27 15:22:16.731 -0700 | RELATIONAL_AI_HIGHMEM_X64_S | 2024.10.27-e829e39d |
| john_doe | e4f5a6d7c8e9 | M | READY | john.doe@company.com | 2024-10-27 17:29:53.110 -0700 | 2024-10-27 17:29:54.319 -0700 | RELATIONAL_AI_CPU_X64_M | 2024.10.27-e829e39d |
+------------------------+--------------+------+--------+----------------------+--------------------------------+-------------------------------+-----------------------------+-------------------------+ */

Refer to the reference docs for details about each column in the api.engines view.

To get details about a specific engine, pass the engine name to the api.get_engine() procedure:

-- Get details about the CDC engine. Note that if CDC is disabled, this engine may not exist.
CALL relationalai.api.get_engine('CDC_MANAGED_ENGINE');
/*+---------------------+--------------+-------------------------+------+--------+------------+-------------------------------+------------------------------ +-----------------------------+
| NAME | ID | VERSION | SIZE | STATUS | CREATED_BY | CREATED_ON | UPDATED_ON | COMPUTE_POOL |
|---------------------+--------------+-------------------------+------+--------+------------+-------------------------------+-------------------------------+-----------------------------|
| CDC_MANAGED_ENGINE | a9d7f3b2c8e4 | 2024.10.27-e829e39d | S | READY | SYSTEM | 2024-10-27 15:22:15.500 -0700 | 2024-10-27 15:22:16.731 -0700 | RELATIONAL_AI_HIGHMEM_X64_S |
+---------------------+--------------+-------------------------+------+--------+------------+-------------------------------+-------------------------------+-----------------------------+ */

Engines that have been automatically scheduled for suspension due to inactivity are considered idle. You can view idle engines by filtering the api.engines view on the for rows where the STATUS column is READY and the SUSPENDS_AT column is not null:

SELECT * FROM relationalai.api.engines
WHERE STATUS = 'READY' AND SUSPENDS_AT IS NOT NULL;

To suspend an engine, pass the engine name to the api.suspend_engine() procedure:

-- Suspend the engine named 'my_engine'.
CALL relationalai.api.suspend_engine('my_engine');
/*+-------------+------------------------+
| NAME | MESSAGE |
+-------------+------------------------+
| my_engine | suspended successfully |
+-------------+------------------------+ */

To resume a suspended engine, pass the engine name to the api.resume_engine() procedure:

-- Resume the engine 'my_engine' if it is suspended.
CALL relationalai.api.resume_engine('my_engine');
/*+-----------+----------------------+
| NAME | MESSAGE |
|-----------+----------------------|
| my_engine | resumed successfully |
+-----------+----------------------+ */

To change the auto-suspend time for an engine, pass the engine name and the desired auto-suspend time in minutes to the api.alter_engine_auto_suspend_mins() procedure:

-- Set the auto-suspend time for the engine 'my_engine' to 30 minutes.
CALL relationalai.api.alter_engine_auto_suspend_mins('my_engine', 30);
/*+---------+
| Success |
+---------+ */

Engines cannot be resized on-the-fly. To resize an engine, first delete the engine and then create a new engine with the same name and a different size:

-- Delete the engine named 'my_engine'.
CALL relationalai.api.delete_engine('my_engine');
/*+-----------+----------------------+
| NAME | MESSAGE |
|-----------+----------------------|
| my_engine | deleted successfully |
+-----------+----------------------+ */
-- Create a HIGHMEM_X64_M engine with the same name.
CALL relationalai.api.create_engine('my_engine', 'HIGHMEM_X64_M');
/*+----------+
| Success. |
+----------+ */

You can view an engine’s transactions by querying the api.transactions view a filtering by the ENGINE_NAME column:

-- List transactions for the engine named 'my_engine'.
SELECT * FROM relationalai.api.transactions WHERE ENGINE_NAME = 'my_engine';
/*+--------------------------------------+---------------+-----------+-----------+-----------------------+----------+-------------------------------+-------------------------------+-------------+
| ID | DATABASE_NAME | STATE | READ_ONLY | CREATED_BY | DURATION | CREATED_ON | FINISHED_AT | ENGINE_NAME |
|--------------------------------------+---------------+-----------+-----------+-----------------------+----------+-------------------------------+-------------------------------+-------------|
| 02c8fa31-1234-5678-90ab-abcdef123456 | MyModel | ABORTED | TRUE | john.doe@company.com | 7643 | 2024-10-28 08:00:12.123 -0700 | 2024-10-28 08:00:19.766 -0700 | my_engine |
| 03d9ab41-2345-6789-01bc-bcdef2345678 | MyModel | COMPLETED | TRUE | john.doe@company.com | 500 | 2024-10-28 08:02:15.456 -0700 | 2024-10-28 08:02:15.956 -0700 | my_engine |
| 04e8bc52-3456-7890-12cd-cdef34567890 | MyModel | RUNNING | FALSE | john.doe@company.com | 3200 | 2024-10-28 08:05:00.789 -0700 | 2024-10-28 08:05:03.989 -0700 | my_engine |
+--------------------------------------+---------------+-----------+-----------+-----------------------+----------+-------------------------------+-------------------------------+-------------+ */

Note that multiple transactions for the same engine may be RUNNING simultaneously. See Concurrent Transactions for information on how concurrent transactions are handled.

Take note of the following states. While occasional occurrences are normal, a high volume may indicate potential issues:

StatusDescription
CREATEDThe transaction has been accepted but is not yet in the engine queue. If it remains in this state, the engine’s resources are at capacity. Consider increasing the engine size or cancelling the transaction and running it on a different engine.
QUEUEDThe transaction is in the engine’s queue. If it remains in this state, the engine’s concurrency limit has been reached. Wait for the transaction to leave the queue or cancel it and rerun on a different engine.
ABORTEDThe transaction was cancelled or failed due to an error. Check the ABORT_REASON column for more details.

To get details about a specific transaction, pass the transaction ID to the api.get_transaction() procedure:

-- Get details for the transaction with ID '02c8fa31-1234-5678-90ab-abcdef123456'.
CALL relationalai.api.get_transaction('02c8fa31-1234-5678-90ab-abcdef123456');
/*+--------------------------------------+---------------+-----------+--------------+-----------+-----------------------+----------+-------------------------------+-------------------------------+-------------+
| ID | DATABASE_NAME | STATE | ABORT_REASON | READ_ONLY | CREATED_BY | DURATION | CREATED_ON | FINISHED_AT | ENGINE_NAME |
|--------------------------------------+---------------+-----------+--------------+-----------+-----------------------+----------+-------------------------------+-------------------------------+-------------|
| 02c8fa31-1234-5678-90ab-abcdef123456 | MyModel | COMPLETED | NULL | TRUE | john.doe@company.com | 7643 | 2024-10-28 08:00:12.123 -0700 | 2024-10-28 08:00:19.766 -0700 | my_engine |
+--------------------------------------+---------------+-----------+--------------+-----------+-----------------------+----------+-------------------------------+-------------------------------+-------------+ */

To cancel a transaction, pass the transaction ID to the api.cancel_transaction() procedure:

-- Cancel the transaction with ID '02c8fa31-1234-5678-90ab-abcdef123456'.
CALL relationalai.api.cancel_transaction('02c8fa31-1234-5678-90ab-abcdef123456');
/*+------------------------+
| Cancelling transaction |
+------------------------+ */

It may take a few moments for the transaction to be cancelled. You may monitor the transaction and confirm that it has been cancelled once the STATE is reported as CANCELED.