Code Monkey home page Code Monkey logo

api-benchmark's Introduction

Go vs Node Experiment Benchmark

Simple POST based create-user endpoint inserting into Postgres.

Most of the bottleneck is in the network between the app and postgres handling the inserts.

To run the Go version:

cd go-api
docker compose up --build

To run the Node.js version:

cd node-api
docker compose up --build

To run the Vegeta stress test:

cd load-tester/vegeta
./start.sh 3000 # 3000 req/s, you can try with more

Results

Running on a Ryzen 9 7950X3D with 96GB of DDR56000 and PCIe Gen 5 NVME.

Vegeta results for 3000 req/s for Go:

Starting Vegeta attack for 30s at 3000 requests per second...
Load test finished, generating reports...
Textual report generated: report_3000.txt


Requests      [total, rate, throughput]         89998, 2999.95, 2999.76
Duration      [total, attack, wait]             30.002s, 30s, 1.828ms
Latencies     [min, mean, 50, 90, 95, 99, max]  1.301ms, 2.348ms, 1.834ms, 2.909ms, 3ms, 3.823ms, 123.211ms
Bytes In      [total, mean]                     2429946, 27.00
Bytes Out     [total, mean]                     8279816, 92.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      201:89998
Error Set:

Vegeta results for 3000 req/s for Node.js (no cluster):

Starting Vegeta attack for 30s at 3000 requests per second...
Load test finished, generating reports...
Textual report generated: report_3000.txt


Requests      [total, rate, throughput]         89999, 3000.01, 2999.84
Duration      [total, attack, wait]             30.001s, 30s, 1.683ms
Latencies     [min, mean, 50, 90, 95, 99, max]  1.448ms, 4.458ms, 1.931ms, 3.097ms, 3.249ms, 97.854ms, 290.991ms
Bytes In      [total, mean]                     2339974, 26.00
Bytes Out     [total, mean]                     8279908, 92.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      201:89999
Error Set:

Remarks

  • In Docker Compose, prefer network_mode: host, as the docker internal networking adds considerable bottleneck
  • Node.js will undoubtfully be "slower". Average, time per request will be slower than Go
  • Adding Node.js Cluster can handle more requests/sec but also adds extra networking and coordination overhead
  • Yes. Go will be faster
  • Should you choose Go blindly? No, only if throughput is the only criteria, disregarding productivity, integration, team preference, toolset, etc.

api-benchmark's People

Contributors

ocodista avatar akitaonrails 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.