Giter Club home page Giter Club logo

grpcgoesbrr's Introduction

gRPC goes BRRR!

a POC to learn gRPC, and playaround in a imaginary scenario, Where you want the use a ML model in python, but want to expose somesort other BACKEND to clients, for whatever reason:

  • productivity
  • performance
  • security
  • legacy
  • stubbornness πŸ™ƒ

altho obviously you could do this over a stupid rest API.

Today I decided to do it over a stupid gRPC API, to reduce request latency, resource utilization and waste an evening.

BEHOLD THE GREATEST OF DIAGRAMS!!! (took 5 minutes πŸ˜‹)

Some client that
you convinced to use
your backend!
another server or
somesort of UI
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SomeClient  β”‚         β”‚ Node Backend β”‚                   β”‚Python Backendβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
        β”‚                       β”‚                                   β”‚
        β”‚                       β”‚                                   β”‚
        β”‚ POST: {transaction_id}β”‚                                   β”‚
        β”‚ /api/FraudActivity    β”‚                                   β”‚
        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚                                   β”‚
        β”‚+[AUTH/PERMISSION]     β”‚ rpc: package fraud_detection: FraudDetectionService(PredictFraud)
        β”‚                       β”‚                              β”Œβ”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β–Ί β”‚         β”‚
        β”‚                       β”‚message PredictionRequest {   β”‚    β”‚Load model
        β”‚                       β”‚    int64 transaction_id      β”‚    β”‚         β”Ό
        β”‚                       β”‚    double amount             β”‚    β”‚ExtractsFeature
        β”‚                       β”‚    int64 time                β”‚    β”‚         β”Ό
        β”‚                       β”‚    int32 age_of_account      β”‚    β”‚Do Prediction
        β”‚                       β”‚    int32 number_of_transactions   β”‚         β”‚
        β”‚                       β”‚}                             β”‚    β”‚         β”‚
        β”‚                       β”‚                              β”‚    β”‚         β”‚
        β”‚                       │◄─────────────────────────────┼─────         β”‚
        β”‚                       β”‚ message PredictionResponse { β””β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                       β”‚     int64 transaction_id          β”‚
        β”‚                       β”‚     bool predicted_label          β”‚
        β”‚                       β”‚     double fraud_probability      β”‚
        β”‚                       β”‚ }                                 β”‚
        │◄───────────────────────                                   β”‚
        β”‚                       β”‚                                   β”‚
        β”‚{                      β”‚                                   β”‚
        β”‚    "transaction_id": "Y12a34x56",                         β”‚
        β”‚    "predicted_label": true,                               β”‚
        β”‚    "fraud_probability": 99.99,                            β”‚
        β”‚}                      β”‚                                   β”‚
        β”‚                       β”‚                                   β”‚
        β”‚                       β”‚                                   β”‚

grpcgoesbrr's People

Contributors

wassef911 avatar

Watchers

 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.