Master the art of deploying, scaling, and managing applications on SLYD with best practices and advanced techniques.
This guide builds upon the Applications documentation, providing deeper insights into deployment strategies, application management, and optimization techniques for real-world use cases.
Choose the right deployment approach based on your application's requirements and business needs.
Run two identical production environments with only one active at a time, allowing for zero-downtime deployments and easy rollbacks.
Set up two identical environments (Blue and Green)
Route all traffic to the active environment (e.g., Blue)
Deploy new application version to the inactive environment (Green)
Test the new version in the inactive environment
Switch traffic from Blue to Green (instantly or gradually)
Keep the old version (Blue) available for quick rollback if needed
# Create Blue and Green instance groups
slyd instance-group create --name my-app-blue --template app-template
slyd instance-group create --name my-app-green --template app-template
# Deploy application to Green environment (inactive)
slyd app deploy --app-id my-application --version v2.0.0 --group my-app-green
# Test application in Green environment
slyd tunnel create --name green-test --group my-app-green --port 8080
# Switch traffic from Blue to Green
slyd load-balancer update --name my-app-lb --active-group my-app-green
# If issues occur, quick rollback to Blue
slyd load-balancer update --name my-app-lb --active-group my-app-blue
Gradually roll out a new version to a small subset of users before full deployment, allowing you to test in production with minimal risk.
Deploy the new version alongside the existing version
Route a small percentage of traffic (e.g., 5-10%) to the new version
Monitor performance, errors, and user feedback closely
Gradually increase traffic to the new version if no issues are found
Roll back quickly if problems are detected
Complete the migration when confident in the new version
# Deploy canary version alongside current version
slyd instance-group create --name my-app-canary --size 2 --template app-template
slyd app deploy --app-id my-application --version v2.0.0 --group my-app-canary
# Configure load balancer for canary traffic splitting
slyd load-balancer update --name my-app-lb \
--primary-group my-app-production --primary-weight 90 \
--canary-group my-app-canary --canary-weight 10
# Monitor performance metrics
slyd metrics watch --groups my-app-production,my-app-canary \
--metrics response_time,error_rate,throughput
# Gradually increase traffic to canary
slyd load-balancer update --name my-app-lb \
--primary-group my-app-production --primary-weight 75 \
--canary-group my-app-canary --canary-weight 25
# Complete the migration
slyd load-balancer update --name my-app-lb \
--primary-group my-app-canary --primary-weight 100
# Clean up old deployment
slyd instance-group update --name my-app-production \
--template app-template-v2
Establish a robust CI/CD pipeline to automate the build, test, and deployment process across different environments.
Code changes are committed to source control (Git)
Application is compiled, dependencies are resolved, and artifacts are created
Automated tests are run to validate the application's functionality
Security scans check for vulnerabilities and compliance issues
Application is deployed to target environment (staging, production)
Application performance and health are continuously monitored
name: SLYD App Deployment
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Test
run: npm test
- name: Security scan
run: npm run security-scan
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: dist/
deploy-staging:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: build-artifacts
path: dist/
- name: Install SLYD CLI
run: npm install -g slyd-cli
- name: Configure SLYD
run: slyd configure --api-key ${{ secrets.SLYD_API_KEY }}
- name: Deploy to staging
run: |
slyd app deploy \
--app-id my-application \
--version ${{ github.sha }} \
--environment staging \
--path dist/
- name: Run smoke tests
run: |
slyd tunnel create --name smoke-test --environment staging --port 8080
npm run smoke-tests -- --url https://smoke-test.slyd.cloud
deploy-production:
needs: deploy-staging
runs-on: ubuntu-latest
environment:
name: production
url: https://my-application.slyd.cloud
steps:
- uses: actions/download-artifact@v2
with:
name: build-artifacts
path: dist/
- name: Install SLYD CLI
run: npm install -g slyd-cli
- name: Configure SLYD
run: slyd configure --api-key ${{ secrets.SLYD_API_KEY }}
- name: Deploy to production (Blue-Green)
run: |
# Determine current active environment
CURRENT_ENV=$(slyd load-balancer get --name my-app-lb --output json | jq -r '.activeGroup')
# Deploy to inactive environment
if [ "$CURRENT_ENV" == "my-app-blue" ]; then
TARGET_ENV="my-app-green"
else
TARGET_ENV="my-app-blue"
fi
# Deploy new version
slyd app deploy \
--app-id my-application \
--version ${{ github.sha }} \
--group $TARGET_ENV \
--path dist/
# Run validation tests
slyd tunnel create --name validation-test --group $TARGET_ENV --port 8080
npm run validation-tests -- --url https://validation-test.slyd.cloud
# Switch traffic
slyd load-balancer update --name my-app-lb --active-group $TARGET_ENV
Leverage containers to improve deployment consistency, scalability, and resource utilization.
Guarantee that your application runs in the same environment across development, testing, and production
Containers are lightweight and share the host OS kernel, allowing for higher density deployment
Easily scale applications horizontally by spinning up additional container instances
Run multiple applications with different dependencies on the same host without conflicts
Create optimized containers for your applications:
# Use specific version tags for base images
FROM node:16-alpine
# Set working directory
WORKDIR /app
# Copy package files first to leverage layer caching
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy application code
COPY . .
# Use non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /app
USER nodejs
# Set environment variables
ENV NODE_ENV production
# Expose application port
EXPOSE 8080
# Use CMD instead of ENTRYPOINT for flexibility
CMD ["node", "server.js"]
SLYD supports direct deployment of container images from public or private container registries.
Configure networking for container-based applications:
For complex applications with multiple containers, SLYD provides built-in orchestration capabilities:
Deploy multi-container applications using a single configuration file
version: '1'
services:
web:
image: nginx:alpine
ports:
- "80:80"
volumes:
- web-content:/usr/share/nginx/html
depends_on:
- app
restart: always
app:
image: myapp:latest
environment:
- DB_HOST=db
- DB_USER=appuser
- DB_PASSWORD=apppass
depends_on:
- db
restart: always
db:
image: postgres:13
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=appuser
- POSTGRES_PASSWORD=apppass
- POSTGRES_DB=myappdb
restart: always
volumes:
web-content:
db-data:
persistent: true
slyd compose up \
--file slyd-compose.yaml \
--instance-id inst-abc123
Configure health checks for automatic container recovery
slyd container deploy \
--image myapp:latest \
--instance-id inst-abc123 \
--health-check '{
"type": "http",
"path": "/health",
"port": 8080,
"interval": 30,
"timeout": 5,
"retries": 3
}' \
--restart-policy '{
"policy": "on-failure",
"max_retries": 5
}'
Implement comprehensive monitoring, logging, and tracing for your applications.
Track application health, performance, and resource utilization in real time.
Enable built-in metrics collection for instances and applications
slyd metrics enable \
--instance-id inst-abc123 \
--collection-interval 60 \
--retention-days 30
Implement application-specific metrics using the SLYD Metrics API
// Node.js example using the SLYD Metrics client
const { SLYDMetrics } = require('slyd-metrics');
const metrics = new SLYDMetrics({
apiKey: process.env.SLYD_API_KEY
});
// Record a count metric
metrics.count('orders.completed', 1, {
customer_tier: 'premium',
region: 'us-east'
});
// Record a timing metric
metrics.timing('payment.processing_time', 250, {
payment_method: 'credit_card'
});
// Record a gauge metric
metrics.gauge('inventory.level', 42, {
product_id: 'SKU123'
});
Set up visualizations and notifications for critical metrics
slyd alert create \
--name "High Error Rate" \
--metric "app.error_rate" \
--threshold 0.05 \
--operator "gt" \
--duration 300 \
--severity "critical" \
--notification-channels "email,slack" \
--instance-id inst-abc123
Capture detailed information about application events, errors, and activities.
Use structured formats like JSON for machine-processable logs
// Node.js example using Winston
const winston = require('winston');
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { service: 'user-service' },
transports: [
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' }),
new winston.transports.Console({
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple()
)
})
]
});
// Log with structured metadata
logger.info('User login successful', {
userId: 'user123',
loginMethod: 'oauth',
ipAddress: '192.168.1.1',
timestamp: new Date().toISOString()
});
Collect and centralize logs from all instances and containers
slyd logging setup \
--instance-id inst-abc123 \
--storage-type s3 \
--storage-config '{
"bucket": "my-logs-bucket",
"prefix": "app-logs/",
"retention_days": 90
}' \
--log-sources '{
"app": "/var/log/app/*.log",
"nginx": "/var/log/nginx/*.log",
"system": "/var/log/syslog"
}'
Query and analyze logs using full-text search and structured filters
Set up notifications based on log patterns or anomalies
Configure retention policies and archive logs to cost-effective storage
Ensure logs meet security requirements with encryption and access controls
Track requests as they flow through distributed microservices for end-to-end visibility.
Add tracing instrumentation to your application code
Set up trace collection and storage in SLYD
slyd tracing setup
Use the SLYD Tracing UI to search, filter, and analyze distributed traces
slyd tracing ui --instance-id inst-abc123
Follow these recommendations to maximize the efficiency, reliability, and security of your application deployments.
Regularly analyze application resource usage and adjust instance sizes accordingly
Use SLYD's integrated CDN for static assets to reduce load times and server load
Implement proper indexing, caching, and query optimization for database workloads
Regularly perform load testing to identify bottlenecks before they impact users
Regularly scan and update dependencies to address security vulnerabilities
Run applications with minimal required permissions and use service accounts
Use SLYD's secrets manager instead of hardcoding sensitive information
Implement network policies and firewalls to restrict unnecessary traffic
Assume any component can fail and design your application to handle failures gracefully
Implement circuit breakers to prevent cascading failures in distributed systems
Periodically test system resilience by intentionally introducing failures
Implement and regularly test backup and recovery procedures for critical data
We're constantly improving our documentation. Let us know how we can make it better!