The engine can be configured to suspend automatically when you create the engine via the auto_suspend_mins option. When set to 0, auto suspend is disabled. If auto_suspend_mins is set to a non-zero value, the engine will automatically shut down after being inactive for the number of minutes specified. If not specified in the creation statement, the default value of 60 minutes is set.
This can be accomplished via a SQL API call, such as:
CALL relationalai.api.create_engine(
'my_engine',
'HIGHMEM_X64_S',
{"auto_suspend_mins": 30}
);
Note: The RAI CLI agent does not support setting auto_suspend_mins as of the rai package version 0.6.4. If attempted, it will return an error such as No such option. For this reason we recommend creating engines via a SQL call.
Confirm Settings
You can check the configuration of your engines by querying the engines view.
SELECT * FROM relationalai.api.engines;
/*+------------------------+--------------+------+-------+-----------------------+--------------------------------+-------------------------------+-----------------------------+-------------------------+-------------------+-------------------------+----------------------+
| NAME | ID | SIZE | STATUS | CREATED_BY | CREATED_ON | UPDATED_ON | COMPUTE_POOL | VERSION | AUTO_SUSPEND_MINS | SUSPENDS_AT | AWAIT_STORAGE_VACUUM |
|------------------------+--------------+------+--------+----------------------+--------------------------------+-------------------------------+-----------------------------+-------------------------|-------------------+-------------------------+----------------------|
| 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 | 0 | NULL | false |
| my_engine | e4f5a6d7c8e9 | HIGHMEM_X64_S | 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 | 30 | 2024-10-27 18:29:53.110 | true |
| test_engine | d9ba84d30b0a | HIGHMEM_X64_S | SUSPENDED | gen@relational.ai | 2024-10-27 08:50:22.391 -0800 | 2024-10-27 09:52:48.833 -0800 | | | 60 | NULL | False |
+------------------------+--------------+------+--------+----------------------+--------------------------------+-------------------------------+-----------------------------+-------------------------+-------------------+-------------------------+----------------------+ */
In this output my_engine is online, and will automatically suspend after 30 minutes of inactivity. However this engine is currently inactive, and will suspend at 2024-10-27 18:29:53.110 unless there is more activity on it before then. The other engine test_engine is currently suspended.
Change the Setting
After creating an engine, you can change the auto suspend time. For example to disable the auto suspend feature, set it to 0. This means the engine will never automatically suspend. Be sure to delete the engine when you are finished with it so that you are not charged for its resources.
CALL relationalai.api.alter_engine_auto_suspend_mins('my_engine', 0);
Error Message
Any transactions sent to an engine that is suspended will error with a message similar to the below:
---------------------------------------------------
Error: Engine 'my_engine' is in an invalid state: 'SUSPENDED'
---------------------------------------------------
Resume an Engine
Resume any suspended engines with a command like:
CALL relationalai.api.resume_engine('my_rai_engine');
After the command completes, it will take the engine a few minutes to come online. While it is coming online it will show status PENDING. Once it is fully resumed it will show status READY.
Related Documentation
For more information see these documents.