Coder Social home page Coder Social logo

epsagon / kinesis-autoscaler Goto Github PK

View Code? Open in Web Editor NEW
4.0 8.0 3.0 1.04 MB

Autoscaling solution for Kinesis data streams

License: Apache License 2.0

Python 100.00%
kinesis kinesis-data-streams serverless aws autoscaling cloudformation-stack

kinesis-autoscaler's Introduction

Kinesis Autoscaler

An easy to deploy autoscaling solution for Kinesis data streams.
Read more about the motivation, design and comparison to the native on-demand mode on the Epsagon and Cisco blogs.

Introduction

AWS Kinesis data streams service doesn't have native autoscaling support.
This solution purpose is to fill that need by automatically handling the scaling of Kinesis data streams in order to prevent data loss, avoid manual developer intervention and save cost.

Solution Architecture

architecture

The suggested solution consists of 3 stages: triggers, delivery and execution.

  • CloudWatch alarms - Defined for each stream that is subscribed to the autoscaling service. Responsible for starting the scaling operation by publishing to the relevant autoscaling service SNS topic.
  • SNS topics - Exported by the autoscaling service and used as the entry point to the service. Responsible for invoking the relevant scaling lambda when receiving a message from the scaling alarms.
  • Scaling lambdas - Calculates the target shard count, updates the stream and alarms according to it and writes a result log to a DynamoDB table.

Usage

  • Deploy the autoscaling service CloudFormation stack.
  • Create 2 alarms (scale-up/scale-down) for each subscribed stream.
  • Wire the alarms to the relevant exported SNS topics of the autoscaling service.

Example of how to create alarms and subscribe a stream to the autoscaler service can be found here.

Deployment

Prerequisites

Service Deployment

The service is deployed using the Serverless Framework.
Make sure to configure your AWS credentials (as environment variables or AWS profile) before running any command that interacts with AWS.

From the project root:

  • npm install - Installs the Serverless Framework plugins
  • serverless deploy - Deploys the service to AWS as a CF stack

Region and Stage

By default, the service is deployed to us-east-1 as a dev stage.
Overriding that default configuration can be done by passing the stage and region flags to the Serverless Framework deploy command (e.g. sls deploy --region eu-west-1 --stage production).

Usage Remarks and (current) Limitations

  • Alarm names should be identical and contain either scale-up / scale-down in their name.
    For example, example-stream-scale-up-alarm and example-stream-scale-down-alarm.
  • Each alarm must have a math expression with the id shardCount and the current shard count of the stream (which will be updated automatically on each scale operation).
  • Each alarm should have incomingBytes and/or incomingRecords metrics, as they are used for parsing the stream name.

kinesis-autoscaler's People

Contributors

adavidai avatar ophiryael avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.