Load Balancer
Simple FastAPI load balancer
pip install load-balancer
Usage
from multiprocessing import Process
from fastapi import FastAPI
import uvicorn
from load_balancer import session_affinity, # or round_robin
myapp = FastAPI()
# ...
NUM_WORKERS = 4
UDP_PATHS = [f'udp-{i}.sock' for i in range(NUM_WORKERS)]
balancer = session_affinity(UDP_PATHS)
procs = [Process(target=uvicorn.run, args=(balancer,))] + [
Process(target=uvicorn.run, args=(myapp, path))
for path in UDP_PATHS
]
for proc in procs:
proc.start()
for proc in procs:
proc.join()
Metadata
Release files for load-balancer 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| load_balancer-0.1.1.tar.gz | 2.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| load_balancer-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / load_balancer-0.1.1.tar.gz
| Download URL | load_balancer-0.1.1.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6ac86771d082c944a4d77bdd1c788621dcb01bed1c93ddca23f7da26bcb2acb
|
|
BLAKE2b-256 checksum How to use checksums |
52bccefe1efaad7c73c3969cb1d47c7ec8c2a3c7d4d7fec1083ba1ab8a4f8235
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / load_balancer-0.1.1-py3-none-any.whl
| Download URL | load_balancer-0.1.1-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a0262aa236bb8dc2c4a43e631fae67ef2ae469becc22601177c2715179a8279a
|
|
BLAKE2b-256 checksum How to use checksums |
c8c7d255cd4aabc48e0d554d5bfbd1e135ba213168c549c09b32f8e0f413c41b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|