Skip to content

Commit

Permalink
Create load_balancer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored May 11, 2024
1 parent 7cd90e0 commit a6661b3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions distributed_systems/load_balancer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import requests

def create_load_balancer(hosts):
# Create a load balancer using HAProxy or NGINX

response = requests.get(f'http://{hosts[0]}/load_balance/{len(hosts)}')
load_balancer_url = response.json()['load_balancer_url']

return load_balancer_url

def send_request(load_balancer_url, data):
# Send a request to a load balancer

response = requests.post(load_balancer_url, json=data)

return response.json()

0 comments on commit a6661b3

Please sign in to comment.