You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,9 @@ This Go project implements a load balancer that supports two balancing methods:
21
21
22
22
### Example Usage
23
23
24
-
1.**Spawn Local Servers** (5 servers, round-robin method):
25
-
```bash
26
-
go run *.go -amount 5 -method rr -env local
24
+
1.**Spawn Local Servers** (5 servers, round-robin method):
25
+
```bash
26
+
go run *.go -amount 5 -method rr -env local
27
27
Use External Servers from a JSON File (weighted round-robin method):
28
28
29
29
```bash
@@ -37,7 +37,7 @@ go run *.go -method rr -env external -path ./servers.yaml
37
37
### Configuration File Format
38
38
When using the -env external flag, the load balancer will read server information from a configuration file. You can provide the file in either YAML or JSON format.
39
39
40
-
# Sample YAML Configuration (servers.yaml)
40
+
## Sample YAML Configuration (servers.yaml)
41
41
```yaml
42
42
---
43
43
- addr: https://facebook.com
@@ -47,7 +47,7 @@ When using the -env external flag, the load balancer will read server informatio
47
47
- addr: https://google.com
48
48
weight: 3
49
49
```
50
-
# Sample JSON Configuration (servers.json)
50
+
## Sample JSON Configuration (servers.json)
51
51
```json
52
52
[
53
53
{
@@ -64,14 +64,14 @@ When using the -env external flag, the load balancer will read server informatio
64
64
}
65
65
]
66
66
```
67
-
# How It Works
68
-
## Load Balancing Methods
67
+
## How It Works
68
+
### Load Balancing Methods
69
69
Round Robin (rr): Distributes requests evenly across all available servers.
70
70
Weighted Round Robin (wrr): Distributes requests based on the weight assigned to each server. Servers with higher weights receive more traffic.
71
71
Local Server Spawning
72
72
When using -env local, the program spawns a number of local servers on ports starting from 8000 (e.g., localhost:8000, localhost:8001, etc.).
73
73
74
-
## External Servers
74
+
# External Servers
75
75
When using -env external with the -path flag, the load balancer reads external server addresses from the specified JSON or YAML file and balances requests accordingly.
0 commit comments