Giter Site home page Giter Site logo

nodejs-istio-circuit-breaker's Introduction

Istio Circuit Breaker Mission for Node.js

Purpose

Showcase Circuit Breaking in Istio in Node.js applications

Prerequisites

Launcher Flow Setup

If the Booster is installed through the Launcher and the Continuous Delivery flow, no additional steps are necessary.

Skip to the Use Cases section.

Local Source to Image Build (S2I)

Prepare the Namespace

Create a new namespace/project:

oc new-project <whatever valid project name you want>

Build and Deploy the Application

With Source to Image build (S2I)

Run the following commands to apply and execute the OpenShift templates that will configure and deploy the applications:

find . | grep openshiftio | grep application | xargs -n 1 oc apply -f

oc new-app --template=nodejs-istio-circuit-breaker-greeting-service -p SOURCE_REPOSITORY_URL=https://github.com/nodeshift-starters/nodejs-istio-circuit-breaker -p SOURCE_REPOSITORY_REF=master -p SOURCE_REPOSITORY_DIR=greeting-service
oc new-app --template=nodejs-istio-circuit-breaker-name-service -p SOURCE_REPOSITORY_URL=https://github.com/nodeshift-starters/nodejs-istio-circuit-breaker -p SOURCE_REPOSITORY_REF=master -p SOURCE_REPOSITORY_DIR=name-service

Use Cases

Any steps issuing oc commands require the user to have run oc login first and switched to the appropriate project with oc project <project name>.

Without Istio Configuration

  1. Create a Gateway and Virtual Service in Istio so that we can access the service within the Mesh:
    oc apply -f istio-config/gateway.yaml
    
  2. Retrieve the URL for the Istio Ingress Gateway route, with the below command, and open it in a web browser.
    echo http://$(oc get route istio-ingressgateway -o jsonpath='{.spec.host}{"\n"}' -n istio-system)/nodejs-istio-circuit-breaker/
    
  3. The user will be presented with the web page of the Booster
  4. Click "Start" to issue repeating concurrent requests in batches of 10 to the greeting service
  5. Click "Stop" to cease issuing more requests
  6. The number of concurrent requests can be set to anything between 1 and 20
  7. There should be no failures and all calls are ok

With Istio Configuration

Initial Setup

  1. Run oc project <project> to connect to the project created by the Launcher, or one you created in a previous step
  2. Create a VirtualService for the name service, which is required to use DestinationRule later
    oc create -f istio-config/virtual-service.yml -n $(oc project -q)
    
  3. Trying the application again you will notice no change from the current behavior

Istio Circuit Breaker Configuration

  1. Apply a DestinationRule that activates Istio's Circuit Breaker on the name service, configuring it to allow a maximum of 100 concurrent connections
    oc create -f istio-config/initial-destination-rule.yml -n $(oc project -q)
    
  2. Trying the application again you should see no change, as we're only able to make up to 20 concurrent connections which is not enough to trigger the circuit breaker.
  3. Remove the initial destination rule
    oc delete -f istio-config/initial-destination-rule.yml
    
  4. Apply a more restrictive destination rule
    oc create -f istio-config/restrictive-destination-rule.yml -n $(oc project -q)
    
  5. Trying the application again you can see about a third of all requests are triggering the fallback response because the circuit is open
  6. If we check "Simulate load", which adds a delay into how quickly the name service responds, and click "Start". We now see that the majority of our calls trigger the fallback as our name service takes too long to respond.

nodejs-istio-circuit-breaker's People

Contributors

helio-frota avatar lholmquist 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.