Categorygithub.com/Bronsun/RequestCounter
module
0.0.0-20220613232636-210510731a1e
Repository: https://github.com/bronsun/requestcounter.git
Documentation: pkg.go.dev

# README

RequestCounter

Request Counter is a simple solution for counting http requests on the multiple server instances.

Definitions

  • Cluster - contains all instances of HTTPserver
  • Instance - one instance of HTTPserver

It counts the number of requests to the single server instance and also counts all requests to the cluster. Total number of requests to the cluster is saved to Redis. To protect app from race condition, saving to redis is based on transactions. This solution is great for accuracy in number of requests, however, HTTP Handler function is slower due to waiting for transaction to be closed.

Docker-compose is used as a conterization solution, but it also simulates 3 instances using Replica method. NGINX is used as the main reverse proxy solution.

Requirements

You need to install the following tools:

RUN & BUILD

Build project in docker:

make build-docker

Run project in docker

make run-docker

Clear docker containers

make clean-docker

Tools used

NGINX

It is used as a reverse proxy for our web server.

REDIS

It is used as key-value store to saving total number of requests from all instances

Packages

In project was used Redis, as key-value store for saving total numbers of requests on all server instances. For easier development Redis package was used as a solution for connecting to database.

https://github.com/go-redis/redis

# Packages

No description provided by the author
No description provided by the author