Code Monkey home page Code Monkey logo

king.service's Introduction

Task scheduling for .NET core

.NET

  1. Auto-Scale micro-services within your compute
  2. Tasks to initialize your resources
  • Load WCF services
  1. Create Tasks that Occur:
  • Every X seconds per server instance
  • Every X seconds; lessens frequency to Y when there is limited work
  • That determines the needed rate via frequency of processing tasks
  • Once, even with multiple servers
  • Runs at a specified time (resolution to the hour, or the minute) on one server
  1. Extension for working with: Azure Storage
  2. Extension for working with: Service Bus

Ready, Set, Go!

PM> Install-Package King.Service

View the wiki to learn how to use this.

king.service's People

Contributors

jefking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

king.service's Issues

Throttle Dequeue

How do you ensure that a MAX number of dequeuing is occuring?

Handle Poison Message

Create a -poison queue for every queue, and handle messages that are poisoned (ie. over a certain threshold) and push them into the poison queue.

Queue Sharding

Enable an easy way to:

  • Create Shards
  • Queue to Shard 1-10
  • Dequeue from Shard 1-10

Task Count always 0?

Logging output:

Starting 2 tasks
Finished starting tasks 0/2 successfully.
Run finished

Layer Tasks

The ability to start tasks with delays between groups.
use case: initialization Tasks, where secondary tasks are dependent on resources being created.

LoggingProcessor

namespace King.Service.ServiceBus.Demo.Processors
{
    using System;
    using System.Diagnostics;
    using System.Threading.Tasks;

    public class LoggingProcessor : IBusEventHandler<object>
    {
        public Task<bool> Process(object data)
        {
            Trace.TraceInformation("{0}", data);

            return Task.FromResult<bool>(true);
        }

        public Task OnError(string action, Exception ex)
        {
            Trace.TraceError("Errored on {0}: {1}", action, ex.Message);

            return Task.FromResult<bool>(true);
        }
    }
}

RoleTaskManager Takes Factory[]

Enable the Role Task Manager to take an array of factories, so that people can break down their factory code; into simple focused pieces.

Start-Up should be not-aligned

When multiple processes are started at near the same time, with similar timings there can be competition for resources when running.
All tasks should be started with a second or a half second in between so that they are spread out better.

Log Metrics

We need a way to log metrics, of runs and duration of runs.
Look into pluggable, open source frameworks.
Worst case we plug into table storage and take the dependancy when it is enabled.

Recurring Runner

There should be a basic runner, which allows dequeue pollers to be run at even intervals.

Inverse Dynamic Timings

We should have timings that are the opposite of 'trying' to run as fast as possible...

Inverting the Backoff task might be valuable in some cases.

Dynamic Batch Sizes

If the current batch size isn't full, how do you know you can successfully handle a bigger batch size?

Service Name isn't valuable

King.Service.BackoffRunner+King.Service.Timing.BackoffTiming: Task Completed (Duration: 00:00:00.0231845).;

One Time Services (Initialization)

Currently we use IRunnable to create a task, that has a one time run. I would like to create a base class, or make it really simple to have a task that is run first in priority for initialization tasks.

NUnit

Switch to NUnit for testing

Restartable Tasks

Restart Tasks when they fail....
Tasks like Init tasks are not retried/restarted when they fail. However, if you are running long running tasks, like WCF/Event based task, if a failure occurs you need it reloaded.

Tasks as Lambda

We should be able to call code using a Lambda:
{
x => this.Method(22);
}

Tasks Started in Reverse Order

Code:

yield return new InitializeQueueTask(config.QueueName, config.ConnectionString);
yield return new InitializeTopicTask(config.TopicName, config.ConnectionString);
yield return new InitializeSubscriptionTask(config.TopicName, config.Subscription, config.ConnectionString);

yield return new CompanyQueuer(client);
yield return new CompanyDequeuer(client);

Logs:

King.Service.ServiceBus.Demo.Tasks.CompanyDequeuer started: True.
King.Service.ServiceBus.Demo.Tasks.CompanyQueuer started: True.
King.Service.ServiceBus.InitializeSubscriptionTask started: True.
King.Service.ServiceBus.InitializeTopicTask started: True.
King.Service.ServiceBus.InitializeQueueTask started: True.

Range

Create range class for general ranges
Range
Max X
Min X

Autoscaler

By providing a Task wrapper that knows how the task is performing, we can infer how many instances of said task should run.
Take for example a dequeue task that is sustaining 'full speed' for a long duration; it is easy to add another dequeue instance working off of the same queue to enable more throughput.
To ensure that no one piece of code hogs all of the systems resources we can put in place a governer that would ensure a minimum instance count, and a maximum instance count.

Queue Scaling

Adaptive Timing; buys some flexibility, but mostly is for cost saving purposes (let the service 'sleep' at night)
Dequeue Single/Batch: has to be done 'manually' in code
Scaling based on message build up in queue; add more handlers as the queue fills up

I think that the matrix here is really: Cost Vs. Throughput; where cost and throughput can be optimized automatically. low volume queues are find to dequeue single messages at low rates. as soon as you are hitting the single digit seconds time frame then it starts to make sense taking batches at slower rates; lastly if you are still unable to keep up, add more dequeue handlers.

Further breakdown is required, and figuring out 'when' the right times are is important, as well as ensuring that a single workload doesn't saturate a server (is something to think about).

Remove Initialization Tasks

Run init tasks once, and pull them off the stack

Currently they are held in memory as a background thread, which is relatively expensive.

Initialize Task; Make Scalable

For WCF, we use Initialize task, I don't think there is a great way to scale this...
For Service Bus Event Handlers, we can scale those by having more instances...

Data Types

Prefer TimeSpan over integers; to ensure that all code is convenient

Backoff Task Step Down

Current Backoff task: when work is done goes to minimum value...
Would it be more beneficial, if it stepped down to the previous attempt time frame?
That would mean that it would slowly get faster, as well as slowly get slower.

It wouldn't be ideal in a case where a large amount of work comes in quickly, especially if there are few instances dealing with the work load.

Run At minute Sensitivity

It is possible to miss the minute that the Run At task should fire at. Currently signalling every 61 seconds, this needs to be every 60 seconds to ensure we hit the minute.

Initialize Tasks

Initialize tasks not firing as period is too long for Timer?

[WaWorkerHost.exe] King.Azure.BackgroundWorker.Data.InitializeTableTask: Period must be less than 2^32-2.

Mono

Check out what it would take to get this running on Mono

Dequeue Polling Task

We should have a dequeuing task baked in with proper interfaces, so that we can use them to build out Service Bus dequeuing.

Exponential Backoff Task

There should be a service which knows how to do linear back off, when the service is not needed.

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.