Git Product home page Git Product logo

api-bench's Introduction

api-bench

API systems benchmarks

This project aims to compare popular API styles. The API styles/systems compared are:

  • Apache Thrift
  • CNCF gRPC/ProtoBuf
  • JSON/HTTP (not yet)
  • REST/ROA

Repo layout:

  • root - contains no files with the exception of this README
    • thrift - contains all of the Apache thrift test files
    • grpc - contains all of the gRPC test files
    • rest - contains all of the RESTful service test files

The API tested in all cases is something like this (in pseudo-code):

struct date {
    i16 year
    i16 month
    i16 day
}

struct project {
    date inception
    string name
    string host
}

struct create_result {
    1: i16 code
    2: string message
}

interface Projects {
    project get(string name)
    create_result create(project p)
}

The RESTfult version uses the resource route /projects/. To get a project in REST we use GET /projects/[name] and to create a project we use PUT /projects/[name].

Client

All client programs must be named client and accept a server ip, port and action on the command line. Action 1 calls the get() function, Action 2 calls the create() function and Action 3 calls create() then get(). This allows us to seperate performance for read and write operations (important when looking at REST).

$ client --host 10.4.6.2 --port 9090 --action 1

If no command line arguments are provided, the client should use localhost, port 9090 and action 1. All client project files for a given language must be in a directory named ./[apisys]/[lang]-cli. For example: ./thrift/python-cli.

Server

All server programs must be named server and all servers must listen on port 9090 on all interfaces. Servers should accept an alternative port on the command line. All server project files for a given language must be in a directory named ./[apisys]/[lang]-svr. For example: ./thrift/python-svr.

In response to get() all servers should return data identical to the following:

    def get(self, name):
        p = ttypes.Project()
        p.name = name
        p.host = "ASF"
        p.inception = ttypes.Date()
        p.inception.year = 2007
        p.inception.month = 1
        p.inception.day = 10
        return p

In response to create() servers should return data identical to the following:

    def create(self, p):
        #self.projects[p.name] = p
        return CreateResult(200, "ok")

The benchmark goal is not to test how quickly languages execute complex logic, rather it is to compare the performance of the API mechanics.

Apache Thrift

To compile thrift APIs use:

$ docker run -v ~/api-bench/thrift/project.thrift:/project.thrift -v ~/api-bench/thrift/[appdir]:/out thrift thrift -o /out -gen [lang] project.thrift

Output will be owned by root so you may then want to:

$ chown -R user ~/api-bench/*

api-bench's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nsuke

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.