Coder Social home page Coder Social logo

zirain / ext-proc-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ekkinox/ext-proc-demo

0.0 0.0 0.0 112 KB

Envoy ext-proc gRPC filter usage demo with golang

License: MIT License

Shell 1.12% JavaScript 17.35% Go 74.74% Dockerfile 6.79%

ext-proc-demo's Introduction

Envoy ext-proc gRPC filter demo

Advanced usage of Envoy ext-proc gRPC filter demonstration.

Table of contents

Concept

This project is testing in depth how you can work with Envoy ext-proc filter, especially when it comes to share data between processing steps.

This provides:

The intent (example to test ext-proc capabilities):

  • we want to extract a CSRF value and add it in a dedicated X-Extracted-Csrf response header
  • this CSRF can come directly form a X-Csrf header
  • or from a form post, in the csrf field

The workflow:

  • a request comes arrives on envoy (http://localhost:10000)
  • envoy starts a gRPC connection, via the ext-proc filter, to our external processor (:50051)
  • envoy streams the request headers to the external processor
  • if the request contains a X-Csrf header, it's stored in a variable and the request if propagated downstream to the service
  • if not, the external processor asks to be streamed with the request body, and the csrf post field is stored in a variable, and the request if propagated downstream to the service
  • the downstream service processes the request and generates a response
  • envoy stream the response to the external processor
  • the external processor add a new X-Extracted-Csrf response header with the csrf variable content

Usage

To test the stack, simply start the provided docker-compose stack:

docker-compose up -d

Then you can interact with the service through envoy on [POST] http://localhost:10000

  • by sending the X-Csrf header and check you get it back in the X-Extracted-Csrf response header
  • or by sending the csrf form post field and check you get it back in the X-Extracted-Csrf response header

Concurrency

The main goal of this project is to ensure that this pattern does not come with concurrency issues, especially because of the use, external processor side, of high scope variables across gRPC stream handling.

To validate there is actually no concurrency issues, the project provides 2 K6 benchmarking scripts (response code + header assertions) :

  • headerBench.js: to test under traffic the CSRF provided via header
  • bodyBench.js: to test under traffic the CSRF provided via form post

To run the scripts, you can run for example:

k6 run --vus 50 --iterations 100 k6/headerBench.js

ext-proc-demo's People

Contributors

ekkinox avatar xvzf avatar zirain 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.