Tyk API Gateway Complete Stack
Open source API gateway with dashboard, pump analytics, and Redis backend.
Overview
Tyk API Gateway is an open-source API management platform that provides enterprise-grade API gateway functionality with rate limiting, authentication, analytics, and developer portal capabilities. Originally developed to solve the complexity of managing APIs at scale, Tyk has become a popular choice for organizations needing robust API security, traffic management, and comprehensive monitoring without vendor lock-in. This complete stack deployment orchestrates seven specialized services: the core Tyk Gateway for API proxying and policy enforcement, Tyk Dashboard for management UI, Tyk Pump for analytics processing, Redis for session storage and rate limiting, MongoDB for persistent analytics data, plus Prometheus and Grafana for advanced monitoring and visualization. The architecture separates concerns effectively, with Redis handling high-speed operations like rate limiting counters while MongoDB stores detailed analytics and configuration data. This configuration is ideal for organizations implementing API-first architectures, companies migrating from commercial API management solutions, and development teams needing comprehensive API observability. The inclusion of Prometheus and Grafana transforms this from a basic API gateway into a complete API operations platform, providing deep insights into API performance, usage patterns, and system health across the entire stack.
Key Features
- Multi-tenant API management with role-based access control through Tyk Dashboard
- Real-time rate limiting and quota enforcement backed by Redis for sub-millisecond response times
- Advanced analytics pipeline with Tyk Pump processing API metrics into MongoDB and Prometheus
- OAuth 2.0, JWT, and API key authentication with pluggable authentication backends
- API versioning and transformation capabilities with JavaScript middleware support
- Comprehensive monitoring stack with Prometheus metrics collection and Grafana dashboards
- Developer portal functionality for API documentation and key management
- Hot-reload configuration changes without gateway downtime
Common Use Cases
- 1Enterprise API gateway replacement for organizations moving away from commercial solutions like Apigee or Kong Enterprise
- 2Microservices API management for companies implementing service mesh architectures with centralized policy enforcement
- 3API monetization platforms requiring detailed usage analytics, billing integration, and developer self-service portals
- 4Multi-environment API governance for organizations needing consistent rate limiting and security policies across development, staging, and production
- 5SaaS platform API management with tenant isolation, usage tracking, and automated billing integration
- 6Legacy system modernization projects exposing mainframe or monolithic applications through modern REST APIs
- 7Regulatory compliance environments requiring detailed API audit trails and access logging
Prerequisites
- Minimum 4GB RAM recommended (1GB for MongoDB, 512MB for Redis, 2GB for Tyk services, 512MB for monitoring)
- Valid Tyk license key for dashboard functionality (community version available with limited features)
- Docker Engine 20.10+ and Docker Compose V2 for proper health check and dependency management
- Ports 3000, 3001, 8080, and 9090 available for dashboard, Grafana, gateway, and Prometheus respectively
- Understanding of API management concepts including rate limiting, authentication flows, and analytics pipelines
- Basic MongoDB and Redis administration knowledge for production troubleshooting and optimization
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 tyk-redis: 3 image: redis:7-alpine4 volumes: 5 - tyk_redis:/data6 networks: 7 - tyk_net89 tyk-mongo: 10 image: mongo:611 environment: 12 MONGO_INITDB_ROOT_USERNAME: root13 MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}14 volumes: 15 - tyk_mongo:/data/db16 networks: 17 - tyk_net1819 tyk-gateway: 20 image: tykio/tyk-gateway:latest21 ports: 22 - "8080:8080"23 environment: 24 - TYK_GW_SECRET=${TYK_SECRET}25 - TYK_GW_STORAGE_HOST=tyk-redis26 - TYK_GW_STORAGE_PORT=637927 volumes: 28 - ./tyk.conf:/opt/tyk-gateway/tyk.conf29 depends_on: 30 - tyk-redis31 networks: 32 - tyk_net3334 tyk-dashboard: 35 image: tykio/tyk-dashboard:latest36 ports: 37 - "3000:3000"38 environment: 39 - TYK_DB_LICENSEKEY=${TYK_LICENSE}40 - TYK_DB_STORAGE_HOST=tyk-redis41 - TYK_DB_STORAGE_PORT=637942 - TYK_DB_MONGOURL=mongodb://root:${MONGO_PASSWORD}@tyk-mongo:27017/tyk_analytics?authSource=admin43 depends_on: 44 - tyk-redis45 - tyk-mongo46 - tyk-gateway47 networks: 48 - tyk_net4950 tyk-pump: 51 image: tykio/tyk-pump-docker-pub:latest52 environment: 53 - TYK_PMP_ANALYTICSSTORAGECONFIG_HOST=tyk-redis54 - TYK_PMP_ANALYTICSSTORAGECONFIG_PORT=637955 - TYK_PMP_PUMPS_MONGO_META_MONGOURL=mongodb://root:${MONGO_PASSWORD}@tyk-mongo:27017/tyk_analytics?authSource=admin56 depends_on: 57 - tyk-redis58 - tyk-mongo59 networks: 60 - tyk_net6162 prometheus: 63 image: prom/prometheus:latest64 ports: 65 - "9090:9090"66 volumes: 67 - prometheus_data:/prometheus68 networks: 69 - tyk_net7071 grafana: 72 image: grafana/grafana:latest73 ports: 74 - "3001:3000"75 environment: 76 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}77 volumes: 78 - grafana_data:/var/lib/grafana79 networks: 80 - tyk_net8182volumes: 83 tyk_redis: 84 tyk_mongo: 85 prometheus_data: 86 grafana_data: 8788networks: 89 tyk_net: .env Template
.env
1# Tyk API Gateway2TYK_SECRET=secure_tyk_secret_key3TYK_LICENSE=your_tyk_license_key4MONGO_PASSWORD=secure_mongo_password5GRAFANA_PASSWORD=secure_grafana_password67# Gateway at http://localhost:80808# Dashboard at http://localhost:3000Usage Notes
- 1Gateway at http://localhost:8080
- 2Dashboard at http://localhost:3000
- 3Analytics stored in MongoDB
- 4Rate limiting via Redis
- 5Requires Tyk license for dashboard
Individual Services(7 services)
Copy individual services to mix and match with your existing compose files.
tyk-redis
tyk-redis:
image: redis:7-alpine
volumes:
- tyk_redis:/data
networks:
- tyk_net
tyk-mongo
tyk-mongo:
image: mongo:6
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
volumes:
- tyk_mongo:/data/db
networks:
- tyk_net
tyk-gateway
tyk-gateway:
image: tykio/tyk-gateway:latest
ports:
- "8080:8080"
environment:
- TYK_GW_SECRET=${TYK_SECRET}
- TYK_GW_STORAGE_HOST=tyk-redis
- TYK_GW_STORAGE_PORT=6379
volumes:
- ./tyk.conf:/opt/tyk-gateway/tyk.conf
depends_on:
- tyk-redis
networks:
- tyk_net
tyk-dashboard
tyk-dashboard:
image: tykio/tyk-dashboard:latest
ports:
- "3000:3000"
environment:
- TYK_DB_LICENSEKEY=${TYK_LICENSE}
- TYK_DB_STORAGE_HOST=tyk-redis
- TYK_DB_STORAGE_PORT=6379
- TYK_DB_MONGOURL=mongodb://root:${MONGO_PASSWORD}@tyk-mongo:27017/tyk_analytics?authSource=admin
depends_on:
- tyk-redis
- tyk-mongo
- tyk-gateway
networks:
- tyk_net
tyk-pump
tyk-pump:
image: tykio/tyk-pump-docker-pub:latest
environment:
- TYK_PMP_ANALYTICSSTORAGECONFIG_HOST=tyk-redis
- TYK_PMP_ANALYTICSSTORAGECONFIG_PORT=6379
- TYK_PMP_PUMPS_MONGO_META_MONGOURL=mongodb://root:${MONGO_PASSWORD}@tyk-mongo:27017/tyk_analytics?authSource=admin
depends_on:
- tyk-redis
- tyk-mongo
networks:
- tyk_net
prometheus
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- prometheus_data:/prometheus
networks:
- tyk_net
grafana
grafana:
image: grafana/grafana:latest
ports:
- "3001:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
volumes:
- grafana_data:/var/lib/grafana
networks:
- tyk_net
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 tyk-redis:5 image: redis:7-alpine6 volumes:7 - tyk_redis:/data8 networks:9 - tyk_net1011 tyk-mongo:12 image: mongo:613 environment:14 MONGO_INITDB_ROOT_USERNAME: root15 MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}16 volumes:17 - tyk_mongo:/data/db18 networks:19 - tyk_net2021 tyk-gateway:22 image: tykio/tyk-gateway:latest23 ports:24 - "8080:8080"25 environment:26 - TYK_GW_SECRET=${TYK_SECRET}27 - TYK_GW_STORAGE_HOST=tyk-redis28 - TYK_GW_STORAGE_PORT=637929 volumes:30 - ./tyk.conf:/opt/tyk-gateway/tyk.conf31 depends_on:32 - tyk-redis33 networks:34 - tyk_net3536 tyk-dashboard:37 image: tykio/tyk-dashboard:latest38 ports:39 - "3000:3000"40 environment:41 - TYK_DB_LICENSEKEY=${TYK_LICENSE}42 - TYK_DB_STORAGE_HOST=tyk-redis43 - TYK_DB_STORAGE_PORT=637944 - TYK_DB_MONGOURL=mongodb://root:${MONGO_PASSWORD}@tyk-mongo:27017/tyk_analytics?authSource=admin45 depends_on:46 - tyk-redis47 - tyk-mongo48 - tyk-gateway49 networks:50 - tyk_net5152 tyk-pump:53 image: tykio/tyk-pump-docker-pub:latest54 environment:55 - TYK_PMP_ANALYTICSSTORAGECONFIG_HOST=tyk-redis56 - TYK_PMP_ANALYTICSSTORAGECONFIG_PORT=637957 - TYK_PMP_PUMPS_MONGO_META_MONGOURL=mongodb://root:${MONGO_PASSWORD}@tyk-mongo:27017/tyk_analytics?authSource=admin58 depends_on:59 - tyk-redis60 - tyk-mongo61 networks:62 - tyk_net6364 prometheus:65 image: prom/prometheus:latest66 ports:67 - "9090:9090"68 volumes:69 - prometheus_data:/prometheus70 networks:71 - tyk_net7273 grafana:74 image: grafana/grafana:latest75 ports:76 - "3001:3000"77 environment:78 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}79 volumes:80 - grafana_data:/var/lib/grafana81 networks:82 - tyk_net8384volumes:85 tyk_redis:86 tyk_mongo:87 prometheus_data:88 grafana_data:8990networks:91 tyk_net:92EOF9394# 2. Create the .env file95cat > .env << 'EOF'96# Tyk API Gateway97TYK_SECRET=secure_tyk_secret_key98TYK_LICENSE=your_tyk_license_key99MONGO_PASSWORD=secure_mongo_password100GRAFANA_PASSWORD=secure_grafana_password101102# Gateway at http://localhost:8080103# Dashboard at http://localhost:3000104EOF105106# 3. Start the services107docker compose up -d108109# 4. View logs110docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/tyk-api-gateway/run | bashTroubleshooting
- tyk-dashboard fails to start with license errors: Verify TYK_LICENSE environment variable contains valid license key and check Tyk account status
- tyk-gateway returns 503 errors: Check tyk-redis connectivity and ensure Redis is accepting connections on port 6379 within tyk_net network
- MongoDB connection refused in tyk-pump logs: Verify MONGO_PASSWORD environment variable matches between tyk-mongo and dependent services, check MongoDB authentication
- Grafana dashboard shows no data: Confirm Prometheus is scraping Tyk Gateway metrics endpoint and verify prometheus_data volume has proper write permissions
- API policies not applying: Ensure tyk.conf configuration file is properly mounted and tyk-gateway has reloaded configuration after policy changes
- High memory usage in tyk-pump: Tune analytics processing batch sizes and consider implementing data retention policies in MongoDB tyk_analytics collection
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
tyk-gatewaytyk-dashboardtyk-pumpredismongodb
Tags
#tyk#api-gateway#analytics#rate-limiting#oauth
Category
DevOps & CI/CDAd Space
Shortcuts: C CopyF FavoriteD Download