# 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
- Docker
- Code editor.
Steps to run server
- git clone https://github.com/Avish34/tcp-server
- cd tcp-server
- 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.
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