The UniqueIDTracker-Service
is a high-performance REST service designed to handle at least 10,000 requests per second. The service processes incoming requests, logs unique IDs, and integrates with external systems such as Redis for deduplication, Kafka for distributed messaging, and a load balancer for horizontal scaling. It is implemented using Java and Spring Boot and is containerized for easy deployment.
-
High-Performance REST API
- Endpoint:
/api/UniqueIDTracker/accept
- Accepts an integer
id
as a mandatory query parameter and an optional stringendpoint
. - Returns:
- "ok" for successful processing.
- "failed" in case of errors.
- Endpoint:
-
Unique ID Tracking
- Tracks unique requests based on the
id
parameter. - Uses Redis for distributed deduplication across multiple instances.
- Tracks unique requests based on the
-
Scheduled Reporting
- Logs the count of unique requests every minute.
- Sends this count to a Kafka topic for distributed processing.
-
Endpoint Integration
- When an
endpoint
is provided, sends an asynchronous POST request with the unique request count and additional payload.
- When an
-
Clone the repository:
git clone <repository-link> cd UniqueIDTracker-Service
-
Build the Docker image:
docker build -t uniqueIDTracker-service .
-
Start the application using Docker Compose:
docker-compose up
The application is configured via the application.properties
file. Key configurations include:
- Redis:
- Host:
redis
- Port:
6379
- Host:
- Kafka:
- Bootstrap Servers:
kafka:9092
,kafka-2:9093
- Topic:
unique-requests
- Bootstrap Servers:
- Nginx Load Balancer: Distributes requests among three instances of the application.
-
Send a request to the API:
curl "http://localhost/api/uniqueIDTracker/accept?id=123&endpoint=http://example.com"
-
Verify logs for unique request counts and HTTP status codes.
-
Check Kafka and Redis for distributed processing and deduplication.