Using Cloudera Data Platform with Flow Management and Streams on Azure
|Apache NiFi on Azure CDP Data Hub|
- Streams Messaging Heavy Duty for AWS
- Streams Messaging Heavy Duty for Azure
- Flow Management Heavy Duty for AWS
- Flow Management Heavy Duty for Azure
- Apache Kafka 2.4.1
- Cloudera Schema Registry 0.8.1
- Cloudera Streams Messaging Manager 2.1.0
- Apache NiFi 1.11.4
- Apache NiFi Registry 0.5.0
NiFi and Kafka are autoconfigured to work with Apache Atlas under our environments Data Lake SDX. We can browse through the lineage for all the Kafka topics we use.
You may have heard of: https://en.wikipedia.org/wiki/Spaghetti_code. For Apache NiFi, I have seen some (and have done some of them in the past), I call them Spaghetti Flows.
Let's avoid them. When you are first building a flow it often meanders and has lots of extra steps and extra UpdateAttributes and random routes. This applies if you are running on-premise, in CDP or in other stateful NiFi clusters (or single nodes). The following video from Mark Payne is a must watch before you write any NiFi flows.
Apache NiFi Anti-Patterns with Mark Payne
Do not Put 1,000 Flows on one workspace.
If your flow has hundreds of steps, this is a Flow Smell. Investigate why.
Do not Use ExecuteProcess, ExecuteScripts or a lot of Groovy scripts as a default, look for existing processors
Do not Use Random Custom Processors you find that have no documentation or are unknown.
Do not forget to upgrade, if you are running anything before Apache NiFi 1.10, upgrade now!
Do not run on default 512M RAM.
Do not run one node and think you have a highly available cluster.
Do not split a file with millions of records to individual records in one shot without checking available space/memory and back pressure.
Use Split processors only as an absolute last resort. Many processors are designed to work on FlowFiles that contain many records or many lines of text. Keeping the FlowFiles together instead of splitting them apart can often yield performance that is improved by 1-2 orders of magnitude.
Reduce, Reuse, Recycle. Use Parameters to reuse common modules.
Put flows, reusable chunks (write to Slack, Database, Kafka) into separate Process Groups.
Write custom processors if you need new or specialized features
Use Cloudera supported NiFi Processors
Use RecordProcessors everywhere
Read the Docs!
Use the NiFi Registry for version control.
Use NiFi CLI and DevOps for Migrations.
Run a CDP NiFi Datahub or CFM managed 3 or more node cluster.
Walk through your flow and make sure you understand every step and it’s easy to read and follow. Is every processor used? Are there dead ends?
Do run Zookeeper on different nodes from Apache NiFi.
For Cloud Hosted Apache NiFi - go with the "high cpu" instances, such as 8 cores, 7 GB ram.
same flow 'templatized' and deployed many many times with different params in the same instance
Use routing based on content and attributes to allow one flow to handle multiple nearly identical flows is better than deploying the same flow many times with tweaks to parameters in same cluster.
Use the correct driver for your database. There's usually a couple different JDBC drivers.
Make sure you match your Hive version to the NiFi processor for it. There are ones out there for Hive 1 and Hive 3! HiveStreaming needs Hive3 with ACID, ORC. https://community.cloudera.com/t5/Support-Questions/how-to-use-puthivestreaming/td-p/108430
Let's revisit some Best Practices:
Here are a few things you should have read and tried before building your first Apache NiFi flow:
Also when in doubt, use Records! Use Record Processors and use pre-defined schemas, this will be easier to develop, cleaner and more performant. Easier, Faster, Better!!!
There are record processors for Logs (Grok), JSON, AVRO, XML, CSV, Parquet and more.
Look for a processor that has “Record” in the name like PutDatabaseRecord or QueryRecord.
Use the best DevOps processes, testing and tools.
Some newer features in 1.8, 1.9, 1.10, 1.11 that you need to use.
Spaghetti is for eating, not for real-time data streams. Let's keep it that way.
If you are not sure what to do check out the Cloudera Community, NiFi Slack or the NiFi docs. Also I may have a helpful article here. Join me and my NiFi friends at virtual meetups for more in-depth NiFi, Flink, Kafka and more. We keep it interactive so you can feel free to ask questions.
Streaming Data with Cloudera Data Flow (CDF) Into Public Cloud (CDP)
At Cloudera Now NYC, I showed a demo on streaming data from MQTT Sensors and Twitter that was running in AWS. Today I am going to walk you through some of the details and give you the tools to build your own streaming demos in CDP Public Cloud. If you missed that event, you can watch a recording here.
Let's get streaming!
Let's login, I use Okta for Single-Sign On (SSO) which makes this so easy. Cloudera Flow Management (CFM) Apache NiFi is officially available in the CDP Public Cloud. So get started here. We will be following the guide (https://docs.cloudera.com/cdf-datahub/7.1.0/howto-data-ingest.html). We are running CDF DataHub on CDP 7.1.0.
There's a lot of data engineering and streaming tasks I can accomplish with few clicks. I can bring up a virtual datawarehouse and use tools like Apache Hue and Data Analytics Studio to examine database and tables and run queries.
We go to Data Hub Clusters and can see the latest Apache NiFi in there. You can see we have Data Engineering, Kafka and NiFi clusters already built and ready to go. It only takes a click, a few drop down settings and a name to build and deploy in minutes. This saves me and my team so much time. Thanks Cloud Team!
Once build, the Kafka Data Hub is our launching place for Cloudera Manager, Schema Registry and SMM.
From the DataHub cluster that we built for CFM - Apache NiFi or for Apache Kafka I can access Cloudera Manager to do monitoring, management and other tasks that Cloudera administrators are use to like searching logs.
Our module for Twitter ingest on CDP Data Hub.
We can download our flow immediately and quickly sent our code to version control.
We consume MQTT messages sent from my IoT gateway that is pushing messages from multiple devices via MQTT.
Using parameters that can be set via DevOps or via Apache NiFi, we setup a reusable component to read from any MQTT broker. Username, password, broker uri and topic are parameters that we set and can change based on any use needed.
Ingesting from Twitter is just as easy as reading from MQTT.
We can also parameterize our Twitter ingest for easy reuse. For this twitter ingest, we have some sensitive values that are protected as well as some query terms for twitter to limit our data to airline data.
Editing parameters from the NiFi UI is super easy.
All the data passing through the nodes of my cluster.
Apache NiFi has a ton of tabs for visualizing any of the metrics of interest.
Put To Hive Streaming Table
PutORC Files to CNOW3, autoconverted JSON to ORC
For storing to Apache Hive 3 tables, we have to set some parameters for Hive Configuration and the metastore from our data store.
We want to look at our data in Kafka, so the we can use Cloudera Streams Messaging Manager (SMM) to view, edit, monitor and manage everything Kafka.
We can build alerts for any piece of the Kafka infrastructure (broker, topics, etc...)
I want to look at the lineage, provenance and metadata for my flow from data birth to storage. Atlas is easy to use and integrated with CDP. Thanks to the automagic configuration done in Cloudera Enterprise Data Cloud - NiFi, Kafka, HDFS, S3, Hive, HBase and more are providing data that comes together in one easy to follow diagram powered by Graphs.
The connection to Atlas is prebuilt for you in Apache NiFi, you can take a look and see.
We push our merged ORC files to /tmp/cnow3 directory in S3 controlled by HDFS and full security for an external Hive table.
It becomes trivial to push data to S3, whether it's compressed JSON files or internal ORC files used in Hive 3 tables.