Skip to main content

pybalancer

pybalancer an simple load balancer for Python

Features

English

  • a simple load balancer
  • consistent Hash Load Balance using uhashring ketama hash function
  • periodly health checks, remove failed instance and add when it recovers
  • manually call remove_instance when it fails.

Installation

Using pip:

$ pip install pybalaner

Basic usage

pybalancer is very simple and efficient to use:

from pybalancer import LoadBalancer

# create a consistent hash ring of 3 nodes of weight 1
balancer = LoadBalancer(instances=['node1:port1', 'node2:port2', 'node3:port3'], interval=5)

# get the node name for the remote_addr key
target_instance = balancer.get_instance(remote_addr="host:port")

failed_times = 0
# call target_instance fails
if call(target_instance):
	failed_times += 1
	if failed_times > max_fails:
		balancer.remove_instance(target_instance)


alive_instances = balancer.get_alive_instances()
print(alive_instances)

Metadata

Release files for pybalancer 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybalancer 1.0
File Size Uploaded Provenance Actions
pybalancer-1.0.tar.gz 2.9 kB Without provenance Details for pybalancer-1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pybalancer 1.0
File Interpreter ABI Platform Actions
pybalancer-1.0-py3-none-any.whl Python 3 none any Details for pybalancer-1.0-py3-none-any.whl

Total release size: 6.4 kB

Release files / pybalancer-1.0.tar.gz

Download URL pybalancer-1.0.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
213d5e45b64ffe1843f0efb45747a0bd4c147368ef87bb6590b4497a03488b96
BLAKE2b-256 checksum
How to use checksums
ac087685c8f3a23608a4a16f994dc41ade59bdd38db0c8d4ef7bc451913fc952
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

Release files / pybalancer-1.0-py3-none-any.whl

Download URL pybalancer-1.0-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85ec0799bc03e1a80f26e9be8c6f04c6ed792c091c456a4a3f4229023ce79d92
BLAKE2b-256 checksum
How to use checksums
e7b305780b7005b11f9f512b6ce7d1eb33d9bd58b30c7bc280b737fa84770367
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

Security for pybalancer 1.0

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

1.0 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