Simple FastAPI load balancer
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
load_balancer-0.1.1.tar.gz
(2.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file load_balancer-0.1.1.tar.gz.
File metadata
- Download URL: load_balancer-0.1.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6ac86771d082c944a4d77bdd1c788621dcb01bed1c93ddca23f7da26bcb2acb
|
|
| MD5 |
7fc905389c579e3fb7832f1d0cbf793d
|
|
| BLAKE2b-256 |
52bccefe1efaad7c73c3969cb1d47c7ec8c2a3c7d4d7fec1083ba1ab8a4f8235
|
File details
Details for the file load_balancer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: load_balancer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0262aa236bb8dc2c4a43e631fae67ef2ae469becc22601177c2715179a8279a
|
|
| MD5 |
a23946ebbf613954bcfb8da46d6ebc24
|
|
| BLAKE2b-256 |
c8c7d255cd4aabc48e0d554d5bfbd1e135ba213168c549c09b32f8e0f413c41b
|