Skip to content

Latest commit

 

History

History
155 lines (107 loc) · 4.29 KB

README.md

File metadata and controls

155 lines (107 loc) · 4.29 KB

golax performance

Intro

The reason for this project is this question made by Adrian Sampaleanu in golang-nuts.

The performance compared with the most popular alternative is very similar (actually golax performs slightly better) however code readability and maintainability is far better with golax implementation.

The results

List users

Retrieve user

GET letters/z/z

GET letters/z/z/z

Keep alive with 100 threads

Tests has been executed in a Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz and 16GiB RAM.

Run tests in your machine

Run all benchmarks for all frameworks:

make dependencies
make benchmark

Make and run golax:

make golax

Make and run gorilla:

make gorilla

Make and run chi:

make chi

Execute tests:

1 thread:

ab -n 20000 -c 1 http://localhost:9999/service/v1/users
ab -n 20000 -c 1 http://localhost:9999/service/v1/users/2
ab -n 20000 -c 1 http://localhost:9999/letters/z/z
ab -n 20000 -c 1 http://localhost:9999/letters/z/z/z

10 threads:

ab -n 200000 -c 10 http://localhost:9999/service/v1/users
ab -n 200000 -c 10 http://localhost:9999/service/v1/users/2
ab -n 200000 -c 10 http://localhost:9999/letters/z/z
ab -n 200000 -c 10 http://localhost:9999/letters/z/z/z

100 threads:

ab -n 200000 -c 100 http://localhost:9999/service/v1/users
ab -n 200000 -c 100 http://localhost:9999/service/v1/users/2
ab -n 200000 -c 100 http://localhost:9999/letters/z/z
ab -n 200000 -c 100 http://localhost:9999/letters/z/z/z

500 threads:

ab -n 200000 -c 500 http://localhost:9999/service/v1/users
ab -n 200000 -c 500 http://localhost:9999/service/v1/users/2
ab -n 200000 -c 500 http://localhost:9999/letters/z/z
ab -n 200000 -c 500 http://localhost:9999/letters/z/z/z

Keep alive:

ab -k -n 200000 -c 100 http://localhost:9999/service/v1/users
ab -k -n 200000 -c 100 http://localhost:9999/service/v1/users/2
ab -k -n 200000 -c 100 http://localhost:9999/letters/z/z
ab -k -n 200000 -c 100 http://localhost:9999/letters/z/z/z

About the implementations

All implement a CRUD API described here and:

  • Errors are returned in JSON format
  • All requests are logged to stdout and/or stderr

Golax

The code is the standard way a REST API should be implemented with golax.

Gorilla

Gorilla implementation has been done following Making a RESTful JSON API in Go article.

Chi

I am glad to know about Chi, it follows the same approach as golax and it has a very similar implementation.

About the code readability and maintainability

TODO: comment several points here, and how easy (or not) is adding middlewares/interceptors and routes.