Git Product home page Git Product logo

json-tcp-lb's Introduction

json tcp lb

Docker Automated Build Docker Build Status

This is a simple line based tcp load balancing proxy. It is designed to work with newline delimited json, but will work with any line based protocol.

This is different from a basic TCP proxy in that it will load balance data in a single connection across multiple destinations.

Features

  • Load balancing to multiple connections across multiple targets.
  • Failed transmissions will be retried to avoid ever losing data.
  • Target failover and failback.

Implementation

  • The proxy will start up N worker connections to each target.
  • The proxy will read data from the incoming connection into a 16KB buffer.
  • The buffer will be split cleanly on a newline boundary, or combined with additional data until at least one newline is seen.
  • The buffer containing one or more lines is places onto a channel and will be pulled by a worker and transmitted to a target.
  • If any of the worker connections fail, it will attempt to connect to a random target instead.
  • Every 5 minutes it will attempt to reconnect to its original target.

Usage

Usage of ./json-tcp-lb:
  -addr string
        Address to listen on (default "0.0.0.0")
  -port int
        Port to listen on (default 9000)
  -target string
        Address to proxy to. separate multiple with comma (default "127.0.0.1:9999")
  -connections int
        Number of outbound connections to make to each target (default 4)

Container Usage

The Dockerfile can be used to build the tcp lb in a container, then run like the following example:

docker build -t json-tcp-lb .
docker run -p ${LISTEN_PORT}:${LISTEN_PORT} -target ${TARGET_STRING} json-tcp-lb

Alternatives

I'm not aware of any simple alternatives. This is similar to something like gRPC load balancing across a single http/2 session in something like Envoy. It's likely possible to add 'newline delimited' data as a codec in Envoy or another load balancer.

json-tcp-lb's People

Contributors

alrs avatar johnclawson avatar justinazoff avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

json-tcp-lb's Issues

Using Encrypted Connections

Is there a way to use this with encrypted data? From what it looks like, in order for the program to see the payload, it needs to be unencrypted. Any details? Thanks!

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.