Skip to main content

Large Scale Distribution Toolkit

Project description

Scaled

This project is aiming the target that provides simple and efficient and reliable way for distributing computing framework, centralized scheduler and stable protocol when client and worker talking to scheduler

Introduction

The goal for this project should be as simple as possible

  • It built on top of zmq
  • it has ready python version of Client, Scheduler, Worker
  • I will provide golang or Rust version of Scheduler, the goal for the Scheduler should be completely computer language agnostic, which means they follow the same protocol
  • Scheduler might support function based computing tree in the future

Installation

pip install scaled

if you want to use uvloop, please do: pip install uvloop, default we are using python builtin uvloop

How to use it

Start local scheduler and cluster at the same time in the code

import random

from scaled.client.client import Client
from scaled.cluster.combo import SchedulerClusterCombo
from scaled.utility.zmq_config import ZMQConfig, ZMQType
from scaled.utility.logging.scoped_logger import ScopedLogger
from scaled.utility.logging.utility import setup_logger


def calculate(sec: int):
  return sec * 1


def main():
  setup_logger()
  config = ZMQConfig(type=ZMQType.tcp, host="127.0.0.1", port=2345)

  cluster = SchedulerClusterCombo(address=config, n_workers=10, event_loop="uvloop")
  client = Client(config=config)

  tasks = [random.randint(0, 100) for _ in range(100000)]

  with ScopedLogger(f"submit {len(tasks)} tasks"):
    futures = [client.submit(calculate, i) for i in tasks]

  with ScopedLogger(f"gather {len(futures)} results"):
    results = [future.result() for future in futures]

  assert results == tasks

  cluster.shutdown()
  client.disconnect()


if __name__ == "__main__":
  main()

Start scheduler and cluster independently

use scaled_scheduler to start scheduler, for example:

scaled_scheduler --allocator-type queued tcp://0.0.0.0:8516

use scaled_cluster to start workers:

scaled_worker -n 10 tcp://127.0.0.1:8516

Then you can write simply write client code as:

from scaled.utility.zmq_config import ZMQConfig, ZMQType
from scaled.client.client import Client

def foobar(foo: int):
    return foo

config = ZMQConfig(type=ZMQType.tcp, host="127.0.0.1", port=2345)
client = Client(config=config)
future = client.submit(foobar, 1)

print(future.result())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scaled-0.3.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

scaled-0.3-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file scaled-0.3.tar.gz.

File metadata

  • Download URL: scaled-0.3.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for scaled-0.3.tar.gz
Algorithm Hash digest
SHA256 28f9eaa161c33fb859314d94f90f22c15fb0ed06b8dbaf40c2795a78e31839e3
MD5 82783e986b913c87db01ecc439f8c1ae
BLAKE2b-256 a6c22f6da9e4c65bb0b2d3186c44a1786cbf58b04fd695e817279c181918356b

See more details on using hashes here.

File details

Details for the file scaled-0.3-py3-none-any.whl.

File metadata

  • Download URL: scaled-0.3-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for scaled-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 906f44ee7813b57d88ca8d9886af44d1c1ecff674eb272324e127ca93365140a
MD5 15bb9accf6c55a8a66fa4a1d8577e410
BLAKE2b-256 04818d493f8f01424914e135650f6cddd1dc98cdb1c7cb00edf73431400f65d2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page