Spark memory management

MemoryManager is the place where I started looking at spark’s memory management architecture. This class handles the split of the overall memory into four dynamic portions — onHeapStorage, onHeapExecution, offHeapStorage, offHeapExecution. Execution memory is transient (shuffle, join, aggregates, sorting) and storage memory is longer lived (cache, broadcast variables). MemoryManager depends on MemoryStore to actually allocate and free memory. There are two kinds of MemoryManagers — StaticMemoryManager and UnifiedMemoryManager. Unified allows execution and storage to borrow memory from each other while Static does not allow this. ...

December 10, 2016 · 1 min · Bharath

Spark - QueryExecution

Today I am going to talk about the QueryExecution class in Spark. This class takes care of providing fine grained access to different stages of running a SparkSQL query. Basically the parsing, analysis, optimization and physical planning are all accessible via this class. It also handles inserting extra operations like extracting python UDFs, inserting shuffle stages, internal row format conversions etc. IncrementalExecution is a derived class which allows the same query to be run repeatedly in an incremental fashion, with possible state save in between executions. This is used in Structured Streaming. It is also used to allow users to run their own optimization strategies which is very cool.

November 20, 2016 · 1 min · Bharath

Trying out spark streaming

I am playing with simple examples of spark streaming here and here. The flexibility of creating any number of separate dstreams, and calling updateStateByKey on any dstream is really nice. Here is a link to configure logging in a standalone spark program.

April 1, 2014 · 1 min · Bharath

Running Apache Spark examples

Apache Spark has a good set of examples to play with. But I could not figure out how to rerun the test by recompiling only that test. An entire sbt/sbt assembly will take ages and will preclude understanding modified examples within this lifetime. So a shorter route was necessary. The obvious sbt/sbt compile org.apache.spark.streaming.examples failed. Digging into the (slow as in molasses) output of sbt/sbt help showed sbt/sbt project to set the current project. Sidenote: Leaving a JVM running could not hurt the speed of sbt’s startup. End of Sidenote. Trying to set the current project to examples did not succeed. Wading through several error messages which mentioned ‘/’ as a special character did not help. ...

March 28, 2014 · 2 min · Bharath

Apache spark use cases

Here is a list of possible use cases for Apache spark. Mining logs for interesting patterns Text search (also web search)

March 26, 2014 · 1 min · Bharath

Big data processing toy example - Part 2

This is the second part of the blog series on big data processing. This will focus on doing some simple processing on a large dataset stored in HDFS. I have 300000 random integers stored in HDFS as a single shard in /user/hduser/random4 directory. val rdd4 = sc.hadoopFile("hdfs://vagrant-ubuntu-precise-64/user/hduser/random4") rdd4.partitions.size ###Problems encountered: The above snippet throws an exception: java.lang.RuntimeException: java.lang.InstantiationException at org.apache.hadoop.util.ReflectionUtils.newInstance (ReflectionUtils.java:115) at org.apache.spark.rdd.HadoopRDD.getInputFormat (HadoopRDD.scala:141) at org.apache.spark.rdd.HadoopRDD.getPartitions (HadoopRDD.scala:154) Checking the api reference for hadoopFile shows that some more arguments might be needed. Switching to sc.textFile solved the problem. ...

March 25, 2014 · 3 min · Bharath

Big data processing toy example - Part 1

This is the first part of the blog series on big data processing. This will focus on generating a large dataset. The idea is to generate a large dataset in a distributed way and write it to HDFS. Below is scala-spark snippet to generate lots of random integers and store them on HDFS. import util.Random val rdd = sc.parallelize(Seq.fill(100)(Random.nextInt)) rdd.saveAsTextFile("hdfs://vagrant-ubuntu-precise-64/user/hduser/random") ###Problems encountered The hostname was not really matching and spark-shell was throwing an EOFException. ...

March 25, 2014 · 3 min · Bharath

Mental map of big data software

I was trying to create a mental map of the various big-data software solutions. My first attempt is below. . Since there are close connections to virtualization solutions and cloud computing solutions, I have added those also into the map. It is possible there are mistakes in the map and I need to update it as I learn more. Also played around with HDFS using this tutorial.

March 24, 2014 · 1 min · Bharath

Keeping track of what is happening in Apache Spark

I am trying to follow what is happening in Apache Spark. Things that need to be done: Subscribe to user@spark.apache.org Subscribe to dev@spark.apache.org Follow github notifications for spark. PRs, comments, commits etc are all sent as notifications. Create an account on Apache Spark Jira. But I did not find any way to get email notifications for activity on JIRA. So following the RSS feed of the activity stream. I am also going through this summary presentation.

March 24, 2014 · 1 min · Bharath

Basic usage of Apache Spark

Played around with Apache Spark today. Ran the spark-shell and did some text processing as shown in the quickstart documentation. I tried to run the examples but that fails complaining that the examples are not built. Trying to run sbt/sbt assembly again but there is a SSL certificate error on repo.maven.apache.org – there is a domain mismatch (hmm…). Curl complains that the security chain is invalid. I tried out the master-slave mode of running spark. Feels really cool counting 119 lines of a small text file using 3 workers and taking 2-3 seconds :)

March 23, 2014 · 1 min · Bharath