https://github.com/goldenreynard/tcp_server
Making a TCP server which is multithreaded and can do Parallel Processing
https://github.com/goldenreynard/tcp_server
golang multithreading server tcp-server
Last synced: over 1 year ago
JSON representation
Making a TCP server which is multithreaded and can do Parallel Processing
- Host: GitHub
- URL: https://github.com/goldenreynard/tcp_server
- Owner: goldenreynard
- Created: 2023-04-22T02:23:11.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-22T02:25:48.000Z (about 3 years ago)
- Last Synced: 2025-01-23T17:55:22.346Z (over 1 year ago)
- Topics: golang, multithreading, server, tcp-server
- Language: Go
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TCP Server made using Go
- TCP is the most reliable way for two machines to talk to each other over the network.
- TCP servers are designed to handle and serve multiple TCP connections.
- A TCP server is a simple process that runs on a machine and listens to a port that understands TCP.
## First Part: Accepting a single request
- First block the port: 1729 for the connection
- Made the connection open
- Make the do function which
- Accepts the request
- Read the connection string
- Process the Request
- Write back to the server
- Close the request
---
## Accepting Multiple Request - Single threaded
- Built on the top of the first request
- We Made the connection to run infinitely using the for loop
- Can accept the multiple request
- First Process the first incoming request then when finished move to the next one
- Single threaded i.e One Request at one time
---
## Multithreading - Parallel Processing
- Accepting multiple request at the same time
- When accepting the request the function which is responsible for processing the request will go to the other thread
- Main thread then can process the next incoming request
- Server can process the multiple request at the same time
> if Large numbers of the request comes then it will be thread overloading which can crash the server limits
---
## Improvements to the Multithreading
- Limiting the number of threads
- Connection pooling: fixed time for a client to send the request
- Making thread Pool i.e Fixed number of the thread available
- TCP backlog queue configuration i.e how many connection you want in the backlog
> **SOURCE**: [Link](https://www.youtube.com/watch?v=f9gUFy-9uCM)