Giter Site home page Giter Site logo

travisnielsen / k8s-waitroom Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 0.0 339 KB

Proof-of-concept application that demonstrates rate-limiting of new user sessions via YARP.

License: MIT License

TypeScript 1.62% Dockerfile 2.63% C# 62.53% Bicep 31.68% HTML 1.53%

k8s-waitroom's Introduction

Virtual Wait Room for Kubernetes Services

This is a proof-of-concept application that demonstrates rate limiting new user sessions for a given workload hosted as services on Kubernetes. It is designed to eliminate the need for code changes on existing services and operate in a flexible, easy to configure manner.

Overview

This method of rate limiting helps address spikes in new sessions over a rolling one minute window. When new connections exceed the defined limit within the active window, new connection requests are redirected to a static site (Virtual Wait Room) and the URI path is "locked" for a defined period of time.

The following diagram illustrates the basics of the modified traffic flow. A Kubernetes ingress controller, Istio Ingress Gateway in this case, is configured to forward traffic matching a particular path (/auth) to a service that acts as a proxy (ServiceProxy). In this sample, ServiceProxy is implemented with Microsoft's Yet Another Reverse Proxy (YARP) toolkit. If there is capacity in the current new sesion window, an ASP.NET session is created and a proxy session cookie is inserted into the request flow and is finally maintained in the browser.

Fig 1. New session with capacity

The presence of this cookie, which is sent on subsequent requests, guarantees access to the backend service regardless of the session create block status.

Fig 2. Existing session

In a case where a client is attempting to create a new session and capacity is exceeded in the current window, ServiceProxy redirects the client to a static page. At this point, the proxy enters the session-create-block state where all new connection attempts are redirected to the static page until the session-create-block state expires (curently 1 minute). JavaScript running on the static page periodically re-tries connecting to the URL path.

Fig 3. New session no capacity

Run and Deploy

Follow the steps in these documents to run and deploy

Test

TBD

k8s-waitroom's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

nanofabricfx

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.