A DevOps demonstration project showcasing Microservices Architecture and Redis caching with a Streamlit web application. This project simulates a high-traffic news dashboard to demonstrate the performance benefits of caching (reducing load times from seconds to milliseconds).
This application demonstrates:
- Redis Caching: Fast data retrieval using Redis as an in-memory layer.
- Docker Compose: Orchestrating multi-container environments.
- Service Discovery: Internal networking between containers.
- Performance Comparison: Visual demonstration of cache hits vs. cache misses.
The application consists of two services running in a private Docker network:
- news-app: Python/Streamlit application (Port 8501) - The Frontend.
- redis-db: Redis cache database (Port 6379) - The Backend Storage.
- Docker Desktop installed and running.
- No Python installation required (runs entirely in containers).
-
Clone the repository:
git clone https://github.com/Nipuna-Lakruwan/news-dashboard.git cd news-dashboard -
Start the application:
docker-compose up
-
Access the dashboard: Open your browser and navigate to:
http://localhost:8501 -
Stop the application:
docker-compose down
-
First Request (Cache Miss):
- User clicks "Refresh News".
- App checks Redis cache → Empty.
- Simulates a slow API fetch (3-second delay).
- Stores result in Redis with a 60-second TTL (Time To Live).
-
Subsequent Requests (Cache Hit):
- User clicks "Refresh News" again within 60s.
- App finds data in Redis.
- Returns instantly (0ms delay).
The application displays mock data for:
- Headline: Main news story.
- Breaking: Critical alerts.
- Sports: Match updates.
- App Container: Exposes port 8501. Depends on
redis-db. - Redis Container: Uses official
redis:alpineimage (lightweight). - Networking: Containers communicate via Docker Compose's internal DNS (hostname:
redis-db).
- Expiration Time: 60 seconds.
- Key Name:
lanka_news.
If you edit app.py, you must rebuild the container:
docker-compose up --buildTo manually inspect keys inside the running container:
docker exec -it news-dashboard-redis-db-1 redis-cliCommon commands:
KEYS *: List all cached keys.TTL lanka_news: See how many seconds are left before expiration.
- Data Persistence: Add Docker Volumes (
-v) to persist Redis data after container shutdown. - Real API Integration: Replace the mock data with a real request to a News API.
- Load Balancing: Add Nginx to distribute traffic across multiple app containers.
This project is created for educational purposes.
Built for DevOps learning