https://github.com/manikupireddii/own_multi_thread_server
https://github.com/manikupireddii/own_multi_thread_server
mutlithreading threads threads-api
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/manikupireddii/own_multi_thread_server
- Owner: manikupireddii
- License: mpl-2.0
- Created: 2024-11-18T17:55:34.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-19T13:55:00.000Z (about 1 year ago)
- Last Synced: 2025-02-09T16:39:49.348Z (about 1 year ago)
- Topics: mutlithreading, threads, threads-api
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
Here's the `README.md` file for your multi-threaded HTTP server project:
```markdown
# Multi-Threaded HTTP Server in Node.js
This project demonstrates a multi-threaded HTTP server built using Node.js and the `worker_threads` module. It processes incoming requests concurrently using a pool of workers, improving performance for CPU-intensive tasks.
## Features
- Multi-threaded architecture using Node.js worker threads.
- Basic routing and dynamic responses based on request URL.
- Handles GET requests with basic routing (`/`, `/info`, `/health`).
- Scalable to handle higher concurrency through worker thread pooling.
## Requirements
- Node.js (>= v12.0)
## Installation
1. Clone the repository:
```bash
git clone (my url)
cd (my rep )
```
2. Install dependencies:
```bash
npm install
```
3. Start the server:
```bash
node src/server.js
```
4. Alternatively, you can use the shell script to start the server:
```bash
./scripts/start.sh
```
5. Visit [http://localhost:3000](http://localhost:3000) in your browser or use `curl` to test the server.
## Routes
- `/`: A welcome message.
- `/info`: Information about the server.
- `/health`: Health check message.
- `/unknown`: Will respond with "Not Found" for any unrecognized routes.
## Testing
To test the server, you can use Mocha or any other testing framework. The following tests are available:
- Respond to `GET /` with a welcome message.
- Respond to `GET /health` with a health message.
- Respond to unknown routes with a "Not Found" message.
To run the tests:
1. Make sure your server is not running.
2. Run the tests:
```bash
npm test
```
## Configuration
The server configuration, such as the number of worker threads and the port number, can be found in the `config/config.js` file.
Example config:
```javascript
module.exports = {
PORT: 3000,
NUM_WORKERS: require('os').cpus().length, // Number of CPU cores
};
```
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contributing
Feel free to open issues or pull requests if you find any bugs or want to add new features!
```
---
This `README.md` file provides an overview of the project, setup instructions, features, and testing guidelines. Make sure to replace the GitHub URL (`https://github.com/your-username/multi-threaded-server.git`) with the actual URL if you publish it on GitHub.