Inferring latent user attributes in streams on multimodal social data using spark
Abstract
The principal goal of this work can be expressed in two simple words Apache Spark; basically this framework help a developer to deal with big data. Our scope is to understand how Spark operates and use it to deal with Big Data using APIs offered for implement different classifier.
Full text
Inferring Latent User Attributes in Streams of Multimodal Social Data using Apache Spark A thesis presented By Alessio Conese Supervisor: RUBÉN TOUS LIESA JORDI TORRES VIÑALS FIB - Facultat d'Informàtica de Barcelona Barcelona, 2015
I ABSTRACT The work aims to discover and exploit the features of Apache Spark, which is open-source data analytics cluster computing framework that provides primitives for in-memory cluster computing that makes it well suited for this type of problems. For this purpose, initially, it is analyzed a multimodal social data such as community-contributed photos and videos (e.g. Instagram or Twitter). In this part the data are analyzed to obtain model used to understand a possible affiliation of the users to a precise social network group. After, in order to analyze the behavior of Apache Spark in a real cluster, was built an implantation of Spark in the MareNostrum supercomputer. The software obtained from the first part is executed in the in the cluster to obtain a measurement of the models quality. In addition, this document describe the step to work with Spark, its advantages and disadvantages, and the implementation in a cluster, with a briefly analysis of its scalability and performance.
II TABLE OF FIGURE Figure 1-1. Increment of digital data in the last 10 years and his possible evolution ...... 9 Figure 3-1. Histogram perfomance for logistic linear regression ................................... 13 Figure 3-2. Spark timeline version with added features ................................................. 14 Figure 3-3. Apache Spark stack ...................................................................................... 15 Figure 3-4. Spark Streaming flow ................................................................................... 17 Figure 3-5. Property Graph example .............................................................................. 18 Figure 3-6. Graph and table manipulation example ....................................................... 18 Figure 3-7. Stack of MLbase .......................................................................................... 19 Figure 3-8. Simple architecture for a run application ..................................................... 20 Figure 3-9. HDFS client operation schema .................................................................... 22 Figure 3-10. HDFS architecture ...................................................................................... 23 Figure 3-11. MapReduce overiew .................................................................................. 24 Figure 3-12. Sequence File layout whit records or blocks fields .................................... 25 Figure 3-13. Structure of Shuffle and Sort phases .......................................................... 27 Figure 3-14. Configuration stacks to run Spark over Hadoop ........................................ 28 Figure 3-15. Possible types of dependencies among RDDs ........................................... 30 Figure 3-16. Schema of the flow in the iterative phase .................................................. 32 Figure 3-17. Schema of the flow in the initialization phase ........................................... 33 Figure 3-18. Final schema of the RDDs and its dependencies ....................................... 34 Figure 3-19. SparkR data flow schema ........................................................................... 35 Figure 3-20. New BlinkDB component for Spark stack ................................................. 36 Figure 3-21. Yahoo chooses to work with Shark to provide Ad Analytics .................... 37 Figure 3-22. Conviva network status control .................................................................. 37 Figure 3-23. ClearStory process include in-memory computation done by Spark ......... 38 Figure 4-1. Most used tags .............................................................................................. 47 Figure 4-2. Example of one JSON object store in the file data sample .......................... 48 Figure 4-3. Example of hyperplane that separate points in two different categories ..... 51 Figure 4-4. Graph of the logistic function ...................................................................... 53 Figure 4-5. Binary classification with Naive Bayes, the two categories created and the decision boundary is shown in red .................................................................................. 54 Figure 5-1. MareNostrum supercomputer inside the glass box of Torre Girona chapel. 55
III Figure 5-2. Panoramic of MareNostrum racks: 7 Storage Server (green), 4 Network elements (red) and the Computation racks (blue). .......................................................... 58 Figure 5-3. Shared Disk environment ............................................................................. 59 Figure 5-4. LSF schema. ................................................................................................. 60 Figure 5-5. Job lifecycle ................................................................................................. 62 Figure 5-6. Nodes distribution mode .............................................................................. 64 Figure 5-7. Example of a job configuration file for spark4mn command ...................... 66 Figure 5-8. Example for setting a range of value in spark4mn_benchmark configuration file ................................................................................................................................... 67 Figure 6-1. Histograms of the models accuracy ............................................................. 74 Figure 6-2. Comparison of models accuracy .................................................................. 75 Figure 6-3. Confusion matrices of Logistic Regression, Support Vector Machine and Naive Bayes .................................................................................................................... 75 Figure 6-4. Performance of Naive Bayes using 4 workers per node and different number of nodes ........................................................................................................................... 77 Figure 6-5. Performance of K-means using 4 workers per node and different number of nodes ............................................................................................................................... 77 Figure 6-6. Performance of Naive Bayes using 4 nodes and different number of workers per node ........................................................................................................................... 78 Figure 6-7. Performance with 2 cores per worker .......................................................... 78 Figure 6-8. Performance with 4 cores per worker .......................................................... 79 Figure 6-9. Performance with 8 cores per worker .......................................................... 79 Figure 6-10. Histogram of performance using different partitions and number of workers per node ........................................................................................................................... 80
IV TABLE OF CONTENTS Abstract .............................................................................................................................. I Table of Figure ................................................................................................................. II 1. Introduction ............................................................................................................... 7 Motivation .......................................................................................................... 7 Objectives ........................................................................................................... 8 2. Big Data ..................................................................................................................... 9 Increasing data ................................................................................................... 9 About Big Data .................................................................................................. 9 New Paradigms ................................................................................................ 10 2.3.1 Volume ...................................................................................................... 10 2.3.2 Variety ...................................................................................................... 10 2.3.3 Velocity ..................................................................................................... 11 2.3.4 2 more V: Value and Veracity .................................................................. 11 Relevance of Big Data and Application ........................................................... 11 Frameworks ...................................................................................................... 12 3. Apache Spark ........................................................................................................... 13 What is Spark ................................................................................................... 13 3.1.1 Spark Version and history ......................................................................... 14 Stack ................................................................................................................. 14 3.2.1 Spark Core ................................................................................................ 15 3.2.2 Spark SQL ................................................................................................. 16 3.2.3 Spark Streaming ........................................................................................ 16 3.2.4 GraphX ...................................................................................................... 17 3.2.5 MLlib ........................................................................................................ 18 3.2.6 Cluster Managers ...................................................................................... 19 Spark and Hadoop ............................................................................................ 21 3.3.1 Hadoop ...................................................................................................... 21 3.3.2 Working together ...................................................................................... 27 3.3.3 Performance comparison .......................................................................... 28 Spark execution ................................................................................................ 29 3.4.1 RDD in deep ............................................................................................. 29 3.4.2 DAG (Directed Acyclic Graph) ................................................................ 30
V 3.4.3 Execution .................................................................................................. 31 New Features ................................................................................................... 34 3.5.1 SparkR ...................................................................................................... 35 3.5.2 BlinkDB .................................................................................................... 35 Spark real use cases .......................................................................................... 36 3.6.1 Yahoo! ...................................................................................................... 36 3.6.2 Conviva ..................................................................................................... 37 3.6.3 ClearStory ................................................................................................. 38 4. Implementation ........................................................................................................ 40 TOOLS ................................................................................................................. 40 4.1.1 Scala language .......................................................................................... 40 4.1.2 SBT ........................................................................................................... 41 The Dataset ....................................................................................................... 45 Algorithms........................................................................................................ 47 4.3.1 TF-IDF ...................................................................................................... 48 4.3.2 Feature Hashing and bigrams ................................................................... 49 4.3.3 Counting Frequency .................................................................................. 50 4.3.4 SVM – Support Vector Machine .............................................................. 51 4.3.5 Logistic Regression ................................................................................... 52 4.3.6 Naive Bayes .............................................................................................. 53 5. Implementation in a cluster ..................................................................................... 55 BSC .................................................................................................................. 55 5.1.1 History ...................................................................................................... 56 5.1.2 MareNostrum ............................................................................................ 56 Spark and MareNostrum .................................................................................. 63 5.2.1 Setup ......................................................................................................... 63 5.2.2 Commands ................................................................................................ 65 5.2.3 Configuration file and logs ....................................................................... 65 6. Evaluation ................................................................................................................ 69 Models evaluation ............................................................................................ 69 6.1.1 Methodology ............................................................................................. 69 6.1.2 Results ....................................................................................................... 72 Spark on MareNostrum .................................................................................... 75 6.2.1 Methodology ............................................................................................. 75 6.2.2 Results ....................................................................................................... 76
VI 7. Conclusion and Future Work ................................................................................... 81 Future Work ..................................................................................................... 82
13 3. APACHE SPARK Apache Spark provides an attractive, attractive development API and permit data workers to rapidly iterate over data via machine learning and other data science techniques that require fast, in-memory data processing. Actually Spark is the most active project in the Big Data ecosystem, it was originally developed in 2009 in UC Berkeley’s AMPLab, and open sourced in 2010 and it is immediately become a top-level Apache project and interesting topic in all the big data communities, with over 200 contributors in 50+ organizations. In this part are explained all the relevant components, the basic structure and the library that are included in Spark. The first step is to understand in concrete what is spark, and why has been chosen for this project. After that, is described the stack the stack of the framework and each part of it. Finally, are illustrated the library include and the application in which Spark can used. WHAT IS SPARK Spark is s general-purpose open source computing framework specialize in big data analytics, it builds on top of Hadoop HDFS system, is totally compatible with it and is not tied to the map reduce platform. It offers different solution for the developers in three main languages Python. Java and Scala, but the last one is the more suitable for the framework, because the documentation and the implementation algorithm are principally done with this. Apache Spark is platform implemented for cluster computing and it is designed to be fast. It use a own reformulation of MapReduce, to increase the support of the type in the computation, and adding new interesting features, like the possible to streaming processing and to submit queries in real time. Obviously, Spark was born for Big Data application, so the most important quality is the processing large data set very fast. Spark is designed in manner to allow an easy combination of different processing times and to cover a wide range of workloads that previously required separate distributed systems, like batch application, interactive queries, streaming and iterative algorithms. Spark become very popular for its ease of use, is possible to use object-functional scripting and intuitive API, with a little effort is possible to write simple code in order to obtain a good result in data analysis, quite hard with previous framework. Figure 3-1. Histogram perfomance for logistic linear regression
14 Hadoop is the standard for large scale data processing across nearly every industry and enterprise, it scales out computation and storage across cheap commodity servers and allows other applications to run on top of both of these. A bonus point for Apache is a totally integration with Hadoop, in fact it is built on top of Hadoop and is intention is to enhance, not replace, the Hadoop stack, it tries to making it as easy as possible for every Hadoop user to take advantage of its capabilities, such as better utilization of compute capacity, reduce unnecessary replicated reads and writes and the elimination of the need for data transfer in and out of the cluster, obtaining a performance 10-100x faster of Hadoop. Spark is not only compatible with Hadoop, but it can also runs with Mesos, standalone, or in the cloud, and it can access diverse data sources including HDFS, Cassandra, HBase, S3. 3.1.1 Spark Version and history Spark started in 2009 as a research project in the UC Berkeley RAD Lab, later to become the AMPLab. In the begin they were working on Hadoop MapReduce, seeing that it was inefficient for iterative and interactive computing jobs, so they start to implement Spark on Hadoop, in the same year research papers were published about the project academic conferences. After one year the code was open sourced and a license was acquire. In 2011, was started the development for the high live component, such as Shark or Spark Streaming. From the beginning, was a very popular project with an active participating from the community, who participation increase every day, in fact the creators of Spark decides to found the DataBricks society to commercialize it. The first version, the 1.0.0 was released May 2014, in about 7 months the project is arrived at the version 1.3.0, release only in March 2015. STACK Spark tries to combine and integrate different component and so is stack is compose from different multiple closely-integrated components. The total integration of the components provide a closely interoperation, letting you combine them like libraries in a software project and giving some benefits from improvements at the lower layers. Every time that a new Figure 3-2. Spark timeline version with added features
15 component is included in the stack, Spark is able to provide a perfect interoperability and so every organization that uses Spark will immediately be able to try this it, reducing the cost of trying. Imaging to run a different program for each stack, without interoperability, you have start an execution 5-10 times, instead that only one, also this feature allows to save time and money. The figure below shows the entire stack of Apache, it will now be describe in each part. 3.2.1 Spark Core Spark core is the center of the framework, it contains the basic functionality of Spark, its API and it is an abstraction layer called Resilient Distributed Datasets, or RDDs. The core contains all the important functions to work with Spark, such as for task scheduling, memory management, fault recovery, interacting with storage systems, and more. 3.2.1.1 RDDs overview RDDs are Spark’s principal programming abstraction, they represent a collection of items distributed across many compute nodes that can be manipulated in parallel. RDD contains also metadata, such as information on the location of their data partitions. It is formally a read-only, immutable distributed collection of objects. Each RDD is split into multiple partitions, which may be computed on different nodes of the cluster. They could be created in different manner. The first method is by referencing datasets in external storage systems, the second is by applying coarse-grained transformation computed on other RDDs. All the sequences of transformations performed are, forming a directed acyclic graph (DAG, called “lineage” in Spark) which is used to calculate its data partitions from the original data. This DAG is used to regenerate an RDD after a failure, ensuring fault-tolerance within an application. Figure 3-3. Apache Spark stack
16 On a RDD is possible to execute two possible operations, the principal different is the way how Spark compute the result: Action that compute a new result based on the RDD itself, and returning it to the system or saving in external space. The concept of an action is to do something (e.g. count number of elements) with the dataset and return a final value to driver program. Transformation is every operation that give a new RDD for result. The transformation could be done on one RDD (e.g. filter, map, flatMap) or between more than one RDD (e.g. join, union, cogorup). Usually RDD executes transformation in Lazy evaluation, means that the real execution of the transformation begin only when Spark find an action apply on it. To do this, Spark store only the metadata of the transformation, is possible to see an RDD like a as container of instructions on how to compute the data, and at the moment of the first action on it, it start the real execution of the transformation. The lazy evaluation can appear counter intuitive, but Spark uses this approach to reduce the number of passes it has to take over our data by grouping operations together. 3.2.2 Spark SQL Spark SQL works on top of Spark core, it introduces a new data abstraction called SchemaRDD and similar to a normal RDD, but it provides support for structured and semistructured data and can be used interacting with Spark via standard SQL. Each query lunched is transformed in a RDD operation, and it is applied to the SchemaRDD, so the developer can intermix use of SchemaRDD like a normal RDD, manipulating data with complex analytics trough domain-specific language (Scala, Java and Python), or treat it as a database table giving to developers the power to integrate SQL commands in only single application. Spark SQL permit to manipulate different type of source and join it with simple command, it supports many different types of data and can unified them through the SchemaRDD, such as Apache Hive tables, parquet files and JSON files. It also include a server mode that offer a standard connectivity through JDBC or ODBC to run your query. 3.2.3 Spark Streaming Spark Streaming is general framework built on the Spark Core and it enables the processing live streams of data and real-time data processing, it gives provides a high-level abstraction called discretized stream or DStream, which represents a continuous stream of data, implemented in a sequences of RDDs. The streaming component provides API for manipulating data streams, and it is designed to have the same level of fault tolerance, throughput, and scalability. The Spark streaming approach differs from many existing streaming engines, because it uses a micro-batch, mean it captures input from a stream for a pre-defined interval and at the end a batch is created upon which data manipulation are executed. After all, each batch created is stored as a collection of RDD, and these are processed as explained in the previous section.
17 Spark Streaming is compatible with different types of data source, in fact one or more DStream can be created reading data from two principal categories of sources: Basic sources: Sources directly available in the StreamingContext API. Example: file systems, socket connections, and Akka actors. Advanced sources: Sources like Kafka, Flume, Kinesis, Twitter, etc. are available through extra utility classes. In details, every input data, present in form of DStream, is associated with a Receiver object that store the source in the Spark’s memory, where can be processed and transformed with the Spark engine. In the processing phase can be used all the function present in the spark stack (machine learning, graph processing or whatever) and the result obtained can be pushed out to filesystems, databases, and live dashboards. 3.2.4 GraphX Another component of Spark stack is GraphX, it is a library containing the Spark API and it has the scope to unify graph-parallel and data-parallel computation in one system with a single composable API. The new era of social network brings a different concept of data storage, indeed an inflexible structured data, actually are presented revolutionary representation of data in the system. One of this is exactly a graph representation, which is based on vertex, usually the data with its properties, and edge, a link that can also contain properties which represents a connection between the data. The graph theory can be applied in a lot of fields, from protein modeling to social networks and targeted advertising and astrophysics, big graphs capture the structure in data and model them with a new free schema concept. The importance of this different representation of data is shown by the increase of new technologies schemaless (without a rigid schema), such as NoSQL database, in fact these database lost the classic model of relational databases, The GraphX introduce the directed multigraph with properties in the Spark context and support it in the computation, with all the important operations usable in a normal graph (search subgraph, minimum spanning tree, etc.) for a complex data analysis. As DStream of Spark Streaming, GraphX owns its type of RDD, called Resilient Distributed Property Graph, which are partition and distribute graphs that permit a rapid conversion from graph to table, and viceversa. RDP graph is a directed graph with potentially multiple parallel edges sharing the same source and destination vertex. It has the ability to support parallel edges Figure 3-4. Spark Streaming flow
18 simplifies modeling scenarios where there can be multiple relationships between the same vertices. Vertex and edges have each one own identifiers and GraphX does not impose any ordering constraints on these the identifiers. As before, the data can be acquire directly in form of graph, all the computation can be done directly on the graph, or transforming it, and is possible to repeat this action each time that developer need it. 3.2.5 MLlib MLlib is a Spark subproject providing primitive machine learning library consisting of common learning algorithms and utilities. Machine learning (ML) and statistical techniques are key to transforming big data into actionable knowledge. In Big Data the principal main is to extract important value from different fast data inflows, in fact value from such Big Data is a growing concern, and machine learning techniques enable users to extract underlying structure and make predictions from large datasets. In Spark the distributed machine learning algorithms are provided by MLlib component, that Figure 3-5. Property Graph example Figure 3-6. Graph and table manipulation example
19 achieves high-quality algorithms, 100x faster than MapReduce, and also present some lower level ML primitives. The main algorithms categories offered by MLlib are: Classification Regression Collaborative filtering Clustering Decomposition MLlib works directly over Spark, and like other components, is totally integrated with the environment, so is possible to improve the data analysis using the spark components. MLlib was initially developed as part of the MLbase project, which is a platform that aims to make machine learning accessible to a broad audience of users and applicable to various data corpora, ranging from small to very large data sets. It consists of three components MLlib and two others: MLI: An experimental API for feature extraction and algorithm development that introduces highlevel ML programming abstractions. ML Optimizer: Layer that aims to automating the task of ML pipeline construction. The optimizer solves a search problem over feature extractors and ML algorithms. MLlib is the principal component used in this work, so it will be explained deeper in the following chapter. 3.2.5.1 Spark ML Starting from the version 1.2 Spark introduces a new package called ML, which is an alpha component that aims to provide a uniform set of high-level APIs that help users create and tune practical machine learning pipelines. ML tries to make machine learning algorithms easier to combine multiple algorithms into a single pipeline, or workflow. Spark ML will not use in this work, for that will not describe in deep 1 . 3.2.6 Cluster Managers The last component in the stack is the lower level of Spark stack, the cluster managers. A cluster manager is mostly used to dispatch work for the cluster to perform. Spark includes a simple cluster manager called Standalone Scheduler and also it is developed to work with a variety of cluster, such as Hadoop YARN and Apache Mesos. 1 for a more detailed description, please visit the official guide: ‘http://spark.apache.org/docs/latest/mlguide.html’ Figure 3-7. Stack of MLbase
20 3.2.6.1 How it works When a user run an applications run Spark submit the work as independent sets of processes on a cluster, the coordinator of the cluster is SparkContext object, which is initialize in the main program, called driver program. When the program is executed, SparkContext can connect to various type of cluster manger, such as those previously mentioned, which is used to allocate resources across applications. Once connected, the node in the cluster are acquired, in each node is created an executor, which is process that run computations and store data for your application. Finally, the driver program sends code to the executor and the tasks that they have to run. The figure shows the architecture of simple cluster (only two node) when an application is executed. When an application is started, it gets its own executor processes, which stay up for the duration of the whole application and run tasks in multiple threads, in this manner, each application has a complete isolation from the others on both the scheduling side and executor side, but this also denies to share data among the applications, so it is necessary to use an external storage system for the data sharing. 3.2.6.2 Cluster manager supported Spark has different cluster manager already supported, but it is possible to use its own cluster manager. 3.2.6.2.1 Apache Mesos Apache Mesos is built with the same principles as the Linux kernel, but at a different level of abstraction. The Mesos kernel runs on every machine and provides API’s for resource management and scheduling across entire datacenter and cloud environments. It in Spark determines what machines handle what tasks. Work with Mesos gives the advantage to have Figure 3-8. Simple architecture for a run application
21 a dynamic partitioning between Spark and other frameworks and to scalable partitioning between multiple instances of Spark. 3.2.6.2.2 YARN YARN (Yet Another Resource Negotiator) is a resource-management platform responsible for managing compute resources in clusters and using them for scheduling of users' applications. It is one of the key features in second-generation Hadoop, basically it is an evolution version of MapReduce, called MapReduce 2.0 (MRv2). Working with YARN gives the advantages to improve reliability, security and easing the debugging process 2 . 3.2.6.2.3 Amazon EC2 Amazon EC2 is the central part of Amazon Web Service (AWS) cloud computing platform. In this case, Spark not really works with EC2, but is possible to run it in standalone cluster mode with a script that allows to launch, manage and shut down Spark on Amazon EC2. 3.2.6.2.4 Standalone Standalone is the cluster manager already include in Spark that makes it easy to set up a cluster. Is possible to launch a standalone cluster either manually, by starting a master and workers by hand, or use our provided launch scripts. SPARK AND HADOOP In order to understand Spark, is necessary an explanation about his cousin Hadoop, in fact it works in Hadoop ecosystem and tries to improve his lake. It introduces interactive processing missing in Hadoop, which offers only batch processing, and it is compatible with any Hadoop Input/OutputFormat. Even if Hadoop MR is much more mature, Spark make easier the approach with Big Data world. 3.3.1 Hadoop Hadoop is an open-source Java-based framework and it is the pioneer a fundamentally new way of storing and processing data. It enables distributed parallel processing of big data across inexpensive, industry-standard servers that store and process the data and can scale without limits. It designed to scale up from a single server to thousands of machines, with a very high degree of fault tolerance, in fact Hadoop core is divided in two principal parts, the storage part and processing part. It is composed of 4 principal components: Hadoop Common – Is the part that contains the libraries and utilities used by other modules and contains the necessary Java ARchive (JAR) files and scripts needed to start Hadoop; 2 Extract from the article 'Extending Spark on YARN for Enterprise Hadoop’ http://hortonworks.com/blog/
22 Hadoop Distributed File System (HDFS) – a distributed file-system that stores data on commodity machines, it is built using the Java language; Hadoop YARN – already described in the previous part; Hadoop MapReduce – a programming model for large scale data processing. 3.3.1.1 Hadoop distributed file system Data in a Hadoop is split down into smaller blocks and distributed throughout the cluster, its goal is to use commonly available servers in a very large cluster, where each server has a set of inexpensive internal disk drives, in this way functions can be executed on smaller subsets of your larger data sets, and this provides the scalability that is needed for big data processing. To minimize network congestion and increases the overall throughput of the system, the request by an application is executed near the data it operates on, this makes much more efficient the computation and it is especially true when the size of the data set is huge. Further, HDFS is designed to be highly fault-tolerant and deployed on low-cost hardware, basically a instance consist of hundreds or thousands of server machines, each one storing part of the file system’s data and with a non-trivial probability of failure, in case that a component fails the detection of faults is quick and an automatic recovery start in the HDFS. The HDFS usually manages 3 different replication of each data block to ensure reliability, availability and performance. The architecture of an HDSF is composed in different part: NameNode – In a cluster there is a single NameNode, which stores the directory tree of all files in the file system, and records where in the cluster the file data is store, furthermore it executes file system namespace operations like opening, closing, and renaming files and directories. The file system namespace is maintained by the NameNode and all the changes made on namespace or its properties is recorded by it. Unfortunately, the NameNode is Single Point of Failure in the cluster, in fact when it goes down, the whole system becomes offline, in any case is possible to activate another second NameNode to avoid that the whole system goes down. Figure 3-9. HDFS client operation schema
29 Analyzing the Table 3-1 the result is evident, Spark has better performance, using 10x fewer machine it completes benchmark test in 23 minutes, against the 72 minutes of Hadoop, so it is 3X times faster. The table shows that the ratio between sort rate and number of nodes, is more than 20X in favor of Spark. To push Spark they did a further test sorting 1 PB of data, and the result is that Spark can complete the job in less 4 hours using only 190 machines, beating the previous result of 16 hours on 3800 machines done with Hadoop MapReduce (6). SPARK EXECUTION In this section is illustrated how Spark works in concrete, the first step to begin is to understand how an RDD is composed and its features. 3.4.1 RDD in deep In the section 3.2.1.1 above was already explained an overview on the RDD, now is analyzed in deep what it contains. It is composed of five parts (7) of information: The transformation details on which the RDD depends Partitioning scheme metadata Data placements metadata A set of dependencies on partitions in parent RDDs A set of partitions containing the data stored in the RDD Is important to remember that the RDD is a read-only and immutable after his creation, so each operation (transformation or action) create a new RDD, which contains the five parts said before. So, every time that is created a new RDD, it depends on the partitions of their parent RDD. There are four different type of dependencies based on the type of transformation or action: # Nodes 2100 206 190 # Cores 50400 physical 6592 virtualized 6080 virtualized Cluster disk throughput 3150 GB/s (est.) 618 GB/s 570 GB/s Sort Benchmark Daytona Rules Yes Yes No Network dedicated data center, 10Gbps virtualized (EC2) 10Gbps network virtualized (EC2) 10Gbps network Sort rate 1.42 TB/min 4.27 TB/min 4.27 TB/min Sort rate/node 0.67 GB/min 20.7 GB/min 22.5 GB/min Table 3-1. Sort Benchmark result comparison for Hadoop and Spark
30 Narrow It is the faster because parent’s and child’s partitions are stored in the same node, this means that is not needed network communication. One-to-one Wide In this case the data dependencies from other RDDs might need network communication among different nodes, it generates more overhead and delay in the RDD generation. One-to-many Many-to-one Many-to-many Also, it is necessary to remember that the RDD is computed in lazy mode, so the data is evaluated only when an action operation is called by program or is execute data writing to external storage, thus a runtime can schedule tasks based on data locality to improve performance. 3.4.2 DAG (Directed Acyclic Graph) In order to handle RDDs dependencies is created a DAG, this is one of the Spar keys. It is new concept that generalize the MapReduce multi-stage execution model and it is the basement for Spark program execution. It is used to model the RDDs lineage, thus Spark can reach significant performance improvements. In Hadoop MapReduce the sequence of action is always the same, first the data are read from HDFS, after is applied map and reduce, and finally the result is written back to HDFS. In this sequence of action Hadoop doesn’t have a global knowledge of what are happening during MR steps of different jobs, because each MR is isolated and independent from the others. This partial view could deteriorate the performance in case are used many iterative algorithms, because the job can operate many read and write on the filesystem. Spark in order to improve performance over Hadoop used a different approach for each job, it creates a DAG of map-reduce steps considering all the jobs, so it can optimize the globally performance. Spark’s include many actions, such as reduce, count, collect, etc. An action triggers Spark to construct a DAG composed by multiple stages, they are connected through the shuffle Figure 3-15. Possible types of dependencies among RDDs
31 operations for intermediate data shuffling and each stage contains many transformation that can be modeled as a pipeline. In every type of MR implementation, intermediate data shuffling is a major performance bottleneck, for this reason Spark tries to avoid the overhead using locale partitions (8). A DAG concretely is composed by different chunks (called stages), each one representing a calculation that can be computed in on one node and, without the needing of network communication, and containing a list of consecutive RDDs (zero or more) with near dependencies. The narrows dependencies in a single stage are executed as pipeline. All the transformations executed in one chunk produce as output always one RDD. A simple example is given by consecutive map steps, with DAG is possible to prevent writing data back and forward after each reduce, in practice we can imagine to have jobs A and B that are independent of each other, and another job C needs the results from A and B to complete, so Spark model a DAG to understand the dependencies of the jobs and then it can take the decision to execute A and B in any order and forward the results to C, without store the data in the file system. Also, Figure 3-12 shows an example of task, in this case the task A and B can be merged in one stage, like C, D and E, so we obtain two stages. Other two stages are B’ and F. When the program is execute the DAG is built and it present a list of the four stages and their dependencies. The scheduler decides the order to resolve the dependencies, in the Figure 3-11 it can choose between A-B and C-D-E. After their execution the job can continue after all the stages are completed and so the program can be terminated (9). 3.4.3 Execution When a job is submitted first of all the Spark sees if enough memory is available, because is not required checkpointing to a DFS saved on HDD and data are stored in-memory (if the user not require persist HDD). When the execution start we can divide the data in two category, the static data and the intermediate data, these are separated in the initialization step by Spark and only the data that flows through the computation are saved (Figure 3-17).
32 In this first phase the behavior of Spark and Hadoop are equal, so the map and sort phase are executed in the same manner, instead after the sort in Apache spark are two steps. The first step creates a list containing the collaborating elements for one RDD, in this step the RDD created is static and is possible to perform multiples read on it. In the following step is created a dynamic RDD, which contains intermediate results that can be read only once time and after it is forgotten because in this step the created RDDs are immutable and they can’t be used another times for further storage (Figure 3-16). Figure 3-16. Schema of the flow in the iterative phase
33 Is possible to see in the Figure 3-18 the execution schema of the example relative to the Figure 3-15. In the final flows we can see that are not used middle RDDs, in fact is not needed to rebuild the DAG, because we cached it in memory, so the performance are increased. The problem in this approach is the memory capacity, but the approach allows to perform the operations like reduce, join, map and sort can in pipeline, so in not require a global checkpoint anymore. Figure 3-17. Schema of the flow in the initialization phase
34 NEW FEATURES Spark tries to broaden one's horizons adding new features and working with other software, in this manner it can be used in different fields, like statistic or simulation of system. In this work are presented two particular features adding from the version 1.3.0, the first one is SparkR and the second is BlinkDB. Figure 3-18. Final schema of the RDDs and its dependencies
35 3.5.1 SparkR R is a free software widely used for statistical computing and graphics, but usually its uses are limited to a single machine. Spark focus its effort to enable large scale data analysis from R. SparkR is an open source R package that uses rJava to call Java/Scala code, it could be seen as a lightweight frontend to use Spark from R. It allows users work with the R shell in order to lunch jobs interactively and manipulate the data in a Spark cluster. All the distributed operation are hided to the user, so he can user SparkR without knowing the implementation or the detail of the system. SparkR automatically serializes the necessary variables to execute a function on the cluster and in case of needed, computation module of R can be loaded in the cluster via a built-in function. Also, it is in project to integrate SparkR with Spark's MLlib machine learning library. To allows the interaction between Spark and R is re-used the concept of RDD, but adapting it converting the object in a Distributed List of R, called 2RDDS, that permit to apply R function to each line of an RDD. In the Figure 3-19 is shown a data flow example, the user can interact with the SparkContext from a R shell, lunching the job spark as usual divide the workload among the worker, each worker create a R session to execute its task. The result of each worker follow the normal procedure of Spark. 3.5.2 BlinkDB BlinkDB is a massively parallel, approximate query engine for running interactive SQL queries on large volumes of data. In BlinkDB query are lunch over massive data and the user can have the ability to trade between accuracy and response time, ensuring that the result is still meaningful. This new approach is necessary because data sets continue to grow, and could become impossible to analyze all the data in a limit time, so BlinkDB based is result not looking at all the data, but rather operating on statistical samples of the datasets, giving a response faster than normal database, but it needs to associate to each query an error bars. BlinkDB is based on two principal point, the first one is a dynamic sample selection strategy that selects an appropriately sized sample based on a query’s accuracy or response time requirements, and the second is adaptive optimization framework that builds and maintains a set of multi-dimensional stratified samples from original data over time (10). Figure 3-19. SparkR data flow schema
36 Spark helps BlinkDB to deal with a large dataset providing the API to work in a cluster and make faster the computation using its approach of in-memory MapReduce. This is possible adding over SparkSQL or Shark a new component to interact with BlinkDB. SPARK REAL USE CASES Spark evolves very fast over the time, always more it widens its application, and always more the companies are interested to deal with it. Many important companies starting to use Spark to face their needs. In this part are presented some interesting use cases of Spark in the real world. 3.6.1 Yahoo! Yahoo tries to make the world's daily habits inspiring and entertaining focusing to the transform the users’ experiences in a highly personalized and optimized experiences. But the bottleneck of this ‘dream’ is the Big Data, in fact create a personal dream for each user can become critical for their hundreds of millions of users. Spark enter in the dream creation for the yahoo users, two projects are adopted by yahoo. The first one is for personalizing news pages for Web visitors, to reach this objective are used ML algorithms running on Spark, in order to figure out what individual users are interested in, furthermore it is used to to categorize news stories as they arise to figure out what types of users would be interested in reading them. The second project is running Spark to analytics for advertising. The projects require the processing power of the entire cluster and Yahoo decides to use Spark to improve performance of its iterative model training. The reason that bring Yahoo to use Spark is simple, when a user want a personalization page, the system needs to react fast to understand what the user is doing and to answer on the events happening in the outside world. When a user look at Yahoo’s home page the system has to choose which items are going to show. In order to decide is necessary to learn something about each news item as it comes in to see what users may like it. And in the same time is necessary to learn something about users as they click around to figure out that they’re interest in a topic. Yahoo address this problem using Spark, it wrote wrote a Spark ML algorithm 120 lines of Scala that going to replace the previous code of ML algorithm for news personalization Figure 3-20. New BlinkDB component for Spark stack
37 written in 15,000 lines of C++. This code is used to trains a model on a large, hundred million record data set, and in less than 30 minute the Scala ML algorithm was ready for business. The second project is born with the needs of use existing BI tools to view and query their advertising analytic data collected in Hadoop. Yahoo uses Hive on Spark, called Shark, to allow interactive capability. The advantage of this is that Shark uses the standard Hive server API, so any tool that plugs into Hive, like Tableau, automatically works with Shark, and as a result they were able speed up the interactive and complex analytics and query (11). 3.6.2 Conviva Conviva is one of the largest video companies on the internet, managing over 4 billion video streams per month, second only to YouTube. They has a dynamical approach to select and optimize sources, while the video is playing, to maximize quality; this could be extremely critical in terms of time, if a viewer has to wait much of 1 second buffering, he can decide to leave the platform. To react before the buffer runs out, switching to a different stream, it requires pretty sophisticated behind-the-scenes technology to ensure a high quality of service. Conviva uses Spark Streaming to learn network conditions in real-time and so it can feeds directly the video player, to optimize the streams and guarantee the QoS avoiding dreaded screen buffering. The process to analyze the network conditions starts with an overview of how data flows through the Conviva infrastructure. Conviva monitoring and optimization code embedded and collects nonpersonally identifiable information like buffering time and frame rate, all these data are sent to Conviva’s Figure 3-21. Yahoo chooses to work with Shark to provide Ad Analytics Figure 3-22. Conviva network status control
38 backend infrastructure every few seconds. After, the data is replicated into two streams, the first is sent into Conviva custom live data processing stack. The other stream is stored into a Hadoop File System cluster. MapReduce jobs summarize this raw data and extract out the historical trending information shown in Pulse. The raw data written to HDFS, together with the summaries calculated by the MapReduce jobs, constitute the input to our Hive and Spark based offline reporting and ad-hoc analysis infrastructure, which is described next. Spark manipulate (filter and other operation) and group the data by video name and after with scala code it read from HDFS the data and executes the map-reduce job to produce the results (12). Spark shows is power when are issued multiple queries on the same data stored in caching, for example can be submitted subsequent queries to find the video counts per country, state and city in addition to the video name. 3.6.3 ClearStory ClearStory Data is a developer of data analytics software that brings next-generation Data Intelligence to everyone in order to accelerate the way businesses get answers across any number of data sources. It is specialized in data harmonization and helping users simplify data access to internal and external sources. ClearStory Data’s end-to-end solution includes an integrated platform and incredibly simple user application. It was one of Databricks first customers and choose Spark to figure out a way to help business users to merge their internal data sources with external sources without requiring complex data modeling, an example of data can be the data generated by social media traffic and public data feeds. The normal practice of union the data and correctly preparing it for analysis is quite difficult in real time. The company needed Spark for an in-memory engine that could interface with the Hadoop Distributed File System, when users upload data into the ClearStory service, it's stored on a Figure 3-23. ClearStory process include in-memory computation done by Spark
45 THE DATASET In this work are used two principals dataset. In the first part of my studies I used a littler dataset deriving by the World Cup 2014. This dataset consist in users of Instagram that share picture during the world cup and who used the tag “worldcup” and similar tags. At begin the data set was composed by 500 user images, of each pictures was download the relative JSON file, in this manner was possible to extrapolate all the tags used in the picture and other information. Unfortunately Instagram not release many information about the user, but analyzing the metadata, other information can be retrieved, such as the city, using the coordinates, the language, or the moment when the picture was published. In this case to tries the capabilities of Spark all the 500 images and all the 500 json files, were stored in two Hadoop Sequence File, this was obtained with a shell script that initially generate a tarball of the files, obtained the tarball file it can be manipulated with a java program to generate a Hadoop sequence file 6 . To work with HSF spark offers simple APIs that allow to read, write and manipulate them. When a HSF is read in Spark, it created immediately and RDD to store all the information about the data, we already sew, that in a RDD are not stored the data, but only the step to obtain the data. Applying to an RDD a map function, obtained from HSF reading, is possible to work directly with each file, in fact every “line” contains a file, in our case a json file or an image. This dataset was used principally to deal with Hadoop Sequence File and to understand how to integrate this type of file in Apache Spark. Also was used to start with the basic APIs of spark and to try simple function of MLlib and Spark SQL. Finished to work with Hadoop sequence file part, another dataset was used, because in this new process is necessary a greater set of data. In the second part the dataset is composed by two different typologies. The first typology, positive type, was taken a group of users that belong to a certain group of Instagram, we can call them group A. The second typology, negative type, contains users that should not belong to the first group, so we can suppose that this group B, is equal to a ‘not A’. In order to obtain the first group ‘A’ were selected some tags belonging to the group of interest, and after were taken the users that uses these tags. In this way was created a database of the users that follow a given topic and for each one were downloaded image and relative metadata that they shared. Instead, create a negative data sample was a tortuous process, in fact is impossible a priori to said that a user not belong to a group, a given user can not follow a topic, in the present, but he can become a follower and maturate interest in this topic in the future. So, the negative 6 For a complete guide see http://personals.ac.upc.edu/rtous/howto_spark_opencv.xhtml
46 data sample was created catching that in the present not belong to group A, users were selected changing some characteristics, such as city, following and used tags. In order to understand how the database is composed, the similarities and diversities of two samples, are shown some statistics. First, the characteristics of the final database are shown in the following table: Number of ‘positive’ users 1.073 Number of ‘negative’ users 3.694 Total numbers of tags data sample 1.827.097 Total numbers of tags of ‘positive’ data sample 22.7254 Total numbers of tags of ‘negative’ data sample 1.599.843 Total different tags in database 176.057 Table 4-1. Summary of database characteristic In the Figure 4-1 is represented two histograms of the most used tags in each data sample, the first one is negative, and the second one the positive. Is possible to see that some tags are common for both data sample, for this reason we cannot ensure that all the element of negative data sample B not belong instead to positive data sample A.
47 ALGORITHMS 0 2000 4000 6000 8000 10000 12000 14000 N° repetition tag Most used tags negative data sample 0 500 1000 1500 2000 2500 3000 3500 N° repetition tag Most used tags positive data sample Figure 4-1. Most used tags
48 In this section will be explained the methods used to convert and normalize the data and the algorithms used to create the followers classifiers. The first step to obtain a compatible input is to extract from a set of files the relevant data. From all the files were taken the tag field, which contains a vector of words used to comment the relate picture, and were stored in a single file. The position of each picture also was taken and converted and merged in the tag vector. So, with this method were created the two data sample file, positive and negative. The files contain a json objects, one for each follower, the structure of one json object is shown in the Figure 4-2. When the files are obtained, three method to convert json data to numeric values usable from machine learning algorithms. 4.3.1 TF-IDF Term frequency-inverse document frequency (TF-IDF) is used in information retrieval and it is a feature vectorization method widely used in text mining useful to calculate the frequency of terms in a document and to correct the value based on the importance of a term in a document. Formally, giving a term t, a document by d, and the collection of document denoted by D we can said that: “Term Frequency TF(t,d) is the number of times that term t appears in document d, while Document Frequency DF(t,D) is the number of documents that contains term t” 7 . A correction factor is adopted because the only use of term frequency can easily to over-estimate the importance of some terms that appear more frequently than others words but giving less information about the document, for example some terms that fall in this category are “a”, “the”, and “of”. The idea that introduce this correction is that if a term is repeated many times in a collection of document, is probable that not bring relevant information for the document. So, the inverse document frequency is a numerical measure of how much information a term provides: 𝐼𝐷𝐹(𝑡,𝐷)=𝑙𝑜𝑔|𝐷|+1𝐷𝐹(𝑡,𝐷)+1 where |D| is number of document present in the collection. The TF-IDF measure is simply the product of TF and IDF: 7 https://spark.apache.org/docs/1.2.0/mllib-feature-extraction.html Figure 4-2. Example of one JSON object store in the file data sample
49 𝑇𝐹𝐼𝐷𝐹(𝑡,𝑑,𝐷)=𝑇𝐹(𝑡,𝑑)⋅𝐼𝐷𝐹(𝑡,𝐷) For an example of TF-IDF we can consider a document containing 1000 words wherein the term ‘car’ appears 4 times. Is simple to calculate the term frequency for ‘car’, in fact it is (4 / 1000) = 0.004. Now, assume we have a collection of 100 million documents and the term cat appears in one thousands of these, so we can calculate the inverse document frequency as log(100,000,000 / 1,000) = 40. The final measure as we said before, is simply the product of both, so the TFIDF: 0.004 * 40 = 0.16. In my project the TF-IDF was apply to the both data sample and each one give as result a RDD of vectors, one for each user. Inside a vector is stored the result of TFIDF for the relate user in form of float number. 4.3.2 Feature Hashing and bigrams Talking about text classification, we can introduce some concepts, the first is the ‘Unigrams’ that is considered a set of single words, the second, most important in our case, is ‘Bigrams’ that introduce the concept of relation between two words which appear next to each other in the text, and finally the ‘Trigram’ that it is just the next extension of that concept. Bigrams are commonly used for statistical analysis of text in many applications, then can be useful for a classification algorithm, in fact it tends to really improve performance helping the classifier to determine which class has a higher probability for a better classifications. A definition of bigram could be “2-gram is a contiguous sequence of 2 items from a given sequence of text or speech. The items can be phonemes, syllables, letters, words or base pairs according to the application”. If we consider a bigram which has a letter as single item, we can calculate that the total possible pairs constructible in a natural language, depurate the string from special characters, are 262 = 676. In this work to implement the calculation of bigram frequency was used the Hashing Trick, or formally ‘Feature hashing’. It is a fast way to featurize a vector useful to preserve sparsity and introduces no additional overhead to store projection matrices. The concept is very simple, to each element, in this case a bigram, is applied a hash function, and the hash values obtained is used as indices directly, rather than looking the indices up in an associative array. In Scala the hashing trick could implemented in easy way, to each data sample is applied a map function that takes the tags vectors and then apply the function to convert the tags in bigrams, after with all the bigrams is create an array with hashing trick to count the occurrences and finally the frequency. We can take as example the sentences below and see the example in the Table 4-2:
50 “The sun is in the sky” Bigram Hash Value/Index HASH MAP Index Count Frequency th 5 1 1 0.1 he 6 2 1 0.1 su 4 3 1 0.1 un 1 4 1 0.1 is 3 5 2 0.2 sk 2 6 2 0.2 ky 7 7 1 0.2 in 8 8 1 0.1 Tot 10 1.0 Table 4-2. Example of bigram and hashing trick combination 4.3.3 Counting Frequency Another algorithm used for compute the frequency of the tags is a simple frequency calculator. It can be seen as a TF-IDF without the value document frequency as correction factor. The purpose to use this simple algorithm is based on the idea that in a document compose of only tags, is more difficult to find useless term, in fact thinking about the use of picture and tags that a user do. Supposing the no presence of irrelevant terms (e.g. ‘the’, ‘of’...), that in the tags are not often used, apply the TF-IDF can negative influence relevant tags. Analyzing for example the Figure 4-1, the most used terms are not particle words and they seem to carry important information to the text. To avoid a collision problem and to under-estimate the size of a hash map, due to a big dictionary generated by the huge variety of tags, were used two array, the first one is create to associate a tag with a corresponding index as value, from 0 to number of different tags, and the second for the count, where the index is get by the first array, that contains the total number of times that a single tag appear in the data sample. A clarification is given by the example below. Using the series of tags “summer sky summer sun sun sky sun sky sky summer” We can create the following arrays: Tag Index Index Count
51 First Array summer 3 Second Array 1 3 sun 1 2 3 sky 2 3 4 Table 4-3. Creation example of counting arrays These algorithms are used to extract the information from a data sample, commonly this technique are part of information retrieval (IR) processes. These technique are used to obtaining information resources relevant to an information need from a collection of information resources. The relevant information are used in our case as input to create and training the classifier model. In order to train the model were used three principal algorithms that will be explained in the following section. The first two algorithms are part of binary classification method, instead the third is multiclass classification algorithm. Knowing that our goal is to find a model to predict if a user can belong, or in this case follow, a group or a brand, so immediately we can understand the need to use a binary classification in fact these types of algorithms have the scope to divide items into two categories: positive and negative, follower or not follower, in the group or out of the group. Actually in MLlib are implemented two principal linear methods for binary classification: linear Support Vector Machines (SVMs) and logistic regression. These algorithms need an RDD of LabeledPoint as input. A LabelPoint is a simple vector, of floating point, with a label put at begin, a training label could be denoted as either +1 (positive) or −1 (negative). 4.3.4 SVM – Support Vector Machine SVM is a relatively new type of learning algorithm, introduced by Vapnik and Corinna Cortes in 1993 and published in 1995. The idea is to take a set of training examples, in our case the two data sample, negative and positive, and with an SVM training algorithm builds a model that can predict for a new entry one category or the other. An SVM model is represented by a hyper-plane that divides set of points in space, in order to improve the classification the separate categories are divided by a clear gap wide as possible. The SVM can construct one or a set of hyperplanes 1 to infinite-dimensional space, which can be used for classification. Larger is the distance from the hyperplane to the nearest training data point of any class better is the quality of the model created. This distance is called functional margin, so larger Figure 4-3. Example of hyperplane that separate points in two different categories
52 is the margin, and lower is the generalization error of the classifier. Formally, given some training data set D, a set of n points of the form: 𝐷 ={(𝑥𝑖,𝑦𝑖)| 𝑥𝑖 ∈ 𝑅𝑝,𝑦𝑖 ∈{ −1,1} }𝑖=1 𝑛 where the point 𝑥𝑖 belong to the class 𝑦𝑖 that could be either 1 or −1; 𝑥𝑖 is a vector belong to a p-dimensional space. The scope is to figure out the maximum-margin hyperplane that can divide the points having 𝑦𝑖=1 from those that have 𝑦𝑖= −1. The definition of a hyperplan is: {𝑥𝑖∙ 𝑤− 𝑏 ≥+1 𝑤ℎ𝑒𝑛 𝑦𝑖=+1 𝑥𝑖∙ 𝑤−𝑏 ≤+1 𝑤ℎ𝑒𝑛 𝑦𝑖=−1 From this equation is possible to calculate the two hyperplanes 𝐻1 and𝐻2, the SVM algorithm tries to maximize the distance between them, so the problem is basically a maximization problem that can be resolve with linear methods. MLlib include APIs to training the model with the SVM algorithm, but only for linear hyperplans, in fact SVM can also work with nonlinear classification, using for example polynomial equations. With MLlib the SVM model is trained using a part of RDD of LabeledPoint as training set, all the calculus and communication between workers necessary to find the model in distributed system are done automatically by spark. 4.3.5 Logistic Regression The name logistic regression comes from the fact that the data curve is compressed by using a logistic transformation, to minimize the effect of extreme values. Logistic regression is used to model the relationship between a dependent and one or more independent variables and estimates the probability of an event occurring, in fact it wants to predict from a knowledge of relevant independent variables is not a precise numerical value of a dependent variable, but rather the probability that it is 1 event rather than 0 event. In others words it is used to predict a binary response from a binary predictor, basing the outcome of a categorical dependent variables, on one or more predictor variables. The term logistic regression is strictly used to refer to problems in which the dependent variable is binary, instead the problem has more categories the model is referred to multinomial logistic regression or ordered logistic regression. Logistic regression treats the same set of problems a using similar techniques, the first assumes a logistic function and the second a standard normal distribution function.
53 Logistic regression can be seen as a special case of generalized linear model and thus analogous to linear regression. In this algorithm, the result predict by the model is usually coded as "0" or "1", true or false, and in our case follower or not follower. Essentially what it does is to create a model that “draws a line” through the data, and says if this data point falls on one side, assign it a label 0, or if it falls on the other side of the line, give it a label 1. In Logistic Regression the effect of each input on the output is measured, and the various inputs are weighted in the finished model, for do this it is necessary that logistic regression use a logistic function to create continues criterion, formally in logistic regression, the dependent variable is in fact a logit, which is a log of odds, that has the formula: 𝑙𝑜𝑔𝑖𝑡(𝑃)=ln ( 𝑃 1−𝑃) Where P is the probability of a “1” event and it is equal to: 𝑃 = 𝑒𝛼+𝛽𝑥 1 + 𝑒𝛼+𝛽𝑥 α and β are the parameters of the model. In MLlib, as SVM, the input format expected in the Logistic Regression algorithm implementation in Spark is a LabeledPoint array, in which the first element is the class, that could be 0 or 1, and all elements after the first elements are the features, which must a float datatype. 4.3.6 Naive Bayes Naive Bayes is different from the previous algorithms because is a multiclass classification algorithm and is necessary to assume the independence between every pair of features. The peculiarity of Naïve Bayes is that is very efficiently to train and it also give a high quality prediction. It is simple technique, or better a family of algorithms, used in our case to construct a classifiers. This group of algorithms is based on common principle: The value of a particular feature is independent of the value of any other feature Each of the features is considered to contribute independently to the probability of one category Figure 4-4. Graph of the logistic function
54 Some of these algorithms belonging to naive Bayes classifiers can be trained very efficiently in a supervised learning setting, to improve the quality of the classifier can be chosen different parameter estimation, for example in MLlib is possible to modify the s ‘additive smoothing’ 8 parameter λ. Naive Bayes has the advantage that is enough a small amount of training data to estimate the parameters necessary for classification, and despite this and its design it works well in many complex real-world situations and can often outperform more sophisticated classification methods. Formally (16), given a set of variables𝑋 ={𝑥1,𝑥2,𝑥...,𝑥𝑑}, the algorithm aims to construct the posterior probability for the event 𝐶𝑗 among a set of possible outcomes 𝐶 = {𝑐1,𝑐2,𝑐...,𝑐𝑑}, so X is the predictors and C is the set of categorical levels present in the dependent variable. The Bayes’ rule claims that 𝑝(𝐶𝑗 |𝑥1,𝑥2,𝑥...,𝑥𝑑)∝ 𝑝(𝑥1,𝑥2,𝑥...,𝑥𝑑 |𝐶𝑗)𝑝(𝐶𝑗) Where 𝑝(𝐶𝑗 |𝑥1,𝑥2,𝑥...,𝑥𝑑)the probability that X is belongs to 𝐶𝑗, but assuming the independency of the variables and using the conditional probabilities we can obtain: 𝑝( 𝑋 | 𝐶𝑗)∝ 𝑝(𝐶𝑗)∏𝑝(𝑥𝑘|𝐶𝑗) 𝑑 𝑘=1 Using this formula we can label a new case X with a class level 𝐶𝑗. 9 Like the previous algorithm also here, Naïve Bayes takes an RDD of LabeledPoint to create a model which can be used for evaluation and prediction. In this work the Naïve Bayes, even if is a multiclass classifier, is used as a binary classification, so the model predict only if a new income belongs a positive or negative category. 8 For mor information http://en.wikipedia.org/wiki/Lidstone_smoothing 9 An example with explanation could be find at http://sebastianraschka.com/Articles/2014_naive_bayes_1.html Figure 4-5. Binary classification with Naive Bayes, the two categories created and the decision boundary is shown in red
61 lightly loaded. It maintains full control over the jobs, including the ability to suspend and resume the jobs based on load conditions. Furthermore, it allows to transparently run and use software that is not available on your local host and it help to manage the easily the access and the control of the resources such as: who can submit jobs and which hosts they can use how many jobs specific users or user groups can run simultaneously time windows during which each host can run load shared jobs load conditions under which specific hosts can accept jobs or have to suspend some jobs resource limits for jobs submitted to specific queues 5.1.2.3 Run a job To LSF provides a resource management framework that takes your job requirements, finds the best resources to run the job, and monitors its progress, the jobs submitted behave just like jobs run on the local host. Even jobs with complicated terminal controls behave transparently to the user as if they were run locally and in according to host load and site policies Job in a LSF is a program or command that is submitted to a queue for scheduling and execution in an LSF cluster. A job can be complex problems, simulation scenarios, and extensive calculations, anything that needs compute power. All LSF jobs run in queues, even interactive programs. A queue is associated with one or more servers, and has various limits defined, such as the number of jobs that can run on it at a given time and runtime limits for jobs that run on it. A job can be submitted from an LSF client or server with the bsub command, in this case is used the default queue as shown below: It is also possible to specify a different queue using instead the command ‘bsub -q name_queue’. Jobs are held in a queue waiting to be scheduled and have the PEND state. The job stands in the PEND state until all conditions for its execution are met, and all the resources that it needs are free. When the resources are free and the policies choose by the user are respected, the job is execute and enter in RUN state until the end. Normally, if not in contrast with some directives of the scheduler, when a job acquires the resources necessary bsub my_job Job <1234> is submitted to default queue <normal>
62 to start, no other jobs can have access to the same resource. This allow to run a job without interruption given by absence of resources. In MareNostrum are present different queues, is possible to see them and the relative facilities using the command ‘bsc_queues’. Each queue has some information to help the work of scheduler and dispatcher, the attributes associated are: Priority Name Queue limits (restrictions on hosts, number of jobs, users, groups, or processors) Standard UNIX and Linux limits: memory, swap, process, CPU Scheduling policies Administrators Run conditions Load-sharing threshold conditions When a job is submitted the LSF system uses built-in and configured resources to track resource availability and usage. Jobs are scheduled according to the resources available on individual hosts. To choose the best queue LSF considers the requirements of the job and automatically chooses a suitable queue from a list of candidate default queues according to: User access restriction Host restriction Queue status Job’s requested resources Exclusive execution restriction Jobs submitted through the LSF system will have the resources they use monitored while they are running. This information is used to enforce resource limits and load thresholds as well as fair share scheduling. Figure 5-5. Job lifecycle
63 LSF allows multiple scheduling policies in the same cluster based on the needs of each host. The common scheduling policies used also on MareNostrum are 11 : First-come, first-served (FCFS) scheduling Service level agreement (SLA) scheduling Fairshare scheduling Preemption Backfill SPARK AND MARENOSTRUM Spark in MareNostrum was implemented avoiding the use of a pre-implemented cluster manager, such as YARN. In our case was created an own cluster manager in order to simplify and automate the use of Spark over the IBM LSF Platform used in the BSC supercomputer. To reach a complete control of the Spark in the HPC cluster was created a special framework named Spark4MN that also allows a cooperation with other different cluster manager, the version of Spark in the cluster each part of it was compiled to make compatible with MareNostrum 64 bits, the principal component are Hadoop 2.6.0 and Spark 1.3.0, furthermore is used Java 1.8.0 u40 that not needs to be re-compiled. The framework is used to help a user to work in a cluster without knowing the real structure of the supercomputer, basically it is composed by different Bash scripts that provide a series of command to work with it. The implementation was done to make the framework modularized, so add a new distributed file systems (DFSs) will be easy. Spark4MN gives to the user the three principals commands to the developers to work with their applications work with Big Data: 1. spark4mn 2. spark4mn_benchmark 3. spark4mn_plot These three commands will be analyzed better in the section Error! Reference source not found.. Spark4MN take in charge to monitor the application before and during its execution, until the end, where are written a series of files to help the developers in the analysis of the results. 5.2.1 Setup Every time that an application is executed in the HPC cluster in MareNostrum is created a job that is managed by the framework. To run a job is necessary to create a dedicated configuration file in order to manage the resource needs by the application, so the user can 11 Please refer to glossary for the definition of the queues.
64 avoid to interact directly with Spark, indeed every action pass through spark4MN because it is designed to manage and work a supercomputer environment. When a job is executed through Spark4MN, when the part of the cluster configuration is end, the job enter in the proper queue until an exclusive number of cluster’s nodes are available for it. The execution has to follow several step, the first is to understand if a DFS cluster has to be set up, this is reach collection all the information given by the host. The second step is to initialize the system, so Spark4MN tries to balance the configuration distributing the hardware resources homogenous as possible and deciding how to split the nodes between the DFS and Spark. Calling M the number of nodes belonging to the DFS and N the number of nodes belonging to Spark and remembering that one node is always necessary for manage the job script submitted with Spark, four nodes distribution are possible (Figure 5-6): Exclusive mode Shared mode with M=N Shared mode with M<N Shared Mode with M>N a) Exclusive mode b) Shared mode with 𝑀 =𝑁 d) Shared mode with 𝑀 >𝑁 b) Shared mode with 𝑀 <𝑁 Figure 5-6. Nodes distribution mode
65 Finally, Spark4MN can distribute across the nodes previously configured the data and start the services required, also if a DFS is requested, its master service is executed and all the DFS worker services are launched and connected to the master while Spark4MN waits that the interconnection is ready. Now, the nodes configuration for DFS is finished and Spark4MN can execute the Spark configuration. This step is similar to DFS configuration, in fact the steps to follow are: start master, which corresponds to the standalone Spark manager, wait for master to be ready, and start workers, that are worker services. Spark4MN wait until the cluster is completely set up and ready and start to executed sequentially the user’s application via spark-submit, each application is submitted with one call of spark-submit. To improve the performance Spark4MN allows to use the output of one application as input of the next application, so it creates an application pipeline that can help users running related applications. When all the application submitted by the user are executed and completed, Spark4MN can turn off all the component associated with each job and create a gather all the metrics files in order the create one single metric file. 5.2.2 Commands The principal command provided by the framework is spark4mn; it is used to deploy all the Big Data cluster’s services, and to execute all the user’s applications. To use the command is enough to pass as argument one or more configuration files, the configuration files are read through a cycle and for each configuration file read, a job is submitted into the cluster putting it into a proper queue, in our case in the bsc queue. In addition to spark4mn command, the framework provides the command spark4mn_benchmark. This command can be used to run multiple jobs changing automatically the configuration file and monitoring during the execution each job. To allow the lunch of many jobs, spark4mn_benchamark is implement on the top of spark4mn, so when a user wants to run the same applications with different geometries, he has just to use one configuration file for spark4mn_benchamark that takes care to generated the correct configuration values and pass them to spark4mn. Like spark4mn, also spark4mn_benchmar offer to use more than one configuration file, this can be useful to run different applications, each one with different geometries. Moreover, spark4mn_benchamark provides at the end of all the jobs submitted a set of logs and metrics files that contain also important information about their application’s scalability. An interesting feature is the possible to set a ”restart” flag that can be used to complete a previous execution adding only the jobs with the missing geometries, this is reached looking at the already generated metric files and submitting the jobs missing. The last command provided by Spark4MN is spark4mn_plot that collects all the metrics files generated using spark4mn_benchamark command, calculates statistics about the application performance and writes them within gnuplot-compliant data files. 5.2.3 Configuration file and logs
66 The configuration file, shown in Figure 5-7, is composed by different settable parameters, only few parameters are mandatory, almost of them are optional and are used to instruct Spark4MN about the geometries and optional component. The main parameter to lunch a job is the domain program, and it has to be set writing the path of the JAR file of the program, plus an entry point, that is the class of the Java/Scala program that the user wants to submit. Other parameters are used to modify the geometries of the job, it is possible to set the number of nodes, the number of workers per node and the number of cores per worker, each one of these values, if not set, have a default value calculate by Spark4MN. In case that sum of the resources request is more than the cluster’s hardware the resource, a warning is raised by Spark4MN. It is possible also to change the network interface, this can be useful to test the behaviors of different cluster architectures, or to simulate an environment in which the DFS and Spark are in different networks. Another set of parameters established the characteristics of CPU affinity that will be applied to the worker services in order to change the pinning modes. The four possible options are: Core → this mode pin one worker per core, so if in the configuration file is set the parameter ”number of cores per worker” it is misleading. In order to decide how many threads or subprocesses they will be able spawn, Spark wants to know the number of CPUs. In fact is possible to use less physical cores than requested(#𝑐𝑜𝑟𝑒𝑠𝑤𝑜𝑟𝑘𝑒𝑟 ∗ #𝑤𝑜𝑟𝑘𝑒𝑟𝑠𝑛𝑜𝑑𝑒) if one chooses core pinning, because each worker has all its threads and subprocesses inside one single core. ### JOB PARAMETERS: ### JOB_NAME="[STRING]" WORKING_DIR="[PATH]" WALLCLOCK=[INT] # Minutes. NEAR_NODES="[BOOL]" DOMAIN_JAR_[[1-9]+]="[PATH]" DOMAIN_ENTRY_POINT_[[1-9]+]="[STRING]" [...] ### SPARK_PARAMETERS: ### # SPARK_VERSION="[STRING]" # SPARK_NNODES=[INT] # SPARK_NWORKERS_PER_NODE=[INT] # SPARK_NCORES_PER_WORKER=[INT] # SPARK_WORKER_MEM_SIZE=[INT] # MiB. # SPARK_WORKER_AFFINITY="[CORE | SOCKET | NODE | NONE]" # SPARK_NETWORK_INTERFACE="[IB | ETH]" ### DFS PARAMETERS: ### # DFS_MODULE="[HDFS | NONE]" # DFS_SHARE_NODES="[BOOL]" # DFS_NNODES=[INT] [...] Figure 5-7. Example of a job configuration file for spark4mn command
67 Socket → it assigns each worker to a socket, and the requested number of cores belongs to it; Node → the pinning is fixed, but a worker can have CPUs from more than one socket. The set of CPUs assigned to each worker, no matter the pinning mode, is calculated taking into account the workload balance; pinning to each socket, and core the same amount of workers (± 1); None binding → it is the kernel’s default scheduling. In the configuration file of spark4mn_benchamark are present all the parameters of the configuration file of spark4mn, but for many of them is possible to set a range of values that the user wants to use for his applications. As shown in the Figure 5-8 to set a range is enough to choose the start and end values, the operator and the step used to calculate the values inside the range. Setting these values benchmark program takes care to call a spark4mn program one per each value of the list of numbers calculated. The number of jobs submitted can increase dramatically if are set different parameters, in fact if we decide to create one range for the number of nodes (e.g. [16 32 64 128 256]), and for the number of worker (e.g. [1 2 4 8 16]), the program will submit all the possible combination of the values in the ranges (in this case will have 25 jobs). When a job ends, a set of logs files will be created; in case that spark4mn_benchamark is used will be generated one set of logs files per each job submitted. The principals files generated are: Metrics file → in this file are collected all the information about the time that the master and all workers related spent for the job; Domain file and workers files → here are saved the output (info, warnings and user output, errors) of the program generated by the master and the workers; Error file → in this file is stored the errors outputs generated by spark4mn program, so is possible to see if an error occur in the cluster during the set up or the execution of the program. In this file are not present error generated by the user application (e.g. errors due to logic of the program); Out file → here are stored different information about the job. The principals information are: a portion of code used to submit the job in the LSF (using bsub command), submission information (id_job, name_job, user, queue, directories), list # SPARK_START_NNODES=[INT] # SPARK_END_NNODES=[INT] # SPARK_NNODES_STEP_OPERATOR="[+ | *]" # SPARK_NNODES_STEP=[INT] Figure 5-8. Example for setting a range of value in spark4mn_benchmark configuration file
68 of worker used by the job and a summary of resource usage (CPU time, max memory, average memory, total requested memory, delta memory, max processes, max threads).
69 6. EVALUATION The late part of the development has seen a validation and performance testing phase of the model and the implementation in the MareNostrum. The first part will consist in the models quality evaluation, in this part will be explained the different algorithms used to estimate the correctness of the models and error. Moreover, will be shown the influence of different parameters configurable for each model. Subsequently is analyzed how Spark work in a real cluster, in this case in MareNostrum; to test phase in this case are done on the scalability of Spark, changing the number of nodes used. MODELS EVALUATION 6.1.1 Methodology The experiments are executed in a local machine, precisely in a virtual machine using Oracle VirtualBox. The operating system used is Xubuntu 14.04 LTS (64bit), for the VM is reserved a RAM of 4096 MB and 50GB of hard disk. To reach acceptable results the final values are obtained calculating the average of 10 experiments. The experiment is done splitting the dataset in two parts, one for the training of the model, and the other one for the testing. The split is done randomly using a floating number as seed at run time. For document classification, the input feature vectors are usually sparse, and sparse vectors should be supplied as input to take advantage of sparsity. 6.1.1.1 Parameters For each model can be considerate different parameters, that can be changed in order to obtain a better estimator. MLlib use an optimizer object to changing the values of the parameters, so each model has different values that can be used to improve the estimator. The binary classifiers, SVM and Logistic Regression, has an optimizer that allows us to change the following parameters: Number of iteration → is the maximum number of iteration that the algorithm has to do Regularization parameter → is fixed regularization parameter 𝜆≥0 and settable with regParam method. It is used to defines the trade-off between the two goals of minimizing the loss and minimizing model complexity
70 Updater → this regularization methods is to prevent overfitting by penalizing models with extreme parameter values. In this work are used three common variants: zero, L₁ and L₂ regularization 12 . Instead for Naïve Bayes is possible to modify only the parameter λ, that is the ‘additive smoothing’, a technique used to smooth categorical data, it is used to incorporate a smallsample correction, in all probability estimates such that no probability is ever set to be exactly zero. 6.1.1.2 Metrics The three principal models are evaluated with three metrics, the first one is the Mean Squared Error, after, the second one is the Accuracy and finally is calculated the confusion matrix. These three metrics are calculate for each model and for each parameters changed in the model. 6.1.1.2.1 Mean Squared Error The mean squared error in static is one of the most important criterion used to evaluate the performance of a model predictor or an estimator. It is useful to relay the concepts of bias and precision in statistical estimation. In statistic the mean squared error is frequently used to assess the risk of an estimator, that is, how large are on average the losses generated by the estimation errors committed when employing the estimator in question, in practice it measures the average of the squares of the "errors", that is, the difference between the estimator and what is estimated. Let 𝑋 be a vector of n predictions and 𝑋 the vector of true values, the formula to obtain the MSE is: MSE=1 n∑(𝑋𝑖 −𝑋𝑖)2 𝑛 𝑖=1 There is also another possible mathematical definition for the MSE that uses the concepts of targets and estimator, but is not relevant for our scope. As we can see, the MSE could be seen like the average of “distance” between the real value and the prediction of the value. Considering that in our case each point is represented by a vector of LabeledPoint (store in a RDD) the MSE is calculated the label of each vector, so if the value is correct estimated the ‘distance’ is 0 (label 0.0 prediction 0.0 and label 1.0 prediction 1.0), instead if the estimation is wrong, the ‘distance’ is equal to 1 (label 0.0 prediction 1.0 and label 1.0 prediction 0.0). Doing the average of these distance we can obtain our MSE with LabeledPoint vectors. 12 The regularizer values used in MLlib are in https://spark.apache.org/docs/1.2.0/mllib-linear- methods.html#regularizers
77 The input data sizes ranged anywhere from 500 MB to 250GB, depending on the benchmark. We did scaling tests for each of the benchmarks, going from 8 nodes to 128 nodes. The Figure 6-4 and Figure 6-5 show the performance of the three benchmarks with different input data sizes and different amount of nodes. Figure 6-4. Performance of Naive Bayes using 4 workers per node and different number of nodes Figure 6-5. Performance of K-means using 4 workers per node and different number of nodes
78 Figure 6-6 shows the performance of Naive Bayes with a fix number of nodes and with different number of worker per nodes. Each MareNostrum node has 16 cores, we performed experiments with different distribution of the workers within each node. The Error! Reference source not found., Figure 6-8 and Figure 6-9 show some possible distributions and related performance. The last analysis done is on the influence of the number of partitions and the correlation with the number of workers per node, result of the performance are collected in a histogram shows in the Figure 6-10. Figure 6-6. Performance of Naive Bayes using 4 nodes and different number of workers per node Figure 6-7. Performance with 2 cores per worker
79 Figure 6-8. Performance with 4 cores per worker Figure 6-9. Performance with 8 cores per worker
80 Figure 6-10. Histogram of performance using different partitions and number of workers per node
81 7. CONCLUSION AND FUTURE WORK The scope of this work three algorithms were implemented using Spark frameworks in order to create a classifier to predict if a user can belong to a certain group of followers, so the main goal of this thesis was to show that Spark framework is suitable for classification algorithms. The goal was fulfilled by implementing three different algorithms and showing quality of the classifiers. The three algorithms implemented were: Support Vector Machine, Logistic Regression and Naïve Bayes. Algorithms were tested using three different method to convert data into a RDDs containing the same data in a form usable by MLlib algorithms. The quality taken by each algorithm with different parameters was calculated with three metrics: MSE, accuracy, confusion matrix. The number of initials data tags are more than 1.800.000 divide in two data sample, negative and positive. For the first experiment each algorithm was tested with all the possible combination of the parameters settable. In the binary classifier the parameters taken into account are the number of iteration that the algorithm has to do, the regularization parameter and the regularization method, instead remembering that Naïve Bayes is a multiclass classifier, in this case is possible to set only the value of λ (additive smoothing). The results show that the best performance are reached with the binary classifiers SVM and Logistic Regression, instead the Naïve Bayes has worst performance probably due to its simplicity and the inability to change many parameters to improve the model. In the case of the two binary classifier the best results are obtained with the combination of the simple frequency counter, low value of regularization parameter and 𝐿2 as regularization method. TF-IDF can be worse than the counting frequency because introduce a correction factor in the calculus of the frequency, and in tags case the correction value can hide due importance to relevant tags, only for the massive use of them. Usually 𝐿₁ regularization is preferred performs feature selection within the learning algorithm producing sparse models, but in this case 𝐿2 works better because 𝐿1 can be not differentiable for these algorithms. Finally, the regularization parameter has not theoretical value, but it is can be found trough experiments, in our case we discovered that for algorithms a RP lower than 0.5 improve the overall quality of the models. Regarding the number or iteration we can said that each algorithms with its parameters has unknowable value a priori, but each algorithm has to be tested with different number of iteration values in order to create a good classifier. All the three models created can be used to have a good prediction of a user, also Naïve Bayes, that has the worst performance, can predict if a user can belong to a followers group with less of 30% of error. The second scope we reached in this thesis, to explore the feasibility and convenience of deploying a state-of-the-art instantiation of the emerging Apache Spark over a real-world, petascale, HPC setup. The deployed Apache Spark 1.3.0 was successfully done the MareNostrum supercomputer. To work with MareNostrum, we have designed and developed a Spark4MN framework in order to automate the usage of Spark over an IBM LSF-based environment and the hardware particularities of MareNostrum. Spark4MN has proven to be convenient tool for running Spark-based applications on an HPC setup and is being currently used at BSC for executing Big Data workloads. The framework is also
82 extremely useful for benchmarking the Spark deployment, providing tools to run multiple instance of the same application with different configuration for each job. In order to test Spark4MN framework a data input were generated in a range with sizes from 100.000 to 400.000. Different tests were done changing the number of nodes, the number of workers per node and, the number of cores per worker and at the end also the number of partitions. Three algorithms were used to test Spark: sort-by-key, K-means and Naïve Bayes. Beginning with the difference of the algorithms, we can see that the faster is Naïve Bayes, in fact as we said before it also is the simplest of the three algorithms. It is used to the performance tests of Spark in order to obtain the time spent to run the algorithm with different cluster configurations. The first parameter changed is the number of nodes used in the cluster, from 4 to 32. We can see that in this case that increase the participants node Spark need less computation time, this is visible mostly increasing the data size, bigger is the data size, and better is the scalability. Instead changing only the number of worker per node we can see that in initially the performance not improving, but changing also the number of total nodes used in the cluster, the overall performance increase and the computation time considerably decrease. The others tests are centered to find this equilibrium point exploring different distribution of the cores. All the results shows that in the all the possible distribution, the time spent is the same, so the distribution of the cores not affect the computation time. Finally, we tested the influence of the number of partitions, this parameter can be changed trough the configuration file or also during running time. To explore the relevance of this parameters were taken into account different combination changing the number of workers per node. Results show that the number of partitions is crucial to improve the performance, we can see a big difference between the use of 100 and 1.000 partitions, and in fact this parameter said how to cut the dataset in the cluster to create a parallel collections. RDD is the key of Spark, and is based of concept of distributing and parallelize the work, knowing that Spark will run one task for each partition of the cluster, and that each RDD is divided in different partitions, we can understand how this number can strongly influence the performance. FUTURE WORK To improve the classifiers we are working on a better pre-process algorithm in order to normalize the data and take off the possible outliers’ users or tags. The pre-processing consist in the find a possible correlation among the tags, so to fold a group of tags in only one word. Another improvement in working is to use OpenCV framework (available in Scala and Java) to manipulate the images, in order to extract some important information, such as writes, brands, faces and objects. These information can be added to the data sample in form of tags, in this way all the pictures can be used to enrich the details of each user and to create a more fitting profile. The project is MareNostrum is still on going, the test using the cluster are trying to figure out the impact of storage (GPFS vs. HDFS) and the impact of network. A further feature of Spark4MN will be the extension of the framework to work with other workload managers,
83 with the addition of new job headers that state all the job’s configuration. The addition of other distributed file systems like Apache HBase, or Apache Cassandra is also possible, because each DFS is packed as a code module. We also plan to port Spark4MN to a compiled language (C++) to improve its efficiency. Using Spark4MN, MareNostrum, OpenCV and the classifiers will be possible to do create a stream application cl of the meta-data and pictures and so obtaining a real-time classifiers to analyze the big data generated by Instagram traffic.
84 REFERENCES 1. Cox, Michael and Ellsworth, David. Application-controlled demand paging for out-of- core visualization. Los Alamitos, CA, USA : IEEE Computer Society Press Los Alamitos, CA, USA, 1997. 2. Bryan, Randal E., Katz, Randy H. and Lazowska, Edward D. Big-Data Computing: Creating revolutionary breakthroughs in commerce, science, and society. California : In Computing Research Initiatives for the 21st Century, Computing Research Association, 2008. 3. Stoica, Ion. Spark and Hadoop: Working Together. [Online] Databricks, January 21, 2014. https://databricks.com/blog/2014/01/21/spark-and-hadoop.html. 4. Sort FAQ. [Online] http://sortbenchmark.org/FAQ-2014.htm. 5. Nyberg, Chris and Shah, Mehul. Sort Benchmark Home Page . [Online] http://sortbenchmark.org/. 6. Xin, Reynold. Spark the fastest open source engine for sorting a petabyte . [Online] Databricks Inc., October 10, 2014 . http://databricks.com/blog/2014/10/10/spark-petabyte- sort.html. 7. Zaharia, Mate. Resilient distributed datasets: A fault-tolerant abstraction for in-memory cluster computing. University of California. Berkeley : Proceedings of the 9th USENIX conference on Networked Systems Design and Implementation, 2012. p. 14. 8. Wang, Yandong, et al. Characterization and optimization of memory-resident mapreduce on HPC systems. s.l. : IEEE 28th International Parallel & Distributed Processing Symposium, 2014. 9. Hubregtsen, Thomas Samuel. Evaluation of different storage systems for Apache Spark and Apache Hadoop. s.l. : TU Delft, Delft University of Technology, 2015. 10. Agarwal, Sameer, et al. BlinkDB: queries with bounded errors and bounded response times on very large data. s.l. : Proceedings of the 8th ACM European Conference on Computer Systems. ACM., 2013. 11. Feng, Andy. Spark and Hadoop at Yahoo: Brought to you by YARN. s.l. : Yahoo!, 2013. 12. Joseph, Dilip. Using Spark and Hive to process BigData at Conviva. [Online] Conviva, 2011. http://www.conviva.com/using-spark-and-hive-to-process-bigdata-at-conviva/. 13. Mulligan, Sharmila. How an early bet on Apache Spark paid off big. [Online] ClearStory Data, 2015. http://venturebeat.com/2015/03/18/why-we-bet-the-farm-on-apache-spark/. 14. Dean, Wampler and Payne, Alex. Programming Scala: Scalability = Functional Programming + Objects. s.l. : O'Reilly Media, Inc., 2009. 15. SBT. [Online] Typesafe Inc., 2015. http://www.scala-sbt.org. 16. Raschka, Sebastian. Naive Bayes and Text Classification I. 2014.
85 17. About Bsc - History. [Online] Barcelona Supercomputing Center, 2015. http://www.bsc.es/about-bsc/history. 18. MareNostrum. [Online] Barcelona Supercomputing Center, 2015. http://www.bsc.es/marenostrum-support-services. 19. Marenostrum System Architecture. [Online] Barcelona Supercomputing Center, 2015. http://www.bsc.es/marenostrum-support-services/marenostrum-system-architecture. 20. Compute Racks. [Online] Barcelona Supercomputing Center, 2015. http://www.bsc.es/marenostrum-support-services/marenostrum-system- architecture/compute-racks. 21. Schmuck, Frank and Haskin, Roger. GPFS: A Shared-Disk File System for Large Computing Clusters . San Jose, CA : IBM Almaden Research Center, 2002. 22. IBM. IBM Platform LSF Documentation. [Online] IBM Corporation, 2013. http://www.bsc.es/support/LSF/9.1.2/. 23. Dean, Jeffrey and Ghemawat, Sanjay. MapReduce: Simplied Data Processing on Large Clusters. San Francisco, CA : Google, Inc., December, 2004. 24. Qi, Chen, Liu, Cheng and Xiao, Zhen. Improving mapreduce performance using smart speculative execution strategy. Beijing : IEEE, 2013.