How sandesh-543/cdn_simulation works
Purpose and Entry Points
This is a Java CDN simulation/service that exposes HTTP endpoints for cache/data access, node health, and CDN routing. The application starts from src/main/java/cdn_server/CdnSimulationApplication.java; request-facing entry points are in src/main/java/controller/CdnController.java, src/main/java/controller/DataController.java, and src/main/java/controller/HealthController.java.
HTTP/API Layer
Controllers define the external control boundary:
• CdnController likely accepts CDN content requests and delegates node selection and cache access.
• DataController provides data/object-oriented operations used by the simulation.
• HealthController exposes node or service liveness for clients, proxies, or orchestration.
Paths: src/main/java/controller/CdnController.java, src/main/java/controller/DataController.java, src/main/java/controller/HealthController.java.
Request Routing and Node Selection
src/main/java/loadbalancer/LoadBalancer.java is the routing decision point between incoming CDN requests and available simulated edge nodes. src/main/java/node/CdnNode.java represents an individual node and its state/capacity/cache-facing behavior. The key control flow is controller → load balancer → selected CDN node → cache/data result.
Caching and Object Model
Cached content is represented by src/main/java/model/CachedObject.java. src/main/java/service/CacheService.java is the application-level cache boundary: it should determine cache lookup, insertion, expiry/validity behavior, and cache-miss handling before data is returned to the caller. This isolates HTTP routing from storage semantics.
Redis Persistence/Shared Cache Boundary
Redis is the material external state service. src/main/java/service/RedisService.java encapsulates Redis operations, while src/main/java/config/RedisConfig.java owns client/template connection configuration. Redis server configuration is supplied at redis/redis.conf. The expected data path is CacheService → RedisService → Redis, allowing multiple CDN node instances to share cache state.
Deployment and Edge Infrastructure
The service is containerized by docker/Dockerfile and composed with supporting services through docker/docker-compose.yml. Nginx is configured in nginx/nginx.conf and is the likely reverse-proxy/load-distribution boundary in front of one or more application instances. scripts/start_cdn_nodes.sh operationalizes starting multiple CDN nodes, while scripts/test_load_balancing.sh exercises that topology.
Runtime Configuration and Observability
Application runtime settings are centralized in src/main/resources/application.properties; logging behavior is defined by src/main/resources/logback.xml. The primary runtime is a Maven-built Java application (pom.xml) backed by Redis and optionally fronted by Nginx/Docker Compose. Health endpoints provide the main operational signal for node availability and routing decisions.
Main entry points: CdnSimulationApplication.java CDN application · CacheService.java Cache service · docker-compose.yml Docker Compose · CdnController.java CDN controller
Components 16
Edge & Deployment
- Nginx reverse proxy · Distributes external traffic to application instances.
nginx/nginx.conf - Docker Compose
docker/docker-compose.yml - Application image
docker/Dockerfile - Node startup script · Starts multiple simulated CDN nodes.
scripts/start_cdn_nodes.sh
Java Application
- CDN application
src/main/java/cdn_server/CdnSimulationApplication.java - CDN controller
src/main/java/controller/CdnController.java - Data controller
src/main/java/controller/DataController.java - Health controller · Exposes node or service liveness.
src/main/java/controller/HealthController.java - Load balancer · Selects an available CDN node for requests.
src/main/java/loadbalancer/LoadBalancer.java - CDN node · Represents node state, capacity, and cache-facing behavior.
src/main/java/node/CdnNode.java - Runtime settings
src/main/resources/application.properties
Shared Cache
- Cache service · Handles lookup, insertion, validity, and misses.
src/main/java/service/CacheService.java - Cached object
src/main/java/model/CachedObject.java - Redis service · Encapsulates shared-cache operations.
src/main/java/service/RedisService.java - Redis client config
src/main/java/config/RedisConfig.java - Redis · Shared cache state across CDN node instances.
redis/redis.conf
Connections 19
- Docker Compose → Nginx reverse proxy: runs
- Docker Compose → CDN application: runs
- Docker Compose → Redis: runs
- Application image → CDN application: packages
- Node startup script → CDN application: starts instances
- Nginx reverse proxy → CDN controller: proxies requests
- CDN application → CDN controller: serves
- CDN application → Data controller: serves
- CDN application → Health controller: serves
- CDN controller → Load balancer: routes through
- Load balancer → CDN node: selects
- CDN node → Cache service: accesses cache
- Data controller → Cache service: accesses objects
- Health controller → CDN node: checks
- Cache service → Cached object: reads/writes
- Cache service → Redis service: on lookup or miss
- Redis service → Redis: stores cached data
- Redis client config → Redis service: configures client
- Runtime settings → CDN application: configures