DCoB-Scheduler

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

README

DCoB-Scheduler

Distributed Computing on Browser Scheduler

Conceps & Defines

What

DCoB is a computing platform powered by web browsers as workers.

DCoB's cluster contains one(or a small group) centralized scheduler nodes and many loose worker nodes.

DCoB is not a low latency / high responsee / multi-tenant job executor, it's intend to runing a smal number of big jobs with idle computing power.

Why

Since all mainstream web browers are support WASM, and in most of time we use web brower to browse pages, our CPU's idle rate usually very high.

Usage such idle computing power, we have so many things can do.

Job

We define job as some kind of computing process.

The qualified job should:

  • CPU intensive, not IO intensive
  • Can be easily spilt into many small independent or weakly relevant tasks, which can distribute to workers.
Task

Task is one piece of job, every task should execute on some workers.

Task abstraction should contain:

  • task id
  • context: stage initial / intermediate / final data
  • function: stateful or stateless procedure that can take input and return output.
    • func id
    • control handler: responsible for start / stop / retry / interrupt
Resource

Workers (browsers) have those characteristics:

  • Unstable: to avoid our task affect the normal user browse, worker's process priority is relatively lower.
  • Volatile: task can be killed with user close their browser.
  • Homogeneous: no matter user's operating system, CPU architecture, browser type, all tasks running on WASM VM.

Architecture

                                 TASK TO DAG
                                      |
                                      |
                                      |
                                      |
                                      |
                                      |
                          +-----------v------------+
                          |                        |
                          |      Scheduler         |
                          |                        |
                          +------------------------+
                          |                        |
                          |     Worker Pool        |
                          |                        |
                          +------------------------+
                          |                        |
                  +------->    Connection Registry <----------------+
                  |       +----------------^-------+                |
                  |                        |                        |
------------------+------------------------+------------------------+---------------
                  |                        |                        |
                  |                        |                        |
                  |                        |                        |
                  |                        |                        |
                  |                        |                        |
                  |                        |                        |
        +---------+---------+      +-------+-------+        +-------+------+
        |                   |      |               |        |              |
        |    Task1RunTime   |      |   Task2RunTime|        |              |
        +-------------------+      +---------------+        |              |
        |                   |      |               |        |              |
        |      WASM         |      |    ...        |        |   ...        |
        +-------------------+      +---------------+        |              |
        |     Nodejs        |      |     ...       |        |              |
        +-------------------+      +---------------+        |              |
        |      V8           |      |     ...       |        |              |
        +-------------------+      +---------------+        +--------------+

Modules Design

Scheduler
    +---------------------+                                                                            
  |-|                     |                                                                            
|-- |                     |                                                                            
| | |  Job                |                                    Task Q                                  
| | |        |------------|     Tasks   +-------------------------------------------------+            
| | |        |            |         \   |    |    |    |    |    |    |    |    |    |    |  ----|     
| | |        |            |   --------  |    |    |    |    |    |    |    |    |    |    |      |     
| | |        | Job        |         /   +-------------------------------------------------+      |     
| | |        | Spliterator|                                                                      |     
| | |        |            |                                                                      |     
| | +--------|---------|--+                                                                      |     
| -------------------|-|                                       +-----------------+               |     
---------------------|                                    \    |                 |    /          |     
                                             |--------------   |     Decider     |   -------------     
                                             |            /    |                 |    \                
                                             |                 +-----------------+                     
                                             |                           |                             
                                             |                           |                             
                                             |                          \|/                            
                                                                         |                             
                                   +-----------------+         +-----------------+                     
                                   |                 |         |                 |                     
                                   |   Worker Pool   |         |   Distributor   |                     
                                   |                 |         |                 |                     
                                   +-----------------+         +-----------------+                     
                                                                                                       
                                         Status                     Cmd     Task                       
                                           -                             |                             
                                          /|\                            |                             
                                           |                             |                             
                                 ----------|-----------------------------|---------------              
                                           |                             |                             
                                           |                             |                             
                                           |                             |                             
                                           |                            \|/                            
                                           |           Worker            -                             
  1. Job: contains job meta and context
  • Job Spilterator: spilt job to tasks and can be called iteratively to get one task
  1. Task Q:
  • queue
  1. Worker Pool:
  • manage worker's lifecycle
  • monitor workers status
  1. Decider:
  • pop task from task q
  • apply some workers from worker pool
  • decide how to assign tasks to workers (by some policy)
  1. Distributer:
  • distribute task to worker
  • send cmd (start / stop / retry / interrupt) to worker
Worker
                                           
                                           
    Status                  Cmd Task       
      ^                        |           
      |                        |           
      |                        |           
------|------------------------|-----------
      |                        |           
      |                        v           
 +-------------------------------------+   
 |                                     |   
 |                                     |   
 |             Connector               |   
 |                                     |   
 +-------------------------------|-----+   
        ^                        |         
        |                        |         
 +------|-----+           +------v-----+   
 |            |           |            |   
 |  Monitor   <-----------| Controller |   
 |            |           |            |   
 +------------+           +------^-----+   
                                 |         
                                 |         
                                 |         
                                 |         
                          +------v-----+   
                          |            |   
                          |  Executor  |   
                          |            |   
                          +------------+   
  1. Connector:
  • maintain connection status
  • register, cancellation
  1. Controller:
  • assign task to executor
  • start / stop / retry / interrupt
  • gathering status / result
  1. Executor:
  • run task
  1. Monitor:
  • heartbeat / lease
  • task status
  • task result
Demo

This demo will try to mine simple virtual coins

reference

https://github.com/dockersamples/dockercoins

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
job

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL