./prontouso.com
WEB & MẠNG

Mô Phỏng Thuật Toán Cân Bằng Tải

Mô phỏng trực quan cách thức hoạt động của các thuật toán cân bằng tải mạng (Round Robin, Weighted Round Robin, Least Connections, Random và IP Hash) khi phân phối lưu lượng.

Trạng thái công cụChạy trên trình duyệt của bạn
Xem trước

Load Balancer Simulator

Thuật toán

Servers

  • Server 1Weight:
  • Server 2Weight:
  • Server 3Weight:

Weight only affects the weighted round robin algorithm.

Distribution

  • Server 1
    7 requests (35%)
  • Server 2
    7 requests (35%)
  • Server 3
    6 requests (30%)

Cách thức hoạt động

  1. Nhập dữ liệu của bạn

    Điền các giá trị cần thiết, dán văn bản hoặc tải lên tệp bạn muốn xử lý.

  2. Xem kết quả tức thì

    Hầu hết các công cụ cập nhật theo thời gian thực khi bạn nhập liệu; một số công cụ sử dụng một nút hành động duy nhất.

  3. Sử dụng kết quả

    Sao chép, tải xuống hoặc chia sẻ kết quả được tạo — bạn luôn có toàn quyền kiểm soát dữ liệu của mình.

Quyền riêng tư & xử lý dữ liệuChạy cục bộ 100% trên trình duyệt của bạn. Công cụ này không tải dữ liệu của bạn lên máy chủ.

Mô Phỏng Thuật Toán Cân Bằng Tải là gì?

Simulate how round robin, weighted round robin, and least-connections algorithms distribute a stream of requests across servers.

TÌM HIỂU CÁCH HOẠT ĐỘNG CỦA CÔNG CỤ

How the load balancer simulator works

The three algorithms

  • Round robin — cycles through servers in a fixed order, ignoring load.
  • Weighted round robin — the same rotation, but servers with a higher weight get proportionally more turns (using the smooth algorithm nginx uses internally).
  • Least connections — routes each new request to whichever server currently has the fewest still-active requests.

How to use it

  • Pick an algorithm and add or remove simulated servers.
  • Set a weight per server (used only by weighted round robin).
  • Set how many requests to simulate and how long each one keeps a server busy.

What "request duration" models

Least connections only differs from round robin once requests take more than one tick to finish — that's what lets some servers still be "busy" when the next request arrives, which is exactly the condition least-connections is designed to react to.

Weighted round-robin example

Weights 5:1:1

Smooth weighted round robin gives more turns to the strongest server while still spacing weaker servers into the sequence.

A, A, B, A, C, A, A

Simulation notes

Server weights and request counts are simulated locally. No network requests are sent to any real backend or load balancer.

Các Câu Hỏi Thường Gặp (FAQ)

Which algorithm should I actually use in production?

Round robin works well when every server is equally sized and requests are roughly equal cost. Weighted round robin suits a mix of server sizes. Least connections tends to perform best when request duration varies a lot.

Is this exactly how a real load balancer works?

It models the core decision logic correctly (including nginx's actual smooth weighted round-robin algorithm), but a production load balancer also handles health checks, connection draining, and session affinity, which this simulator doesn't.

Why does least-connections need a request duration at all?

Without one, every request would be considered "finished" instantly, and every server would always show zero active connections — making least-connections indistinguishable from round robin.

Does least connections know future request duration?

No. It only counts requests still active at the current tick, then chooses the server with the fewest active requests.

Công Cụ Liên Quan