# Auto-Scaling SQL Database Storage

[Enable Auto-Scaling](/ncs-documents/database-as-a-service/sql-database/auto-scaling-sql-database-storage/enable-auto-scaling.md) เพื่อป้องกันไม่ให้เกิด Downtime จากการที่ Database Storage เต็ม ฟีเจอร์นี้ จะทำการตรวจสอบขนาดของข้อมูลภายใน Database (Storage Usage) และขยายขนาดของ Storage แบบ Online ทำให้ Database ทำงานได้อย่างต่อเนื่อง ไม่มีสะดุด

**ค่าต่าง ๆ ที่ต้องกำหนดมีดังนี้**

* Auto-Scaling Limit: ค่าสูงสุดของ Storage ที่อนุญาตให้ขยายขนาด Storage แบบอัติโนมัติโดยระบบ
* Usage Threshold: Percent ของ Storage Usage ที่ให้ขยายขนาด Storage
* Increments Size: Size ที่เพิ่มในแต่ละครั้ง
* Start Trigger: เวลาที่ให้ระบบเริ่มเข้าไปตรวจสอบ Usage Threshold
* Trigger Every: ความถี่ที่ให้ระบบเข้าไปตรวจสอบ

{% hint style="info" %}
ทั้งนี้ การตั้งค่าให้เหมาะสมของแต่ละ Database จะต่างกันไปตามรูปแบบการใช้งาน ดังนั้น ควรศึกษารูปแบบการตั้งค่าที่เหมาะสม เพื่อให้การ Auto-Scaling ได้ปรับสิทธิภาพสูงสุด
{% endhint %}

**กระบวนการทำงาน คือ** ระบบจะสร้าง Schedule เพื่อเข้าไปตรวจสอบ Storage Usage ของ Database Instance โดยหากเป็นไปตาม Usage Threshold ที่กำหนด ระบบจะขยายขนาด Storage ตาม Increments Size ที่กำหนดไว้

**กรณีที่ระบบจะไม่สั่งขยายขนาด Storage**

1. Storage Size หลังการขยาย มากกว่าหรือเท่ากับ Auto-Scaling Limit ที่กำหนดไว้
2. Storage Usage น้อยกว่า Usage Threshold ที่กำหนดไว้
3. Database Instance Status ไม่อยู่ในสถานะ Active

## Prerequisite

* มี Database Instance ใน Project ([ขั้นตอนการสร้าง SQL Database Instance](/ncs-documents/database-as-a-service/sql-database/create-sql-database-instance.md))
* มียอดคงเหลือใน Project มากกว่า 0 บาท ([ขั้นตอนการเติมเงินเข้าสู่ Project](/ncs-documents/nipa-cloud-space-overview/billing-and-wallet/topup-a-project-wallet.md))

## คำสั่งที่ใช้จัดการ Auto-Scaling มีดังต่อไปนี้

* [Enable Auto-Scaling](/ncs-documents/database-as-a-service/sql-database/auto-scaling-sql-database-storage/enable-auto-scaling.md)
* [Disable Auto-Scaling](/ncs-documents/database-as-a-service/sql-database/auto-scaling-sql-database-storage/disable-auto-scaling.md)
* [Edit Auto-Scaling](/ncs-documents/database-as-a-service/sql-database/auto-scaling-sql-database-storage/edit-auto-scaling.md)

{% hint style="info" %}
หากต้องการขยายขนาด Database Storage แบบ Manual ยังสามารถทำได้เหมือนเดิม ([ขั้นตอนการขยายขนาด Database Storage](/ncs-documents/database-as-a-service/sql-database/manage-sql-database-instance/online-extend-storage-size.md))
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-epc.gitbook.io/ncs-documents/database-as-a-service/sql-database/auto-scaling-sql-database-storage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
