LogAnalyzer is a java Spring boot application designed to efficiently parse and analyze log files. This project serves as a practical exploration into the benefits of using a thread pool for concurrent task processing, comparing its performance against single-threaded and traditional multi-threaded models.
The primary goal of this project is to understand and demonstrate how a thread pool can significantly improve the performance of I/O-bound or parallelizable tasks, such as processing multiple log files. By managing a pool of worker threads, the application minimizes the overhead of thread creation and destruction, leading to faster and more efficient log analysis.
This project was built as a learning exercise to deepen my understanding of concurrent programming concepts in java.
- Concurrent Log Processing: Analyzes multiple log files simultaneously.
- Efficient Thread Management: Utilizes a thread pool to manage concurrent operations, reducing overhead and improving throughput.
- Performance Comparison: The design allows for easy comparison between single-threaded, multi-threaded, and thread pool-based approaches.
The application creates a fixed-size pool of worker threads upon startup. When new log analysis tasks are submitted, they are placed into a queue. Idle threads in the pool pick up tasks from this queue and execute them. This architecture avoids the costly process of creating a new thread for every single task.
To get a local copy up and running, follow these simple steps.
- Java, Spring Boot
- ThreadPoolExecutor
- Clone the repository:
git clone https://github.com/Surajhub21/LogAnalyzer.git
- Navigate to the project directory:
cd LogAnalyzer - Compile the source code:
javac --release 21 App.java
- Run the application:
./LogAnalyzer
Through this project, I've observed the following:
- Reduced Latency: The thread pool model shows significantly lower delay in processing tasks compared to creating new threads for each task, especially when dealing with a large number of smaller files.
- Resource Efficiency: By reusing threads, the application consumes fewer system resources.
- Scalability: The thread pool approach is more scalable when the number of concurrent tasks increases, providing more consistent performance.
This project has been a fantastic hands-on experience in understanding the practical applications and advantages of advanced concurrency patterns in java.
Contributions, issues, and feature requests are welcome!