Skip to main content

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)

Source distribution for load-balancer 0.1.1
File Size Uploaded Provenance Actions
load_balancer-0.1.1.tar.gz 2.6 kB Without provenance Details for load_balancer-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for load-balancer 0.1.1
File Interpreter ABI Platform Actions
load_balancer-0.1.1-py3-none-any.whl Python 3 none any Details for load_balancer-0.1.1-py3-none-any.whl

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

Security for load-balancer 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page