Let’s learn about Netflix Mantis Platform and some of the cool features it offers.

1. Overview

In this article, we’ll take a look at the Mantis platform developed by Netflix.

We’ll explore the main Mantis concepts by creating, running, and investigating a stream processing job.

2. What Is Mantis?

Mantis is a platform for building stream-processing applications (jobs). It provides an easy way to manage the deployment and life-cycle of jobs. Moreover, it facilitates resource allocation, discovery, and communication between these jobs.

Therefore, developers can focus on actual business logic, all the while having the support of a robust and scalable platform to run their high volume, low latency, non-blocking applications.

A Mantis job consists of three distinct parts:

  • the source, responsible for retrieving the data from an external source
  • one or more stages, responsible for processing the incoming event streams
  • and a sink that collects the processed data

Let’s now explore each of them.

3. Setup and Dependencies

Let’s start by adding the mantis-runtime and jackson-databind dependencies:

<dependency>
        <groupId>io.mantisrx</groupId>
        <artifactId>mantis-runtime</artifactId>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
    </dependency>

Now, for setting up our job’s data source, let’s implement the Mantis Source interface:

public class RandomLogSource implements Source<String> {

        @Override
        public Observable<Observable<String>> call(Context context, Index index) {
            return Observable.just(
              Observable
                .interval(250, TimeUnit.MILLISECONDS)
                .map(this::createRandomLogEvent));
        }

        private String createRandomLogEvent(Long tick) {
            // generate a random log entry string
            ...
        }

    }

As we can see, it simply generates random log entries multiple times per second.

#netflix #web-development #programming #developer

Introduction to Netflix Mantis
2.00 GEEK