An asynchronous microservice for high-speed media downloading and event-driven processing within the AWS cloud infrastructure. This project demonstrates Cloud-Native principles, container orchestration, and Serverless architecture.
- Ingress & API (Kubernetes): The Nginx Ingress Controller routes external HTTP traffic to the application pods. The API accepts a list of URLs and initiates asynchronous background tasks.
- State Management (Redis): Task states (pending, processing, completed, failed) are reliably tracked using an internal Redis cache.
- I/O Processing (Python/aiohttp): Asynchronous workers download files in a streaming manner and upload them directly to Amazon S3, preventing local disk and memory overload in the cluster.
- Event-Driven Post-Processing (AWS Lambda): The creation of a new file in the S3 bucket automatically triggers an isolated AWS Lambda function for metadata extraction and analytics, effectively decoupling network I/O from compute-heavy tasks.
- Language: Python 3.14
- Infrastructure: Kubernetes, Docker, Nginx Ingress Controller
- Cloud Services: AWS S3, AWS Lambda, IAM, CloudWatch
- Databases: Redis
- Libraries: aiohttp, aioboto3
- Docker Desktop with Kubernetes enabled.
kubectlCLI tool installed.- AWS Account (configured S3 Bucket and IAM credentials).
To securely interact with AWS, you need to set up Kubernetes secrets.
Copy the configuration template:
cp k8s/aws-secret-sample.example k8s/aws-secret.yaml
Open k8s/aws-secret.yaml and insert your AWS credentials. Note: The key values must be Base64 encoded. The aws-secret.yaml file is added to .gitignore and should never be committed to version control.
Build the local application image:
docker build -t streamfetch-api:latest .
Apply the Kubernetes configuration manifests (Deployments, Services, Ingress, Secrets):
kubectl apply -f k8s/
Ensure all components have transitioned to the Running state:
kubectl get pods
Send a POST request with an array of target URLs:
curl -X POST http://localhost/api/v1/fetch
-H "Content-Type: application/json"
-d '{"urls": ["https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg"]}'
On success, the server will return a JSON response containing a unique job_id.
Use the received job_id to check the execution status:
curl http://localhost/api/v1/status/<your_job_id>
A "completed" status confirms that the file was successfully downloaded and streamed to the S3 bucket.
To complete the event-driven pipeline, configure a serverless function in the AWS Cloud. The handler source code is located in the lambda/ directory of this repository.
- Create a new Lambda function (Python 3.10+).
- Assign an IAM role with the
AmazonS3ReadOnlyAccesspolicy to the function. - Add an S3 trigger for the
All object create eventsevent on your bucket. - Deploy the code from
lambda/lambda_handler.py. Function logs and execution results will be available in Amazon CloudWatch.