Tuesday, April 18, 2017

Overview of Apache Spark

Big Data processing is often performed using Google’s MapReduce framework (Liu, Iftikhar, & Xie, 2014). In the MapReduce pattern, the only way to share data between operations is to write it to a distributed filesystem (M. Zaharia et al., 2012).  This introduces significant overhead and can account for more than 90% of the execution time when performing machine learning algorithms in Hadoop, an open source implementation of MapReduce.  To facilitate efficient multi-pass and interactive query execution, Zaharia et al. created Spark.
Spark utilizes the concept of discretized streams (D-Streams) to facilitate the sharing of information between iterations and operations (M. Zaharia et al., 2013).  D-Stream essentially enables micro-batch processing of data.  These micro-batches are created every few seconds.  More precisely, the order of magnitude of the duration of the time window used to create the batch is typically measured in seconds.  They are deterministic in nature and enable parallel recovery when a failure occurs.  They also address the challenge of slow nodes, termed stragglers, which are often treated as a failure condition.  D-Streams are manifested through the use of Resilient Distributed Datasets (RDDs).  An RDD contains data, and a lineage graph showing how that data was constructed.   These RDDs are stored to disk via an occasional check-pointing system but primarily reside in memory. This approach enables parallel recovery when a node is lost or is slow delivering results. 
Because of Spark’s in-memory computation, compared to disk-based for Hadoop, it is between 40 and 80 times faster than Hadoop (M. A. Zaharia, 2013).  One logistic regression algorithm was 100 times faster in Spark than Hadoop MapReduce (Díaz, Martín, & Rubio, 2016).  It is important to note that while RDDs are typically stored in memory if the data is too large Spark will persist them to disk.  When a spillover event occurs, the performance degrades to something comparable that delivered by Hadoop MapReduce.
Spark is complementary to Hadoop.  It can read and write data to any storage system that Hadoop supports (M. Zaharia et al., 2012).  Spark’s processing paradigm is similar to Hadoop (Casado & Younas, 2015).   It contains transformations such as map, filter, and group by (M. Zaharia et al., 2012). The output of a transformation can be returned as a result, or used to construct an RDD. It also serves as a foundation for additional functionality, such as Spark Streaming (Liu et al., 2014), the Apache Spark Machine Learning Library (MLlib) (Meng et al., 2016) , SQL queries (Armbrust et al., 2015), and GraphX (Shoro & Soomro, 2015).  Stream processing is one area that can elucidate the characteristics of Spark.
Spark supports a unified processing architecture that is well suited to both batch and stream processing (M. A. Zaharia, 2013).  Spark Streaming creates a series of RDDs from a stream over a specific window of time (Díaz et al., 2016).  The collection of RDDs (a D-Stream) is processed using the same constructs in stream and batch processing.  Because of this uniformity, a solution that requires both a streaming and batch processing model is well suited to Spark.
Traditional stream processing systems utilize a continuous operator model (M. Zaharia et al., 2013).  This model relies on stateful operators receiving records, updating their state, and sending new records.  For this model to provide high-availability, it must rely on replication or upstream backup.  Replication doubles the cost of hardware while the upstream backup approach requires all other nodes to wait while a recovering node processes a replay of all messages before failure. Distributed processing systems also encounter situations where one node is functioning, but processing slower than other nodes.  This straggler use case is treated as a failure in traditional stream processing system.
In contrast, Spark Streaming utilizes a D-Streams approach, relying on RDDs for recovery.  When a failure occurs, a node’s data can be reconstructed using disk-based snapshots and the data lineage information contained within the RDDs.  This processing can occur in parallel, across the entire cluster of nodes (M. Zaharia et al., 2013).  This parallelism allows for fast recovery during failure and partial computation of an RDDs data when a node is slow completing processing.
Spark and Spark Streaming are good solutions for situations where latency is measured in seconds, not milliseconds (M. Zaharia et al., 2013).  Other streaming technology should be used if sub-second response is required.  Spark and Spark Streaming APIs are available for  Java, Scala, and Python (Anonymous, 2016).
Spark offers a high-performance alternative to Hadoop MapReduce.  It leverages the existing Hadoop stack to provide an alternative for jobs that require multiple passes or interactive queries.  Spark is a relatively new arrival to the Big Data space but is already gaining popularity (Xin, Armbrust, & Zaharia, 2016).  The latest revision includes performance improvements that improve its benchmarks by 10%.  It is an ideal solution where both stream and batch processing is required, or multi-pass MapReduce has previously been employed.

References
Anonymous. (2016). Apache Spark FAQ.   Retrieved from http://spark.apache.org/faq.html
Armbrust, M., Xin, R. S., Lian, C., Huai, Y., Liu, D., Bradley, J. K., . . . Zaharia, M. (2015). Spark SQL: Relational Data Processing in Spark. Paper presented at the Proceedings of the 2015 ACM SIGMOD International Conference on Management of Data, Melbourne, Victoria, Australia.
Casado, R., & Younas, M. (2015). Emerging trends and technologies in big data processing. Concurrency and Computation: Practice and Experience, 27(8), 2078-2091.
Díaz, M., Martín, C., & Rubio, B. (2016). State-of-the-art, challenges, and open issues in the integration of Internet of Things and cloud computing. Journal of Network and Computer Applications. doi:http://dx.doi.org/10.1016/j.jnca.2016.01.010
Liu, X., Iftikhar, N., & Xie, X. (2014). Survey of real-time processing systems for Big Data. Paper presented at the Proceedings of the 18th International Database Engineering & Applications Symposium.
Meng, X., Bradley, J., Yuvaz, B., Sparks, E., Venkataraman, S., Liu, D., . . . Owen, S. (2016). Mllib: Machine learning in apache spark. JMLR, 17(34), 1-7.
Shoro, A. G., & Soomro, T. R. (2015). Big data analysis: Apache spark perspective. Global Journal of Computer Science and Technology, 15(1).
Xin, R., Armbrust, M., & Zaharia, M. (2016). Introducing Apache Spark 2.0.  Retrieved from https://databricks.com/blog/2016/07/26/introducing-apache-spark-2-0.html
Zaharia, M., Chowdhury, M., Das, T., Dave, A., Ma, J., Mccauley, M., . . . Stoica, I. (2012). Fast and interactive analytics over Hadoop data with Spark. USENIX Login, 37(4), 45-51.
Zaharia, M., Das, T., Li, H., Hunter, T., Shenker, S., & Stoica, I. (2013). Discretized streams: fault-tolerant streaming computation at scale. Paper presented at the Proceedings of the Twenty-Fourth ACM Symposium on Operating Systems Principles, Farminton, Pennsylvania.
Zaharia, M. A. (2013). An architecture for fast and general data processing on large clusters. (3616767 Ph.D.), University of California, Berkeley, Ann Arbor. Retrieved from http://search.proquest.com.proxy.cecybrary.com/docview/1527163897?accountid=26967 ProQuest Dissertations & Theses Global database.

Stream Processing Systems

Distributed stream processing is a form of Big Data Analytics where a large volume of heterogeneous data is processed in a continuous fashion (Pospiech & Felden, 2013).  The typical stream processing solution is presented in Figure 1.  Data is produced by distributed devices and inserted into a message queue, via a gateway, for processing by a collection of streaming applications (Kamburugamuve & Fox, 2016).  The message queue is utilized as a means of buffering the input, enabling distributed processing, allowing fault tolerance, and increasing scalability. The gateway’s purpose is to provide a thin layer of abstraction, accepting messages in various protocols and inserting their payload into a queue for processing.  They are utilized in a way that is similar to the way that a load-balancer in a traditional web application is utilized.
The processing logic of a stream application can be represented as a graph composed of nodes, which represent streaming operations, and edges representing data flow (Kamburugamuve, Ekanayake, Pathirage, & Fox, 2016).  A logical user defined graph is created explicitly using an application program interface (API) or implicitly using a programming construct, such as Scala, Java, or a variant of SQL.  A component in a stream processing system converts the logical graph into an execution graph which can be scheduled for the execution of the application. The execution graph is then distributed to a set of worker nodes tasked with its execution.  The specifics of each of these steps varies by streaming system, but most share this approach.  Figure 2 shows a graphical representation of the logical graph and its conversion to an execution graph.
Two popular open source stream processing systems are Apache Storm (Apache Software Foundation, n.d.-a) and Apache Spark Streaming (Apache Software Foundation, n.d.-b).  A commercial, closed source, solution is Azure Steam Analytics (Stokes, 2016b). 
Apache Storm is one of the older distributed stream processing systems (Wang, 2016). It was created and released as open source by Twitter.  Storm is a continuously running streaming solution.  It processes data contained in tuples as they arrive.  Developers create logical graphs explicitly via the Storm API (Kamburugamuve & Fox, 2016).  In hosted environments, the cost of Apache Storm execution is based on the time cluster is running, as such, it does not support consumption based pricing (Stokes, 2016a). Deployment and operational monitoring are also at a cluster level.
Apache Spark Streaming takes a different approach to stream processing.  Rather than executing long-running jobs it utilizes a small batch approach (Zaharia, 2013).  Since Spark Streaming utilizes Spark’s Resilient Distributed Datasets (RDDs), it can provide high availability without replication.  This reduces the number of nodes within a cluster by approximately half, greatly reducing cost.  Spark is a near real-time processing system (Morshed, Rana, & Milrad, 2016). Since it uses a micro-batch approach, the developer can trade increased latency for better performance (Chintapalli et al., 2016) by decreasing the frequency of micro-batch creation.  A streaming application’s logical graph is created an API using a language such as Scala.  Deployment and monitoring for Spark Streaming are essentially the same as for Storm. 
Azure Stream Analytics (ASA) is a real-time stream processing system (Stokes, 2016b).  Logical graphs are created implicitly using an SQL-like language.  ASA natively supports temporal processing, such as time-based joins.  This distinction is the result of ASA being a complex event processing implementation (Chen, 2016). Temporal processing is possible in Spark and Storm, but the developer must implement the desired functionality.  ASA is a consumption priced managed service (Stokes, 2016a).  This means that the cost of a hosted ASA application is based on the amount of data processed, not the amount of time it is executing. Since ASA is delivered as a managed service, deployment and monitoring are at an ASA application level.  ASA is based on Trill, a Microsoft Research Project (Chandramouli et al., 2014).  Trill was benchmarked higher than Storm and Spark.  This implies that Stream Analytics likely delivers similar performance.
ASA and Storm are real-time processing systems, while Spark Streaming is near real-time.  This should be taken into consideration for solutions requiring low latency.  Development for Spark and Storm is done at a lower-level than for ASA.  ASA relies on an SQL-like language which is familiar and accessible to many.  Storm and Spark are open source while ASA is a proprietary system.  The choice between the streaming solution is not a simple one.  The choice will likely be made based on other factors, such as a pre-existing cluster or the skillset of the developers tasked with the solution creation. The most likely driver for the decision will be the ecosphere in which the solution is to execute.



References
Apache Software Foundation. (n.d.-a). Apache Storm.   Retrieved from http://storm.apache.org/
Apache Software Foundation. (n.d.-b). Spark Streaming: Apache Spark.   Retrieved from http://spark.apache.org/streaming/
Chandramouli, B., Goldstein, J., Barnett, M., DeLine, R., Fisher, D., Platt, J. C., . . . Wernsing, J. (2014). Trill: A high-performance incremental query processor for diverse analytics. Proceedings of the VLDB Endowment, 8(4), 401-412.
Chen, Z. (2016). Spark Streaming and Azure Stream Analytics.  Retrieved from https://blogs.msdn.microsoft.com/streamanalytics/2016/06/16/spark-streaming-and-azure-stream-analytics/
Chintapalli, S., Dagit, D., Evans, B., Farivar, R., Graves, T., Holderbaugh, M., . . . Poulosky, P. (2016, 23-27 May 2016). Benchmarking streaming computation engines: Storm, Flink and Spark Streaming. Paper presented at the 2016 IEEE International Parallel and Distributed Processing Symposium Workshops (IPDPSW).
Kamburugamuve, S., Ekanayake, S., Pathirage, M., & Fox, G. (2016). Towards High Performance Processing of Streaming Data in Large Data Centers. Paper presented at the HPBDC 2016 IEEE International Workshop on High-Performance Big Data Computing in conjunction with The 30th IEEE International Parallel and Distributed Processing Symposium (IPDPS 2016), Chicago, Illinois USA, Friday.
Kamburugamuve, S., & Fox, G. (2016). Survey of distributed stream processing. Retrieved from
Morshed, S. J., Rana, J., & Milrad, M. (2016, 23-27 May 2016). Open source initiatives and frameworks addressing distributed real-time data analytics.Paper presented at the 2016 IEEE International Parallel and Distributed Processing Symposium Workshops (IPDPSW).
Pospiech, M., & Felden, C. (2013, 3-5 Dec. 2013). A descriptive Big Data model using Grounded Theory. Paper presented at the Computational Science and Engineering (CSE), 2013 IEEE 16th International Conference on.
Stokes, J. (2016a). Help choosing a streaming analytics platform: Apache Storm comparison to Azure Stream Analytics.   Retrieved from https://azure.microsoft.com/en-us/documentation/articles/stream-analytics-comparison-storm/
Stokes, J. (2016b). What is Stream Analytics?   Retrieved from https://azure.microsoft.com/en-us/documentation/articles/stream-analytics-introduction/
Wang, Y. (2016). Stream Processing Systems Benchmark: StreamBench.
Zaharia, M. A. (2013). An architecture for fast and general data processing on large clusters. (3616767 Ph.D.), University of California, Berkeley, Ann Arbor. Retrieved from http://search.proquest.com.proxy.cecybrary.com/docview/1527163897?accountid=26967 ProQuest Dissertations & Theses Global database.

Monday, April 17, 2017

Futurist

As the blog says, my name is Alan Dennis.  I am a published author (Dennis, 2002), an Analytics Architect at Avanade, and a doctoral student at Colorado Technical University pursuing a doctorate in Computer Science with a concentration in Big Data Analytics.  The resurrection of this blog is inspired by an assignment in a doctoral class I am taking this quarter (Futuring and Innovation).  Futuring and Innovation (CS 875) is intended to provide students with the tools to become (or at least understand) futuring, and an introduction to the methods associated with innovation. The idea is that the students will utilize analytical skills to examine the current environment, previous trends, and attempt to make predictions about the shape of the future.

This blog was created about 12 years ago when I published the first post.  Since then a great deal has happened in both my personal life and in the computer industry.  I will attempt to be more diligent and disciplined with future posts.  Of course, that is always my intent.  This blog is my attempt to share the things I learn, those things I am passionate about, and my experiences along this journey of life.  Sometimes, I am a bit stingy and not great at sharing.  I will do my best.



References
Dennis, A. L. (2002). . Net Multithreading: Manning Publications Co.


AI and Human Lives

An interesting research topic is the role that artificial intelligence (AI) will play in human lives in the future. Maurice Conti views the future relationship between AI and humans to be collaborative in nature (Conti, 2016). In an engaging presentation, he discussed the transition from humans creating tools that are applied directly to a problem to a generative approach where computers will create solutions to meet human requirements independently.

There are several forces enabling, and perhaps propelling, this vision. Computer hardware has become a commodity. The advent of consumption based pricing and distributed processing combined with improvements in neural network architecture (deep learning) are enabling systems to be more intelligent that previously possible. The barriers to adoption of the vision include the immaturity of sensing and connectivity of the sensor. Conti discusses a project where a sports car was augmented with dozens of sensors and driven in extreme ways for a week. The resulting four billion data points were then analyzed using an AI to generatively design an auto chassis. As sensors are routinely placed in everyday things and a system of gathering and surfacing that data is developed additional innovations will become possible. However, end users of these systems will need to consent to their data being gathered and analyzed to realize such a vision. This trend relates to a recent purchase decision.

Craftsman is now including Bluetooth connected sensors in their riding lawnmowers (Sears, n.d.). When paired with a smartphone, the mower reminds the user to perform maintenance or perform a repair. While a very simplistic example, it does serve as a data point for the general trend. A more mature example is the OnStar product (OnStar, n.d.). Vehicles equipped with the technology upload diagnostic information used in the generation of monthly reports. For example, the report includes information about tire pressure, oil life, and any sensors indicating failures. One can only assume that OnStar and General Motors utilize the information for additional information, such as driving habits and maintenance practices. The fact that the vehicles are equipped with location detection equipment and two-way communication makes the vehicle as much a data capturing platform as a form of transportation.

Conti presented a positive and compelling view of the future. Viewing intelligent machines as something to augment, rather than replace, is a compelling message. However, public perception and fear may hamper the adoption of true autonomous design and construction.

References
 Conti, M. (Producer). (2016). The incredible inventions of intuitive AI. Retrieved from https://www.ted.com/talks/maurice_conti_the_incredible_inventions_of_intuitive_ai
OnStar. (n.d.). Vehicle Manager. Retrieved from https://www.onstar.com/us/en/services/vehiclemanager.html Sears. (n.d.). Craftsman Pro Series 46" 24 HP V-Twin Kohler Hydrostatic TurnTight Extreme® Riding Mower w/ Smart Lawn
Bluetooth Technology. Retrieved from http://www.sears.com/craftsman-pro-series-46inch-24-hp-v-twin/p-07127042000P

Thursday, April 13, 2017

Voice Data

Voice data is a form of unstructured data. It is often captured by call centers for both training and personnel supervision reasons.   One interesting characteristic of Big Data is that it often realizes high value on previously captured data.  Call center voice recordings is an example of this pattern.

Mattersight is a developer of personality-based call center applications (Bertolucci, 2015).  They developed a Big Data solution that utilizes the vast amount of voice data that is captured during customer calls to call centers.  The data is analyzed to determine personality characteristics of both the caller and the representative.  The idea is to match the caller to an appropriate representative to minimize the chances that the customer will become irate or the call will lead to an escalation.  Mattersight’s product is used by CVS Pharmacy and Esurance.  Wesbecher, Mattersight’s chief marketing officer, says there are a quarter of a billion calls every day between consumers and American brands.  

This is similar to an approach that Southwest Airlines is taking with their call center data (Erevelles, Fukawa, & Swayne, 2016).  Southwest utilizes a speech analytics tool to examine conversations between customers and representatives to gain insights into customer behavior and to improve customer service.  Southwest utilizes this data to identify unrecognized consumer needs.  They utilize Aspect, a competitor of Mattersight, to calculate real-time key performance index (KPI) dashboards (van Rijmenam, 2017).  These metrics guide representatives towards better customer service.

Most large organizations support their customers with a call center.  It is an opportunity to apply Big Data techniques to gain new insights.  Once the recordings are converted to text, additional forms of analytics can be performed.  We are seeing an emerging trend towards considering the psychological makeup of both the caller and the customer service representative.  It is not so difficult to imagine a display guiding future customer service representatives through a call in real time, warning when they are saying something that might upset the customer or lead to an undesirable outcome.  Eventually, we may remove the humans from this conversation and have one autonomous intelligent agent communicating with another, until then, “please hold for the next available agent.”

References

Bertolucci, J. (2015). Big Data: Matching Personalities In The Call Center. InformationWeek.

Erevelles, S., Fukawa, N., & Swayne, L. (2016). Big Data consumer analytics and the transformation of marketing. Journal of Business Research, 69(2), 897-904.

van Rijmenam, M. (2017). Southwest Airlines uses Big Data to deliver excellent customer service.   Retrieved from https://datafloq.com/read/southwest-airlines-uses-big-data-deliver-excellent/371


Friday, July 01, 2005

Streaming PDF using iTextSharp and ASP.NET

I've been looking at iTextSharp and iTextDotNet for a while now and I must say I'm very impressed with both.

One thing you may want to do if you're doing dynamic PDF generation is stream a PDF back from an ASP.NET page. The following simple example shows the basic elements using iTextSharp v3.0.3.


using iText = iTextSharp.text;
....

Response.Clear();
Response.ContentType = "application/pdf";
System.IO.MemoryStream m = new System.IO.MemoryStream();
iText.Document document = new iText.Document();
iText.pdf.PdfWriter writer = iText.pdf.PdfWriter.GetInstance(document, m);
document.Open();

document.Add(new iText.Paragraph(DateTime.Now.ToString()));
document.NewPage();
document.Add(new iText.Paragraph("Hello World"));
document.Close();

writer.Flush();
Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.End();