An open API service indexing awesome lists of open source software.

https://github.com/pavanscales/own_multi_thread_server


https://github.com/pavanscales/own_multi_thread_server

mutlithreading threads threads-api

Last synced: 4 months ago
JSON representation

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.