AutoSuspend
NOTICE: AutoSuspend is an experimental feature and currently only works on kubernetes deployments.
Overview
WeScale's AutoSuspend feature helps you manage resources efficiently by automatically suspending WeSQL-Server nodes that are not actively processing queries for a specified duration. When a suspended WeSQL-Server node receives a new query, WeScale automatically resumes it, ensuring minimal impact on application performance.
Configuration Parameters
AutoSuspend can be configured using the following parameters in the WeScale configuration file or via SQL commands:
-
enable_auto_suspend
: Enables or disables the AutoSuspend feature.- Values:
true
orfalse
- Default:
false
- Values:
-
auto_suspend_timeout
: Specifies the idle timeout duration before a compute node is suspended.- Values: Duration in seconds (
s
), minutes (m
), or hours (h
) - Default:
5m
(5 minutes)
- Values: Duration in seconds (
Step 1: Enabling AutoSuspend
Use kubectl edit
to modify the WeScale configuration file. For example:
kubectl edit configmap wescale-config
To enable AutoSuspend, set enable_auto_suspend
to true
in your WeScale configuration, and specify the desired auto_suspend_timeout
. For example:
enable_auto_suspend = true
auto_suspend_timeout = 5m
Step 2: Wait for Suspension and Observe
Wait for the idle timeout duration to elapse. WeScale will automatically suspend WeSQL-Server nodes that are not actively processing queries.
Before suspension:
kubectl get po
NAME READY STATUS RESTARTS AGE
mycluster-wesql-0-0 2/2 Running 0 2m42s
mycluster-wesql-1-0 1/1 Running 0 2m42s
mycluster-wesql-2-0 1/1 Running 0 2m42s
wesql-vtcontroller-546fdc7f85-h8t6x 2/2 Running 0 2m42s
wesql-vtgate-59f897bf4-68kgq 1/1 Running 0 2m42s
After suspension, you can see that the WeSQL-Server node has been suspended:
kubectl get po
NAME READY STATUS RESTARTS AGE
wesql-vtcontroller-546fdc7f85-h8t6x 2/2 Running 0 7m57s
wesql-vtgate-59f897bf4-68kgq 1/1 Running 0 7m57s
Step 3: Resume a Suspended Node
When WeScale receives a new query for a suspended WeSQL-Server node, it automatically resumes the WeSQL-Server node. The node restores its state and processes the incoming query. There's nothing you need to do to resume a suspended node. WeScale will take care of it for you.
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2024-09-30 12:13:53 |
+---------------------+
1 row in set (0.18 sec)
The select now()
query resumes the suspended WeSQL-Server node and returns the current timestamp.
kubectl get po
NAME READY STATUS RESTARTS AGE
mycluster-wesql-0-0 2/2 Running 0 31s
mycluster-wesql-1-0 1/1 Running 0 31s
mycluster-wesql-2-0 1/1 Running 0 31s
wesql-vtcontroller-546fdc7f85-h8t6x 2/2 Running 0 10m
wesql-vtgate-59f897bf4-68kgq 1/1 Running 0 10m
Benefits of AutoSuspend
- Cost Savings: Reduce operational costs by suspending unused resources.
- Resource Optimization: Free up compute resources for other workloads.
- Automatic Management: Simplify resource management with automated suspension and resumption.
Best Practices
- Set Appropriate Timeout: Choose an idle timeout that balances cost savings with application responsiveness.
- Monitor Activity: Use WeScale monitoring tools to observe compute node activity and adjust settings accordingly.
- Test in Staging: Before enabling AutoSuspend in production, test the feature in a staging environment to understand its impact.
Frequently Asked Questions
Q: Does WeScale keep client connections open when a compute node is suspended?
A: Yes, WeScale maintains the connection between the client and WeScale even when the underlying WeSQL-Server node is suspended. This ensures that the client does not experience connection loss, and queries can be executed seamlessly when the node resumes.
Q: What is the latency impact when resuming a suspended node?
A: Resuming a suspended node introduces a slight delay, typically a few seconds. For some applications, this delay is negligible. However, latency-sensitive applications should account for this delay in their performance considerations.
Q: Is the state of the compute node preserved during suspension?
A: Yes, WeScale ensures that the state of suspended nodes is preserved. Upon resumption, the compute node restores its previous state and continues operation seamlessly, without data loss or the need for reconfiguration.