Apache NiFi: Data Flow Automation & Pipeline Design Guide
Apache NiFi is a visual, real-time dataflow platform that makes it easy to automate data movement between systems without writing code. Drag, drop, and connect processors in a browser-based UI to build powerful, fault-tolerant data pipelines.
What is Apache NiFi?
Apache NiFi is an open-source data integration platform originally developed by the NSA and donated to the Apache Software Foundation in 2014. It is designed for automated, reliable data flow between heterogeneous systems: files, databases, REST APIs, message queues, cloud storage, IoT devices, and more. The browser-based UI lets users build and modify pipelines visually without touching code — making it accessible to both engineers and operations teams.
Every piece of data in NiFi is represented as a FlowFile — a content payload plus metadata attributes. Processors read, transform, route, and write FlowFiles. Data provenance is tracked for every FlowFile through every processor, providing a complete audit trail of where data came from and every transformation it underwent. NiFi includes built-in security (TLS, multi-tenant authorization), clustering for scalability, and Site-to-Site for data transfer between NiFi instances.
Docker Compose Quickstart
# docker-compose.yml — Apache NiFi single-node
version: '3.8'
services:
nifi:
image: apache/nifi:1.27.0
ports:
- "8443:8443" # HTTPS UI (NiFi 1.14+ enforces TLS)
environment:
NIFI_WEB_HTTPS_PORT: '8443'
SINGLE_USER_CREDENTIALS_USERNAME: admin
SINGLE_USER_CREDENTIALS_PASSWORD: adminpassword123
volumes:
- nifi_conf:/opt/nifi/nifi-current/conf
- nifi_data:/opt/nifi/nifi-current/data
- nifi_logs:/opt/nifi/nifi-current/logs
- ./flow_templates:/opt/nifi/nifi-current/flow_templates
volumes:
nifi_conf:
nifi_data:
nifi_logs:
# Access UI at: https://localhost:8443/nifi
# Default credentials set via SINGLE_USER_CREDENTIALS_* env vars Creating Processors via REST API
# NiFi REST API — create a processor via API (Python)
import requests
import json
BASE = "https://localhost:8443/nifi-api"
HEADERS = {"Content-Type": "application/json"}
SESSION = requests.Session()
SESSION.verify = False # disable for self-signed cert in dev
# 1. Get root process group ID
root = SESSION.get(f"{BASE}/process-groups/root").json()
pg_id = root["id"]
# 2. Create a GetFile processor
processor_config = {
"revision": {"version": 0},
"component": {
"type": "org.apache.nifi.processors.standard.GetFile",
"name": "Get Orders CSV",
"position": {"x": 400, "y": 200},
"config": {
"properties": {
"Input Directory": "/data/input",
"File Filter": "orders_.*\.csv",
"Keep Source File": "false",
},
"schedulingPeriod": "10 sec",
"schedulingStrategy": "TIMER_DRIVEN",
},
},
}
resp = SESSION.post(
f"{BASE}/process-groups/{pg_id}/processors",
json=processor_config
)
print("Created processor:", resp.json()["component"]["name"]) NiFi Expression Language
# NiFi Expression Language — FlowFile attribute manipulation
# Used in Processor properties to dynamically route and transform
# Access FlowFile attributes
${filename} # original filename
${uuid} # FlowFile UUID
${fileSize} # size in bytes
${entryDate} # ingestion timestamp
# String operations
${filename:toLower()} # orders_2024.CSV -> orders_2024.csv
${filename:replace('.csv', '.parquet')}
${filename:substring(0, 8)} # first 8 chars
# Conditionals — used in RouteOnAttribute processor
${amount:gt(1000)} # route high-value orders
${status:equals('error')} # route error records
${region:in('us', 'eu', 'ap')} # allow-list routing
# Date formatting for S3/HDFS partition paths
${now():format('yyyy/MM/dd')} # 2024/01/15
${entryDate:toNumber():format('yyyy-MM-dd', 'UTC')}
# Combining attributes in PutS3Object Key property:
# output/${now():format('yyyy/MM/dd')}/${uuid}.json NiFi vs Kafka Connect vs Apache Airflow
| Feature | Apache NiFi | Kafka Connect | Apache Airflow |
|---|---|---|---|
| Interface | Visual UI (drag & drop) | REST API / JSON config | Python code (DAGs) |
| Real-time streaming | Yes (continuous flow) | Yes (Kafka-centric) | Batch / scheduled |
| Transformation | Rich (150+ transform processors) | Limited (SMTs only) | Full Python code |
| Data provenance | Built-in (full lineage) | None | Task logs only |
| Kafka integration | ConsumeKafka / PublishKafka | Native (core purpose) | Kafka operators |
| Best for | Multi-source ingestion, IoT, routing | Kafka source/sink connectors | Batch ETL orchestration |
Common Processor Patterns
- GetFile → SplitText → PublishKafka — read CSV line-by-line and publish each row to Kafka
- ConsumeKafka → EvaluateJsonPath → RouteOnAttribute → PutDatabaseRecord — consume, extract fields, route by value, and write to database
- ListS3 → FetchS3Object → ConvertAvroToJSON → PutElasticsearchRecord — S3 to Elasticsearch with format conversion
- QueryDatabaseTable → ConvertRecord → PutParquet — CDC (change data capture) from DB to Parquet files
- Use HandleHttpRequest / HandleHttpResponse to expose NiFi as an HTTP endpoint for receiving data from external systems
- Use ExecuteScript (Python/Groovy) only when built-in processors cannot handle the logic — maintain testability
Frequently Asked Questions
What is a FlowFile in Apache NiFi?▼
A FlowFile is the fundamental data unit in NiFi — it represents a single piece of data moving through the pipeline. Every FlowFile has two parts: content (the actual payload, stored in the content repository) and attributes (key-value metadata like filename, fileSize, uuid, MIME type, and any custom attributes you add). Processors read, modify, route, and write FlowFiles. Attributes are lightweight and kept in memory; content is stored on disk. FlowFile attributes power NiFi's routing logic via the Expression Language and RouteOnAttribute processor.
What is the difference between a Processor, a Connection, and a Controller Service in NiFi?▼
A Processor is a configurable component that performs an action on FlowFiles — GetFile reads files, PutS3Object writes to S3, ExecuteSQL queries a database, SplitJSON splits a JSON array. A Connection is a queue between two processors that buffers FlowFiles — each connection has back-pressure thresholds and can prioritize FlowFiles. A Controller Service is a shared configuration component referenced by multiple processors — a DBCPConnectionPool manages a database connection pool that all SQL processors in the flow can share, avoiding redundant connections.
How does NiFi handle back-pressure and flow control?▼
Every Connection in NiFi has configurable back-pressure thresholds: maximum queue count (default 10,000 FlowFiles) and maximum data size (default 1 GB). When a connection reaches its threshold, the upstream processor is paused — it stops pulling new data until the downstream processor drains the queue. This prevents memory overflow and natural throttling when a slow downstream sink cannot keep up with a fast source. Monitor queue depths in the NiFi UI to identify bottlenecks. Adjust thresholds based on FlowFile size and acceptable latency.
What is NiFi's Site-to-Site protocol?▼
Site-to-Site (S2S) is NiFi's protocol for transferring data between two NiFi instances — or between NiFi and an application that implements the S2S client library. Unlike pushing raw data over HTTP, S2S transfers FlowFiles with their full attributes, supports compression, and handles back-pressure natively. Use S2S to federate data from remote/edge NiFi nodes (e.g., at a factory or remote office) to a central NiFi cluster. The RemoteProcessGroup processor establishes a S2S connection by pointing to the remote NiFi's URL.
When should I choose NiFi over Kafka Connect or Airflow?▼
Choose NiFi when you need a visual, no-code (or low-code) dataflow tool with drag-and-drop pipeline building, real-time routing based on content and attributes, and complex transformation logic without writing code (ExecuteScript if needed). NiFi excels for data ingestion from heterogeneous sources (FTP, SFTP, HTTP, JMS, databases, IoT devices) with routing, transformation, and delivery in one tool. Choose Kafka Connect when you are in a Kafka-centric architecture and need high-throughput, scalable connectors. Choose Airflow when orchestrating batch ETL jobs written in Python with complex dependency graphs.
What is NiFi Registry and when do I need it?▼
NiFi Registry is a complementary service that provides version control for NiFi flows (process group definitions). Without Registry, flow changes in the NiFi UI are not versioned — you cannot roll back to a previous version or promote a flow from development to production reliably. With Registry, you commit flow versions to a bucket, promote specific versions to production, and see the full change history. NiFi Registry is essential for production deployments where flow promotion, rollback, and audit trails are required. Connect NiFi to Registry via Settings > Registry Clients in the NiFi UI.
Related Products
on GumroadDeveloper Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →AI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →Developer Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →You Might Also Need
CSS Formatter & Minifier
Format and beautify CSS with consistent indentation, or minify it to reduce file size. Handles @media, @keyframes, nested rules, and comments. Runs in your browser.
Open free tool →
CSS Minifier
Free online CSS minifier. Paste your CSS to strip comments, whitespace, and redundant characters. Instantly shows original size, minified size, and % saved. Runs entirely in your browser.
Open free tool →
HTML Formatter & Minifier
Format messy HTML with proper indentation or minify it to reduce file size. Handles void elements, pre/script blocks, and nested tags. Runs entirely in your browser.
Open free tool →
More Free Tools
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →