A high-performance Rust tool designed to ping multiple URLs concurrently. This project utilizes the Tokio runtime for asynchronous execution and the Reqwest library for handling HTTP requests.
- Asynchronous Concurrency: Pings multiple URLs simultaneously using
tokio::task::spawn. - Latency Tracking: Measures and displays the time taken for each request (e.g.,
200 OK (417.8867ms)). - File Input: Reads the target URLs from an external
urls.txtfile. - Rate Limiting: Employs a
Semaphoreto control the number of concurrent requests, preventing system overwhelm. - Robust Error Handling: Gracefully handles network errors and non-responsive URLs without crashing.
- Status Reporting: Prints each URL's status code, latency, or a descriptive error message to the console.
Ensure you have the following installed on your system:
The project relies on:
tokio: Asynchronous runtime for Rust.reqwest: Ergonomic HTTP client for Rust.
-
Clone the repository (if applicable) or navigate to the project directory:
cd concurrent_url_pinger -
Prepare your URLs: Create a file named
urls.txtin the root directory and add one URL per line:https://www.rust-lang.org https://www.google.com -
Build the project:
cargo build
-
Run the application:
cargo run
Pinging 11 URLs concurrently...
https://www.google.com -> 200 OK (712.2399ms)
https://www.github.com -> 200 OK (450.3848ms)
https://www.rust-lang.org -> 200 OK (2.4659965s)
https://invalid-url-example.com -> Error: error sending request for url...
Done!
You can adjust the concurrency limit in the main.rs file within the ping_urls call:
ping_urls(urls, 5).await; // Change '5' to your desired concurrency level- Retry Logic: Automatically retry failed requests.
- Export Results: Save results to a CSV or JSON file.
This project is open-source and available under the MIT License.