# Creating load balancers

ข้อจำกัด:

* Forwarding rule และ protocol ไม่สามารถเปลี่ยนได้ หลังทำเพิ่ม pool

#### ขั้นตอนการสร้าง load balancer

1. หน้า Load balancers กด **Create load balancer**<br>

   <figure><img src="/files/kZgTo84KugqBAeot2aka" alt=""><figcaption></figcaption></figure>
2. บนหน้า **Create** **load** **balancer**:

   1. ระบุชื่อ ตัวเลือกอื่นๆ และ คำอธิบาย
   2. **enable** หรือ **disable** การทำ HA(High Availability):
      1. ถ้า enable HA จะมีการสร้าง instance ของ load balancer 2 ตัว และทำงานแบบ **Active/Standby**
      2. ถ้า disable, load balancer จะสร้างมาแค่ 1 ตัว
   3. เลือก **flavor** สำหรับ **load balancer**:
      1. ถ้า enable HA สามารถเลือกได้ ว่าจะให้ instance ไหน เป็น active ตัวไหนเป็น standby ถ้า instance ที่เป็น active มีสถานะ unhealthy จะทำการ failover ไปที่ instance ที่ standby อยู่

   <figure><img src="/files/vjid9I5D5bixHqXrAMnJ" alt=""><figcaption></figcaption></figure>
3. ในส่วนของ **Network** **settings** เลือก network ที่ต้องการให้ load balancer ทำงาน ระบุ IP Address ที่ต้องการ
4. ในส่วนของ **Balancing** **pools** เลือก **balancing** **pool** ที่จะ forward traffic จาก load balancer ไปยัง VM โดยการกด **Add**
   1. ในส่วนของ **Forwarding** **rule** เลือก rule ที่ต้องการ forward จาก load balancer ไปที่ backend protocol\
      [Forwading rule](/readyidc-docs/readme/load-balancing/forwading-rule.md)<br>

      <figure><img src="/files/KHw86CgpNpb7uqEeG99L" alt=""><figcaption></figcaption></figure>
   2. ในส่วนของ **Balancing** **settings**:
      1. เลือกอัลกอลิทึม
         * Least connections: ส่ง request ไปที่ VM ที่มี **จำนวน connection น้อยที่สุด**
         * Round robin: กระจาย request ไปแต่ละ VM **วนลำดับเท่าๆ กัน**
         * Source IP: Request จาก **IP เดิม จะไป VM เดิมเสมอ**
      2. Sticky session
         * เปิดใช้งานแล้ว Load Balancer จะ **สร้าง cookie** แนบไปกับ response
         * เมื่อ client ส่ง request ครั้งถัดไป → จะถูกส่งไป **VM เดิม**
         * ใช้ cookie นี้เป็นตัวจำว่า client เคยไปที่ VM ไหน
   3. ในส่วนของ **Members**, เพิ่ม vm ที่จะรับ traffic จาก Load Balancer โดยการกด **Add**
   4. **Allowed** **CIDRs** ระบุช่วง IP address ที่ต้องการให้เข้าถึง load balancer ได้
   5. ในส่วนของ Health monitor
      * **HTTP/HTTPS:** ใช้ GET request เช็ค response ต้องได้สถานะ 200 และมีการกำหนด URL Path
      * **TCP/UDP:** เช็คว่าพอร์ตเปิดและสามารถใช้งานได้
      * **PING:** เช็คว่าสามารถ ping ได้
   6. กด **Create**
5. เพิ่ม balancing pools ได้มากกว่า 1 pool ตามความต้องการ
6. กด **Create**<br>

   <figure><img src="/files/EUdRQhUnWvdZu5Rc8S02" alt=""><figcaption></figcaption></figure>


---

# 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://readyidc.gitbook.io/readyidc-docs/readme/load-balancing/creating-load-balancers.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.
