CMPT 732 AWS Revision: Week 1 Report

Week 1 Executive Summary

Learning Outcomes: The primary learning outcomes of the first Amazon EMR assignment (circa Assignment 5) should be:

  1. Students will have confidence that the tools and techniques they have learned to date in CMPT 732 are directly transferrable to cloud computing environments.
  2. Students will have basic competency running Spark jobs on EMR.

Unfortunately, the following learning outcomes can NOT be achieved in this first assignment:

  1. Students will learn a technique on EMR that is superior to what they could do with Apache Hadoop on the SFU cluster.
  2. Students will understand the value proposition of EMR over an on-premise cluster.

Technology: The SFU cluster has significant pedagogical advantages over EMR.

First EMR assignment: It will be a challenge to make this assignment interesting rather than a slog.

Administrative: I do not yet have a contract. I find the internal support tools used for managing RA applications frustrating. Despite my best efforts, I remain only half-convinced that I have done what I needed to do and Vanessa Liu is not waiting for me to send something more. The status emails sent by the tracking system are utterly confusing.

Details

The following sections justify these conclusions. I included a lot of detail that might be useful in adding material to 732 or at least informing the instructor’s perspective on EMR and cloud services more generally. If you’re short of time, the most important section is titled, “The nightmare of diagnosing syntax and top-level runtime errors”.

The EMR experience is ungainly and frustrating

When learning a new technology, after getting beyond the inevitable quirks of setup and learning my first simple application, I typically have a “Wow! That’s cool” moment. That has not yet happened with EMR. To some degree, this is a testimony to the design of the Hadoop components, which have provided me such moments in the past. Amazon EMR is merely Hadoop, supplemented with modest integration into other AWS services.

Integrating Hadoop with AWS ultimately makes Hadoop more cumbersome to use than running it on a dedicated cluster, because a cloud service requires stronger, deeper, and more varied security mechanisms and because interfacing it with other services increases the number of options and size of documentation. As a consequence, students are faced with a more complicated “Hello Spark” configuration and a welter of unfamiliar concepts. This will be especially difficult for students without prior experience of AWS.

EMR simplifies datacentre operations

Amazon has put effort into enhancing EMR but that effort was not directed towards extending its functionality. My take-away from this week:

The value proposition of Amazon EMR is operational, not computational.

Specifically, EMR offers the standard value proposition of a cloud service over an on-prem service:

These benefits are real but none of them is exciting to a technical audience and none of them is visibly demonstrated by an exercise. They are best presented in a declarative format such as a lecture or reading and best learned in an analytic format such as writing.

For completeness, I point out that I found a brief reference to a performance improvement in the EMR Spark runtime made by the EMR team in 2019:

EMR Spark runtime

They don’t describe their changes nor do they say whether these changes have been made available upstream to open-source Spark. The improvements may be specific to the underlying AWS stack, in which case there would be litte point to pushing them upstream.

As an Apache Spark port, EMR also features standard Spark optimization options.

EMR’s one cool feature remains a cost control measure

At the last minute, I did find one EMR feature that struck me as cool. At the intersection of algorithm and pricing, it ultimately is a cost control measure.

Using Spot instances in EMR

AWS Spot instances, EC2 virtual machines, trade low price for reduced availability. Spot instances may not always be available at the specified price and can even be removed from your application after they were assigned to it. This latter case can be exploited under the Hadoop architecture: So long as a node is purely computational and not an HDFS node (in EMR terms, a “Task node”), it can be gracefully removed from a running cluster and Hadoop (perhaps working with YARN?) can reschedule the node’s assigned tasks to other nodes. Hadoop’s fault tolerance makes it well-suited to assigning nodes to Spot instances, reducing cost without risking job failure if a Spot instance is de-assigned.

Although this is a cool consequence of the Hadoop (and YARN?) algorithms, it produces an operational benefit of reduced cost, not an increase in functionality.

The nightmare of diagnosing syntax and top-level runtime errors

Amazon’s EMR documentation touts the system’s debuggability:

This is likely correct, from the perspective of debugging subtle problems that arise in high-volume runs, such as a defective worker node or input data that is slightly the wrong format. Unfortunately, I found it much more awkward to diagnose the most basic errors, the ones that students are most likely to make: errors of syntax or top-level semantics (simulated by writing assert False at points in the main routine).

I want to emphasize that it took me hours to determine that my first Spark run was failing for that most mundane of Sparkly (Hadooply? HDFSly?) reasons, namely that my specified output file already existed.

The problem is not the lack of logs but their surfeit. So. Many. Logs. None of which tell you that you had a syntax error or simple, top-level runtime error. Compounding the confusion, the one log that provides that information only becomes available several minutes after the step has failed. Getting that log, once you know it exists, requires a seven-step quest through dim passageways of dialogue tabs and links.

Did I mention that on occasion, for no reason I could discern*, the relevant page will simply clear the list of links taking you to that log, requiring you to press refresh to restore them?

Note that there are many places where EMR indicates that a step failed. The hard part is determining the reason for that failure.

Yeah, not a great developer experience.

I may be missing something simpler and easier but to repeat, I spent hours on this problem and this is the only solution I found.

* Speculated cause: The EMR page is querying an underlying YARN server. When that server has a state update, it posts a “clear” message to the EMR page. This has the debilitating outcome that the list is cleared exactly when the user is watching to see if the dispositive error log has become available.

EMR Studio addresses controlled sharing more than usability

When I heard of EMR Studio, an IDE frontend for EMR based upon Jupyter notebooks, I thought it might provide some needed sizzle. But in order to use it, you must first reconfigure your account to use Single-Sign-On and then define an AWS Organization that potential Studio users can join. This seemed like too much work and might configure my account in ways that limited my other future uses, so I never tried Studio. The documentation suggests its main purpose is providing a more straightforward way to control access to the underlying cluster, using for example Microsoft Active Directory.

EMR also supports EMR Notebooks, a legacy approach of connecting Jupyter notebooks to a cluster. They recommend that new applications use EMR Studio, presumably due to its superior access control.

Given that 732 students do not learn notebooks (covered in 733?), they won’t see the benefits of EMR Studio or Notebooks. Furthermore, I suspect this is simply Amazon’s branding of Apache tools that could be run on SFU’s cluster.

Structure and learning outcomes of first EMR assignment

Given the challenge of locating syntax errors, the first EMR exercise will have to begin by having students insert a syntax error in their code and walking them in detail through the steps to find the error message. Not a spectacularly fun introduction to EMR but necessary for them to progress in any future step.

Beyond that essential skill, what learning outcomes should we aim for in the first CMPT 732 assignment on EMR? Given that EMR addresses operational benefits rather than computational, I don’t see any “wow” factors that we can present to the student in their initial exercise. Instead, the assignment becomes a sort of reassurance that their investment in the Master’s program is protected:

The assignment should likely comprise running some solutions to earlier assignments on EMR and seeing that they work unchanged. Unfortunately, this isn’t very exciting, especially given the effort required to set an account and start a new cluster. We will need to think of ways to make it interesting without requiring learning yet more AWS services—suggestions encouraged.

EMR can be expensive even for small clusters

The small cluster proposed by the tutorial (1 control, 2 workers, all c4.2xlarge) cost me $6 USD for three hours. Most of this was the instance cost, with about $1 USD surcharge for EMR. My attempt to configure a smaller cluster, featuring 1 control and 1 worker of the much cheaper c4.large instances, failed to bootstrap, presumably because the instances were too small. I haven’t searched for the lowest-cost cluster that I can run small examples upon.

Benefits of SFU cluster

Taking all the above into account, I’ve come to see the benefits of students running their assignments on the SFU cluster: Simpler security, simpler environment, cost already factored into their tuition.

Running EMR on EKS (managed Kubernetes)

EMR can be run on Amazon’s managed Kubernetes service, EKS. The benefits of this are entirely operational, allowing a single pool of Kubernetes worker nodes to perform EMR runs in addition to their other workloads. If the EKS service in turn uses Fargate for its serverless pool of container executors, the Hadoop runs can be made without specifying any server instances at all.

I believe that using EMR on EKS requires Hadoop 3, packaged in EMR 6. Note that the current default EMR release is 5. You have to request EMR 6 explicitly.

Looking ahead to a possible second EMR assignment

What might we do for a second, final EMR assignment? The most likely approach would be some assignment that ties together multiple AWS services with a Spark pipeline. For example, the students might analyze simulated click stream data from AWS Kinesis and place the results in DynamoDB. The learning outcome from such an assignment might be to gain skill in building big data tools in a context closer to actual use and seeing the benefits of Spark when integrated in a larger cloud environment.

The challenge of such an assignment will be minimizing the configuration and administration of the source and sink AWS services, focussing the students’ attention on the Big Data principles and overall architecture.