Giter VIP home page Giter VIP logo

jobs's Introduction

#jobs - a Job scheduler for load regulation#

Copyright (c) 2010 Erlang Solutions Ltd.

Version: 0.1

JOBS

Jobs is a job scheduler for load regulation of Erlang applications. It provides a queueing framework where each queue can be configured for throughput rate, credit pool and feedback compensation. Queues can be added and modified at runtime, and customizable "samplers" propagate load status across all nodes in the system.

Specifically, jobs provides three features:

  • Job scheduling: A job is scheduled according to certain constraints.
    For instance, you may want to define that no more than 9 jobs of a
    certain type can execute simultaneously and the maximal rate at
    which you can start such jobs are 300 per second.
  • Job queueing: When load is higher than the scheduling limits
    additional jobs are queued by the system to be run later when load
    clears. Certain rules govern queues: are they dequeued in FIFO or
    LIFO order? How many jobs can the queue take before it is full? Is
    there a deadline after which jobs should be rejected. When we hit
    the queue limits we reject the job. This provides a feedback
    mechanism on the client of the queue so you can take action.
  • Sampling and dampening: Periodic samples of the Erlang VM can
    provide information about the health of the system in general. If we
    have high CPU load or high memory usage, we apply dampening to the
    scheduling rules: we may lower the concurrency count or the rate at
    which we execute jobs. When the health problem clears, we remove the
    dampener and run at full speed again.

Quickstart

Compile and start a shell:

$ rebar get-deps
$ rebar compile
$ erl -pa ebin/ -pa deps/*/ebin -boot start_sasl

Start the jobs application:

1> application:start(jobs).

Paste an example from below into the shell.

A queue that only allows 3 jobs to run concurrently

jobs:add_queue(three_at_once, [
    {regulators, [{counter, [
                    {name, three_at_once},
                    {limit, 3}
                  ]}]}
]). 
Task = fun(N) ->
    io:format("Task ~p started\n", [N]),
    timer:sleep(2000),
    io:format("Task ~p finished, took 2 seconds.\n", [N])
end,
lists:foreach(fun(N) ->
    spawn( fun() ->
        jobs:run(three_at_once, fun() -> Task(N) end)
    end)        
end, lists:seq(1,10)).

To change the queue from 3-at-once to 2-at-once:

jobs:modify_counter(three_at_once, [{limit,2}]).

A queue that starts 3 jobs per second, regardless of job duration

jobs:add_queue(three_per_sec, [
    {regulators, [{rate, [
                    {name, three_per_sec},
                    {limit, 3}
                 ]}]}
]). 
Task = fun(N) ->
    io:format("Task ~p started\n", [N]),
    timer:sleep(2000),
    io:format("Task ~p finished, took 2 seconds.\n", [N])
end,
lists:foreach(fun(N) ->
    spawn( fun() ->
        jobs:run(three_per_sec, fun() -> Task(N) end)
    end)        
end, lists:seq(1,10)).

To change the queue from 3 jobs/sec to 2 jobs/sec:

jobs:modify_regulator(rate, three_per_sec, three_per_sec, [{limit, 2}]).

Prerequisites

This application requires 'exprecs'. The 'exprecs' module is part of http://github.com/esl/parse_trans

Contribute

For issues, comments or feedback please [create an issue!] 1

##Modules##

jobs
jobs_app
jobs_info
jobs_lib
jobs_queue
jobs_queue_list
jobs_sampler
jobs_sampler_cpu
jobs_sampler_history
jobs_sampler_mnesia
jobs_server

jobs's People

Contributors

jlouis avatar uwiger avatar temporal avatar rj avatar spawnthink avatar dizzyd avatar

Watchers

Bruce Xin avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.