Coder Social home page Coder Social logo

pwfoo / serviceq Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gptankit/serviceq

0.0 2.0 0.0 134 KB

Super fault-tolerant gateway for HTTP clusters, written in Go. White paper for reference - https://github.com/gptankit/adareqmodel-paper

License: Apache License 2.0

Makefile 4.51% Go 95.49%

serviceq's Introduction

ServiceQ Build Status GoDoc

ServiceQ is a fault-tolerant gateway for HTTP clusters. It employs probabilistic routing to distribute load during partial cluster shutdown (k/n nodes experiencing downtimes, timeouts, connection loss etc) and buffers requests during total cluster shutdown (n nodes down). The buffered requests are forwarded in FIFO order when the cluster is available next.

Below graph shows the routing probability (P) on a down node (D) in a 8-node cluster with respect to number of requests (r). Notice how quickly the routing probability on D reduces as the requests on D start to fail. Depending on the rate of request, it will only take a few seconds (sometime even milliseconds) to move all requests away from D, thus ensuring more requests are routed to healthier nodes.

Note that, even when requests keep failing on D (however less), ServiceQ retries them on other nodes until they succeed. If they do not succeed on any of the nodes, they are buffered and periodically retried on the cluster (using the same approach above), until they succeed.

Noticeable features

  • HTTP Load Balancing
  • Probabilistic node selection based on error feedback
  • Failed request buffering and deferred forwarding
  • Request retries
  • Concurrent connections limit
  • Complete TLS/SSL support (automatic and manual)

Here are the steps to run ServiceQ -

Download

Clone the project into any directory in your workspace (say 'serviceq')

$ mkdir serviceq
$ git clone https://github.com/gptankit/serviceq serviceq/

Change into directory serviceq

How to Build

$ make ('make build' will also work)

Optional: make with debug symbols removed (~25% size reduction)

$ make build-nodbg

This will create a Go binary serviceq in the current directory

How to Install

Make sure the current user has root privileges, then -

$ make install

This will create a folder serviceq in /usr/local directory and copy the serviceq binary to /usr/local/serviceq and sq.properties file (serviceq configuration) to /usr/local/serviceq/config.

How to Run

Before running, make sure the mandatory configurations in /usr/local/serviceq/config/sq.properties are set (LISTENER_PORT, PROTO, ENDPOINTS, CONCURRENCY_PEAK) -

#sq.properties

#Port on which serviceq listens on
LISTENER_PORT=5252

#Protocol the endpoints listens on -- 'http' for both http/https
PROTO=http

#Endpoints seperated by comma (,) -- no spaces allowed, can be a combination of http/https
ENDPOINTS=http://my.server1.com:8080,http://my.server2.com:8080,http://my.server3.com:8080

#Concurrency peak defines how many max concurrent connections are allowed to the cluster
CONCURRENCY_PEAK=2048

Also, verify timeout value (default is set to 5s). Low value is preferable as it allows retries to be faster -

#Timeout (s) is added to each outgoing request to endpoints, the existing timeouts are overriden, value of -1 means no timeout
OUTGOING_REQUEST_TIMEOUT=5

By default deferred queue is enabled with all methods and routes allowed. These options can be controlled as -

#Enable deferred queue for requests on final failures (cluster down)
ENABLE_DEFERRED_Q=true

#Request format allows given method/route on deferred queue -- picked up if ENABLE_DEFERRED_Q is true
#DEFERRED_Q_REQUEST_FORMATS=POST /orders,PUT,PATCH,DELETE
#DEFERRED_Q_REQUEST_FORMATS=ALL
DEFERRED_Q_REQUEST_FORMATS=POST,PUT,PATCH,DELETE

After all is set -

$ sudo /usr/local/serviceq/serviceq

Refer wiki for more details: https://github.com/gptankit/serviceq/wiki

Feel free to play around and post feedbacks

serviceq's People

Contributors

gptankit avatar

Watchers

 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.