<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Apache Spark and Apache Kafka at the rescue of distributed RDF Stream Processing engines</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Xiangnan Ren</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Olivier Cure</string-name>
          <email>olivier.cure@u-pem.fr</email>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Houda Khrouf</string-name>
          <email>houda.khroufg@atos.net</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Zakia Kazi-Aoul</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yousra Chabchoub</string-name>
          <email>yousra.chabchoubg@isep.fr</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>ATOS - 80 Quai Voltaire</institution>
          ,
          <addr-line>95870 Bezons</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>ISEP - LISITE</institution>
          ,
          <addr-line>Paris 75006</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>LIGM (UMR 8049)</institution>
          ,
          <addr-line>CNRS, UPEM, F-77454, Marne-la-Vallee</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Due to the growing need to timely process and derive valuable information and knowledge from data produced in the Semantic Web, RDF stream processing (RSP) has emerged as an important research domain. In this paper, we describe the design of an RSP engine that is built upon state of the art Big Data frameworks, namely Apache Kafka and Apache Spark. Together, they support the implementation of a production-ready RSP engine that guarantees scalability, fault-tolerance, high availability, low latency and high throughput. Moreover, we highlight that the Spark framework considerably eases the implementation of complex applications requiring libraries as diverse as machine learning, graph processing, query processing and stream processing.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1 Introduction</title>
      <p>The Resource Description Framework (RDF) is a exible data format that was
originally designed for the Web, and is now gaining popularity in the Internet of
Things (IoT). A majority of IoT data are dynamically generated from various
sources, e.g., sensors, and require inference services to meet their full analytic
potential. This trend leads to the notion of RDF Stream Processing (RSP) which
gains more and more attention as a research topic.</p>
      <p>
        Due to the baseline de ned by some RSP benchmarks such as LSBench [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
and SRBench [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], modern RSP engines need to address the following aspects:
support of SPARQL main operators, output correctness and engine performance.
To cope with these fundamental requirements, several centralized engines have
been proposed in the last decade, such as C-SPARQL [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] and CQELS [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Limited
by a centralized design, these systems can hardly deal with the volume growth
and velocity increase of RDF streams. Therefore, a distributed solution for RSP
is needed to deal with practical workloads. The current distributed RSP engines
such as CQELS-Cloud [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] and Katts [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] make a signi cant progress on engine
performance and scalability. Nevertheless, all available distributed RSP systems
lack important features, e.g., support for common SPARQL operators and are
not ready for production. Moreover, they do not integrate the state of the art
approaches that are currently guaranteeing fault tolerance, highly availability
which can enforce the system's robustness.
      </p>
      <p>To meet the expectations of Big Data projects, a novel RSP engine is
required. Motivated by the WAVES project1, this work provides insights on the
integration of Apache Kafka, a distributed messagging broker, and Apache Spark,
a distributed computing framework. These two Big Data frameworks will ensure
robustness, reliability and scalability properties.</p>
      <p>Applications based on stream processing frequently require di erent libraries
and tools, to (1) perform incremental and iterative tasks, e.g., query processing
and machine learning, (2) process graph data models and (3) handle all the
streaming machinery, e.g., continuous query, windowing operations. Currently,
two distributed stream processing frameworks have been emphasized by their
adoption in large industrial projects: Apache Spark and Apache Flink.
SparkStreaming is based on micro-batch execution mechanism, and provides the
subsecond delay. Flink is another popular massively parallel data processing engine
which supports real-time data processing and CEP. Due to the enrichment and
the maturity of the platform ecosystems, we choose Spark Streaming as the
framework of our RSP engine.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Use case</title>
      <p>Our motivating use case concerns the industrial application of water resource
network management. It aims to provide real-time analytics over RDF data
streams. The observations, also denoted as events, are dynamically generated
from various sensors and are hence anchored in spatio-temporal analytics. The
measures we are considering correspond to pressure, ow, chlorine, temperature
and turbidity. Their real-time analysis permit to detect water network anomalies,
such as water leaks, and can have important impacts at the economical and
environmental levels. Nevertheless, our goal is to design a generic RSP engine
that can easily adapt to use cases concerned with other domains. Intuitively, the
goal is to seamlessly integrate novel ontologies, data streams and sets of queries
within a highly distributed, reasoning-enabled, continuous query and complex
event processing system.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Architecture</title>
      <p>where t is the event timestamp. Then, the obtained RDF event streams are
continuously sent to the Kafka message broker. We use Kafka to manage incoming
event streams. Typically, each pre-de ned Kafka topic is associated to some
speci c RDF events (e.g., the event of ow observation or chlorine observation, etc.).
Finally, Spark-Streaming concurrently receives, caches and deserializes incoming
data streams.</p>
      <p>We combine Spark SQL, MLib and GraphX with Spark Streaming libraries to
form the computing core of our system. It mainly covers the RDF data analytic
in two aspects: basic timely SPARQL query processing and data mining over
RDF streams. Indeed, the canonical SPARQL query processing with external
and contextual data becomes valuable, which may also support stream reasoning.
Moreover, the system is also planned to meet the requirement of advanced data
analytic, such as classi cation and anomaly detection. Besides, Spark provides
a seamless connection among its available libraries, since they share the same
data collection abstraction, i.e. RDD. In the following, we present the tasks that
highlight the use of these libraries.</p>
      <p>Spark Streaming is an extension of the core Spark API and enables near
realtime stream processing. We use Spark Streaming as the basic stream processing
layer. It receives input data from Kafka, divides and parallelizes the data into
batches, which are next processed by Spark Core.</p>
      <p>
        Spark SQL provides a high-level abstraction to support distributed relational
operations. The work in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] gives a road map to choose the appropriate approach
for SPARQL query processing on Spark. In our system, we convert the input
RDF event into a data collection called DataFrame before query execution.
Then, we use Sesame API to parse a (continuous) SPARQL query and return
the query algebra tree. The obtained algebra tree allows us to reconstruct an
equivalent and optimized algebra tree on Spark, namely logical plan. Finally, we
dynamically generate the code from the logical plan for query processing.
      </p>
      <p>MLib is a native Spark library for machine learning. We use MLib to run
the data analytics pipeline. One of the target scenario is anomaly detection.
Once the event is received by Spark Streaming, we push events to the analytic
layer which uses classi cation algorithms and decision tree. For instance, we
compare measures for the same geographical sector on two di erent dates using
a clustering approach such as k-means.</p>
      <p>GraphX facilitates parallel graph processing on Spark. We mainly use GraphX
to generate semantic-aware dictionaries for our knowledge bases. Intuitively, it
enables to seamlessly compute connected components, for instance to compute
the transitive closure of some hierarchies or triples involving the owl:sameAs
property. This computation only requires to provide two RDDs, containing
vertices and edges of the RDF graph, to a given function. The output can easily be
processed within our Spark core program.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Conclusion</title>
      <p>RDF stream processing is an emerging area that is still in its infancy and hence
requires to conduct much more research. In this work, we present our envisioned
RSP system which is based on Spark Streaming and Kafka. These mature
ecosystems bring important properties expected in Big Data applications and have
proved to ease the design of application requiring libraries as diverse as machine
learning, graph computations, query processing and of course stream
management. In future work, we plan to extend our query processing with a trade-o
between two common reasoning approaches, namely materialization and query
reformulation.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Acknowledgment</title>
      <p>This work is funded by the Fonds Unique Interministeriel (FUI #17) through
the WAVES project, available at http://waves-rsp.org.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>D. F.</given-names>
            <surname>Barbieri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Braga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Ceri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. D.</given-names>
            <surname>Valle</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Grossniklaus</surname>
          </string-name>
          .
          <article-title>C-SPARQL: SPARQL for continuous querying</article-title>
          .
          <source>In Proceedings of the 18th International Conference on World Wide Web (WWW)</source>
          , pages
          <fpage>1061</fpage>
          {
          <fpage>1062</fpage>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>L.</given-names>
            <surname>Fischer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Scharrenbach</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Bernstein</surname>
          </string-name>
          .
          <article-title>Scalable linked data stream processing via network-aware workload scheduling</article-title>
          .
          <source>In Proceedings of the 9th International Workshop on Scalable Semantic Web Knowledge Base Systems</source>
          , pages
          <fpage>81</fpage>
          {
          <fpage>96</fpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>H.</given-names>
            <surname>Naacke</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Cure</surname>
          </string-name>
          , and
          <string-name>
            <given-names>B.</given-names>
            <surname>Amann</surname>
          </string-name>
          .
          <article-title>SPARQL query processing with Apache Spark</article-title>
          . ArXiv e-prints,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>D. L.</given-names>
            <surname>Phuoc</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Dao-Tran</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. X.</given-names>
            <surname>Parreira</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Hauswirth</surname>
          </string-name>
          .
          <article-title>A native and adaptive approach for uni ed processing of linked streams and linked data</article-title>
          .
          <source>In the 10th International Semantic Web Conference (ISWC)</source>
          , pages
          <fpage>370</fpage>
          {
          <fpage>388</fpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>D. L.</given-names>
            <surname>Phuoc</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Dao-Tran</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Pham</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Boncz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Eiter</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Fink</surname>
          </string-name>
          .
          <article-title>Linked stream data processing engines: Facts and gures</article-title>
          .
          <source>In the 11th International Semantic Web Conference (ISWC)</source>
          , pages
          <fpage>300</fpage>
          {
          <fpage>312</fpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>D. L.</given-names>
            <surname>Phuoc</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H. N. M.</given-names>
            <surname>Quoc</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. L.</given-names>
            <surname>Van</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Hauswirth</surname>
          </string-name>
          .
          <article-title>Elastic and scalable processing of linked stream data in the cloud</article-title>
          .
          <source>In The 12th International Semantic Web Conference (ISWC)</source>
          , pages
          <fpage>280</fpage>
          {
          <fpage>297</fpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Pham</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Corcho</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Calbimonte</surname>
          </string-name>
          .
          <article-title>Srbench: A streaming RDF/SPARQL benchmark</article-title>
          .
          <source>In the 11th International Semantic Web Conference (ISWC)</source>
          , pages
          <fpage>641</fpage>
          {
          <fpage>657</fpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>