10.0.0 • Published 4 days ago

@mapbox/watchbot v10.0.0

Weekly downloads
8,128
License
BSD-2-Clause
Repository
github
Last release
4 days ago

Build Status

watchbot

A library to help run a highly-scalable AWS service that performs data processing tasks in response to external events. You provide the messages and the logic to process them, while Watchbot handles making sure that your processing task is run at least once for each message. Watchbot is similar in many regards to AWS Lambda, but is more configurable, more focused on data processing, and not subject to several of Lambda's limitations.

Helpful lingo

  • queue: An SQS queue is a "backlog" of messages for your stack to process that helps to guarantee every message gets processed at least once.
  • message: A message in the queue represents some job to be processed. Generally, you are responsible for sending messages to your stack by publishing to Watchbot's SNS topic, or optionally by POST to a webhook endpoint (see WatchbotUseWebhooks in the parameters section below).
  • worker: CLI command/subprocess responsible for processing a single message. You define the work performed by the worker through the command property in the cloudformation template. Watchbot sets environment variables for the subprocess that represent the content of a single message.
  • watcher: The main process in the container that polls the queue, spawns worker subprocesses to process messages, and tracks results.
  • task: The ECS task that contains both the watcher main process and all of the worker subprocesses. You specify how many tasks to run using the maxSize and minSize parameters in the cloudformation template. The service scales the number of tasks based on the existence of messages in the queue.
  • cluster: An ECS cluster of EC2s that are used to run the watcher and worker containers that make up your service.
  • template: A CloudFormation template defining the resources Watchbot needs

What you provide:

  • a cluster that Watchbot will run on
  • a docker image representing your task, housed in an ECR repository and tagged with a git sha or a git tag
  • a CloudFormation template defining any configuration Parameters, Resources, and Outputs that your service needs in order to perform its processing.

:bulb: Other prerequisites:

  • cloudformation-kms-production deployed according to the instructions in cloudformation-kms. Makes encryption of sensitive environment variables that need to be passed to ECS simple using cfn-config.

What Watchbot provides:

  • a queue for you to send messages to in order to trigger your workers to run
  • optionally(http://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html) with permission to send messages to the queue
  • an ECS TaskDefinition for your worker, using the image you provide
  • one or more watcher containers that run continuously on your cluster, polling the queue, running a worker for each message, removing messages from the queue as workers complete, and managing worker failures and retries
  • a script to help you include the resources Watchbot needs to run in your template

Building a Watchbot service

  1. Create a Github repository for your code.
  2. Write and test the code that a worker will perform in response to a message.
  3. Write a Dockerfile at the root of your repository which defines the steps required to bootstrap a worker. Rather than specifying a CMD instructions, use the command property in the cloudformation template to indicate what will be executed when your worker is launched in response to a message. Note that message details will be provided as environment variables to your worker subprocess, and that your worker's exit code will determine whether the message is deleted or returned to the queue (see below).
  4. Use the Dockerfile to build an image and store it in an ECR repository. See ecs-conex for a CI framework to do this for you whenever you commit to the repository.
  5. Write and deploy your service using a CloudFormation template that watchbot helps you to build.

More documentation

  1. Building a Watchbot template
  2. The worker's runtime environment
  3. What happens when workers fail?
  4. Logging and metrics
  5. Using Watchbot's reduce-mode
  6. Watchbot's command-line utilities
  7. Watchbot's CloudWatch alarms
10.0.1-1

4 days ago

10.0.0

3 months ago

10.0.0-alpha.5

4 months ago

10.0.0-alpha.4

4 months ago

10.0.0-alpha.3

4 months ago

10.0.0-alpha.2

4 months ago

10.0.0-alpha.1

4 months ago

10.0.0-alpha.0

4 months ago

10.0.0-beta.14

4 months ago

10.0.0-beta.17

4 months ago

10.0.0-beta.18

4 months ago

10.0.0-beta.15

4 months ago

10.0.0-beta.16

4 months ago

9.0.1-dev1

7 months ago

9.0.1

7 months ago

9.0.0

8 months ago

9.0.0-dev1

8 months ago

8.0.1

1 year ago

8.0.0-rc.8

2 years ago

8.0.0-rc.5

2 years ago

8.0.0-rc.6

2 years ago

8.0.0-rc.7

2 years ago

8.0.0

2 years ago

7.0.0

3 years ago

7.0.0-0

3 years ago

6.1.1

3 years ago

6.1.0

4 years ago

6.0.0

4 years ago

5.1.0-beta.1

4 years ago

5.0.0

4 years ago

5.0.0-beta1

4 years ago

4.20.2

4 years ago

4.20.1

4 years ago

4.20.0

4 years ago

4.20.0-4

4 years ago

4.20.0-3

4 years ago

4.20.0-2

4 years ago

4.20.0-1

4 years ago

4.20.0-0

4 years ago

4.19.0

4 years ago

4.18.1-0

4 years ago

4.17.1-0

4 years ago

4.18.0

4 years ago

4.17.0

5 years ago

4.16.1

5 years ago

4.16.0

5 years ago

4.15.1

5 years ago

4.15.0

5 years ago

4.14.0

5 years ago

4.13.3

5 years ago

4.13.2

5 years ago

4.13.1

6 years ago

4.13.0

6 years ago

4.12.0

6 years ago

4.12.0-1

6 years ago

4.11.2

6 years ago

4.11.1

6 years ago

4.11.0

6 years ago

4.10.0

6 years ago

4.9.1-4

6 years ago

4.9.1-3

6 years ago

4.9.1-2

6 years ago

4.9.1-1

6 years ago

4.9.1-0

6 years ago

4.9.1

6 years ago

4.8.2

6 years ago

4.8.0

6 years ago

4.7.2-2

6 years ago

4.7.1

6 years ago

4.7.0

6 years ago

4.6.0

6 years ago

4.5.5-1

6 years ago

4.5.6-3

6 years ago

4.5.6

6 years ago

4.5.6-2

6 years ago

4.5.5

6 years ago

4.5.6-1

6 years ago

4.5.6-0

6 years ago

4.5.5-0

6 years ago

4.5.3

6 years ago

4.5.3-0

6 years ago

4.5.2

6 years ago

4.5.1

6 years ago

4.5.0

6 years ago

4.4.3

6 years ago

4.2.1-6

6 years ago

4.2.1-5

6 years ago

4.2.1-4

6 years ago

4.4.2

6 years ago

4.2.1-3

6 years ago

4.4.1

6 years ago

4.2.1-2

6 years ago

4.4.0

6 years ago

4.2.1-1

6 years ago

4.3.0

6 years ago

4.2.1-0

6 years ago

4.2.0

6 years ago

4.1.1

6 years ago

4.1.0

6 years ago

4.0.0

6 years ago

3.5.1

6 years ago

3.5.0

6 years ago

3.4.1

6 years ago

3.4.0

7 years ago

3.3.0

7 years ago

3.2.1-cf-join

7 years ago

3.2.1

7 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.5.2

7 years ago

2.5.1

7 years ago

2.5.0

7 years ago

2.4.0

7 years ago

2.4.0-dev1

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.4

7 years ago

2.2.3

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.5.1-0

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.6

7 years ago

1.3.5

7 years ago