Skip to content

Latest commit

 

History

History
87 lines (62 loc) · 2.38 KB

Readme.md

File metadata and controls

87 lines (62 loc) · 2.38 KB

Here's the README.md file for your multi-threaded HTTP server project:

# 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 )
  1. Install dependencies:

    npm install
  2. Start the server:

    node src/server.js
  3. Alternatively, you can use the shell script to start the server:

    ./scripts/start.sh
  4. Visit 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:
    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:

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 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.