Categorygithub.com/Avish34/tcp-server
modulepackage
1.0.0
Repository: https://github.com/avish34/tcp-server.git
Documentation: pkg.go.dev

# README


                   

tcp-server

An adaptable multi-threaded TCP server equipped with built-in rate limiting, affording you the flexibility to tailor thread configurations and rate limits to your specific needs. It comes with metrics support like total request processed by server at a given time, useful for users to analyse the server performance.

Installation

Prerequisite

  1. Docker
  2. Code editor.

Steps to run server

  1. git clone https://github.com/Avish34/tcp-server
  2. cd tcp-server
  3. make start-service

After running (3) command, you should see this output. Server will be listening on 8080. To edit the port and other settings, you can find customise section below in the README.

 ⠿ Container tools-prometheus-1  Started                                                                                                                          
 ⠿ Container tools-tcp-server-1  Started  

Send request to the server. You should see "Hello world as response"

curl http://localhost:8080
Hello world !

Metrics

To check the total request accepted by the server. Open http://localhost:9090/. Search for total_request in Expression search bar. Check the below image for reference.

Screenshot 2023-09-10 at 12 08 50 PM

Customisation

This server comes with capability to throttle request using rate limiting, serving multiple request using workers. This is completly customisable, it can be done via changing the .env file present in

tools/dockerfiles/tcp-server/.env

You should be able to see the below parameters and can change it according to use system capabilites and the requirements.

SERVER_PORT=8080 SERVER_URL=0.0.0.0 SERVER_QUEUE_SIZE=5 SERVER_WORKERS=2 SERVER_TOKEN_LIMIT=1 SERVER_TOKEN_RATE=5

# Packages

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