Git Product home page Git Product logo

gogo's Introduction

Golang REST API boiterplate

Requirement:

  • Go v1.18.
  • Docker v20.10.14.
  • Docker-compose v2.5.1.

Docs:

Demo:

user: anonymous
pass: anonymous

Installation

go mod download

Running with docker compose

# build rest_api package
docker build -t api:multistage -f Dockerfile.multistage.api .

# tag api
docker image tag api:multistage api

# build indexer package
docker build -t indexer:multistage -f Dockerfile.multistage.indexer .

# tag indexer
docker image tag indexer:multistage indexer

# run api with Redis, RabbitMQ, ElasticSearch, Postgres database
docker-compose up

Running Redis, RabbitMQ, ElasticSearch, Postgres database

# run api with Redis, RabbitMQ, ElasticSearch, Postgres database
docker-compose up redis rabbitmq elasticsearch postgres

Running indexer app

The app will help indexing data into elastic search.

Require: RabbitMQ, ElasticSearch

go run ./packages/indexer/main.go

Running tool insert fake user

The app will help get users ramdom from randomuser.me, then insert to Postgres database.

Require: RabbitMQ, Postgres

go run ./packages/random_user/main.go

Running the rest API local

Require: RabbitMQ, Postgres, ElasticSearch

go run ./packages/rest_api/main.go

Load test: Wrk

Cache

wrk -t6 -c100 -d15s https://api.tdo.works/api/v1/users-cache
Running 15s test @ https://api.tdo.works/api/v1/users-cache
  6 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   227.11ms   17.19ms 318.56ms   76.39%
    Req/Sec    70.48     21.42   141.00     73.44%
  6044 requests in 15.10s, 13.25MB read
Requests/sec:    400.35
Transfer/sec:      0.88MB

No Cache

wrk -t6 -c100 -d15s https://api.tdo.works/api/v1/users
Running 15s test @ https://api.tdo.works/api/v1/users
  6 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   581.02ms  217.44ms   1.56s    68.91%
    Req/Sec    27.78     15.62    89.00     65.57%
  2304 requests in 15.03s, 5.05MB read
Requests/sec:    153.25
Transfer/sec:    343.92KB

gogo's People

Contributors

trung051093 avatar trungdo0510 avatar trungdo051093 avatar

Stargazers

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