A Java project that tracks how many requests were received within a recent time window.
This project was built to practice queues and understand how systems monitor recent activity without storing old, unnecessary data.
The program stores request timestamps in a queue.
When a new request arrives:
- Add the timestamp to the queue.
- Remove requests that are outside the time window.
- Return the number of requests currently inside the window.
- Java
- Queue
- LinkedList
- Queue Data Structure
- Sliding Window Technique
- Time-Based Processing
Request at 1 ms -> 1 request(s) in window
Request at 100 ms -> 2 request(s) in window
Request at 3001 ms -> 3 request(s) in window
Request at 3002 ms -> 3 request(s) in window
How to use a queue and sliding window approach to efficiently track recent events, a technique commonly used in rate limiting and traffic monitoring systems.