Skip to main content

Production Flink: Deployment, Operations & Monitoring at Scale

Module Duration: 7-8 hours Focus: Kubernetes/YARN deployment, HA, state backends, monitoring, troubleshooting Prerequisites: Flink fundamentals, Kubernetes basics, distributed systems knowledge Hands-on Labs: Production cluster setup and monitoring

Introduction: From Development to Production

The Production Gap

Development (laptop):
Production (distributed cluster):
  • 100+ TaskManagers across multiple nodes
  • Terabytes of state in RocksDB
  • 24/7 uptime requirements (HA, failover)
  • Multi-tenant resource management
  • Metrics, logging, alerting for 1000s of jobs
  • Zero-downtime upgrades
This module teaches you how to bridge that gap.

Part 1: Deployment Architectures

Deployment Modes

1. Standalone Cluster (Development)

Pros: Simple setup Cons: No resource management, no HA

2. YARN Deployment (Hadoop Ecosystem)

Per-Job Mode (recommended):
Session Mode (shared cluster):

3. Kubernetes Deployment (Cloud Native)

Native Kubernetes Integration:
Deploy to Kubernetes:

Part 2: High Availability (HA)

Why HA Matters

Without HA:
  • JobManager dies → All jobs fail
  • Manual recovery required
  • Downtime = hours
With HA:
  • JobManager dies → Standby takes over in seconds
  • Jobs recover from last checkpoint automatically
  • Downtime = seconds

HA Configuration (Kubernetes)

Deploy HA JobManager:

HA with ZooKeeper (Alternative)

Testing HA


Part 3: State Backends & Checkpointing

State Backend Selection

Production Checkpointing Configuration

RocksDB Tuning (Production)

Savepoints (Manual Checkpoints)

Use Cases:
  • Job upgrades (code changes)
  • Cluster migrations
  • Rescaling parallelism
  • Bug fixes with state preservation

Part 4: Monitoring & Observability

Key Metrics to Monitor:

Prometheus Integration

Flink Configuration:
Prometheus Scrape Config:

Grafana Dashboard

Essential Panels:

Logging

Log4j Configuration (log4j.properties):
Centralized Logging (ELK Stack):

Part 5: Backpressure Detection & Resolution

Understanding Backpressure

Symptoms:
  • Increasing checkpoint duration
  • Growing lag in Kafka consumer
  • High backPressureTimeMsPerSecond metric
Detection:

Common Causes & Solutions

Cause 1: Slow Sink

Cause 2: Inefficient Operator

Cause 3: Skewed Keys

Cause 4: Insufficient Resources


Part 6: Resource Management & Tuning

Memory Configuration

Network Tuning

Parallelism & Scaling

Auto-Scaling (Kubernetes HPA):

Part 7: Troubleshooting Common Issues

Issue 1: Out of Memory (OOM)

Symptoms:
Diagnosis:
Solutions:
  1. Increase heap size: taskmanager.memory.task.heap.size: 4096m
  2. Use RocksDB (off-heap state): state.backend: rocksdb
  3. Enable state TTL to clean old state
  4. Reduce parallelism (fewer tasks per TaskManager)

Issue 2: Checkpoint Timeouts

Symptoms:
Solutions:

Issue 3: Kafka Consumer Lag

Diagnosis:
Solutions:

Issue 4: Job Stuck in Restart Loop

Symptoms:
Diagnosis:
Solutions:

Part 8: Production Best Practices

1. Checkpointing Strategy

2. State Backend Selection

3. Monitoring & Alerting

Critical Alerts:

4. Security

5. Cost Optimization

Spot Instances (AWS):

Part 9: Upgrade Strategies

Blue-Green Deployment

Canary Deployment


Summary

What You’ve Mastered

✅ Deployment architectures (Standalone, YARN, Kubernetes) ✅ High availability with JobManager failover ✅ State backends and checkpointing strategies ✅ Production monitoring with Prometheus/Grafana ✅ Backpressure detection and resolution ✅ Resource tuning and auto-scaling ✅ Troubleshooting common production issues ✅ Security, cost optimization, upgrade strategies

Key Takeaways

  1. HA is Non-Negotiable: Always enable HA in production
  2. Monitor Everything: Checkpoints, backpressure, lag, state size
  3. RocksDB for Large State: Use incremental checkpoints
  4. Tune Memory Carefully: Heap, managed memory, network buffers
  5. Test Failover: Kill pods and verify recovery

Next Module

Module 9: Capstone Project - Fraud Detection System

Build a complete production-grade fraud detection system with Kafka, CEP, ML, and monitoring

Resources

Documentation

Tools

Practice: Deploy a Flink cluster to Kubernetes with HA, RocksDB state backend, and Prometheus monitoring. Run a stateful job, kill the JobManager, and verify automatic recovery!