BLERG Notes on 732

Revisions to draft assignment

  1. Revise questions to be numbered 1–4?
  2. Clarify that in Section 3-a questions, refer to both local cluster and EMR (which will turn out to have proportional values).

This line added just to test reloading. Another line.

Answers to questions

Section 2:

Stage 0, unfiltered (weather-1 dataset):

Total Time Across All Tasks: 10 s Input Size / Records: 2.6 MB / 293571 Output: 27.2 KB / 3245

Stage 0, filtered by S3 (weather-1 dataset): Total Time Across All Tasks: 7 s Input Size / Records: 97.7 KB / 3245 Output: 27.2 KB / 3245

(a) Ratio:

Filtered count: 97.7 KB Original file: 2600.0 KB Ratio: 3.7%

96.3% of the original file was filtered out by S3 (alternatively, students could say that 3.7% passed the filter)

(b) For the unfiltered version, 293,571 records were read but only 3,245 were written. For the filtered version, 3,245 records were read. The filtered records read in totalled 97.7 KB, while the records written were only 27.2 KB.

In the filtered condition, S3 filtered the records to exactly the stations needed for the result, while the Spark code reduced the data for each record.

Section 3:

(a) According to the Spark job history page, here are the times for reddit-5 on 4 m6gd.xlarge instances:

Job 0 (read data): 1.2 min Job 1 (compute): 6 s Job 2 (compute): 7 s Job 3 (write data): 1.2 min

This application is obviously IO-bound.

(b) reddit-5 is 8.5 GiB in 16 partitions and the application is IO-bound. Therefore the run time will scale roughly linearly with input size for the same number of cores. Total time for reddit-5 is 2.9 minutes, so an input dataset 10 times as large would take about 30 minutes. Four instances @ $0.1808 / hr for one half hour is $0.3616.

Note: There are additional costs for EMR: Instance surcharges for running EMR, charges for EBS volumes, and S3 charges. This computation is simply indicative of how cheap EMR is, not a total cost estimate.

With 4 instances, we have 16 cores, matching the number of partitions. If we wanted to speed up the computation by using 16 instances (= 64 cores), we would need at least 64 partitions of the input dataset.

Notes from first days, running on SFU cluster

So. Many. Messages. Not much dev experience.

My directory, HDFS directories.

Isn’t there a command that’s simpler than hdfs dfs ...? Something like dfs ...?

Argh! Dies because directory already exists. No idempotency????

Prefixing subcommands with - (as in -ls) is insane. Oh, and I have to break out each single-char option, as in hdfs dfs -su -s -h, rather than combining them, as in hdfs dfs -su -sh.

Converting to AWS

Where shall we store the data?

Shall we run EC2 instances or EKS Nodes or EKS / Fargate?

All. These. Options.

First try: Cluster with 1 Main node, one Core node, simple C4.large instances.

Question 1: Where are the instances?

Question 2: Where does the input come from?

Question 3: Where should the output go?

Some notes

  1. Refresh often! Can be hard to know what parts of the display are updated and what parts are not.

  2. Many, many application interfaces.

  3. Many, many logs!

  4. The top line of a cluster, indicating state, is live (updated as state changes) but the lower portions have to be refreshed to see the changes.

  5. --conf spark.yarn.maxAppAttempts=1 --conf spark.dynamicAllocation.enabled=false

Time running with one executor and one core on SFU cluster on 8-shard reddit-5:

real	28m32.430s
user	0m33.315s
sys	0m2.608s

Time running with four executors, each one-core, on SFU cluster on 16-shard reddit-5

real	5m23.635s
user	0m26.188s
sys	0m2.193s

SFU cluster on 16-shard reddit-5 with 4 executors, each with 4 cores:

real	2m13.822s
user	0m21.117s
sys	0m1.472s

Locating error from lack of output file

  1. Select Application user interfaces tab

  2. At bottom, below header High-level application history

  3. Click “refresh” (Clockwise circle)

  4. Click on link in Application ID column (the one with Status displayed as Failed)

  5. Select Executors tab

  6. In the drivers row, click View logs. It will be replaced with stderr | stdout.

  7. Click on stdout

Commands

spark-submit --deploy-mode cluster --conf spark.yarn.maxAppAttempts=1 s3://cmpt-732-files/relative_score_runtime_err_end.py s3://cmpt-732-files/reddit-1/ s3://cmpt-732-files/output/reddit-1-rt_err3
select * from pg_catalog.stl_load_errors order by starttime desc limit 2;
-- Insufficient permissions???
select userid, query, slice, segment, rows, bytes from pg_catalog.svcs_query_report order by start_time desc limit 3;
-- Maybe not the one I wanted?
select query, seg, step, rows, bytes, rate_row, rate_byte from pg_catalog.svl_query_summary order by query desc limit 10;
SELECT
    external_table_name,
	s3_scanned_rows,
	s3_scanned_bytes,
	s3query_returned_bytes,
	avg_request_parallelism,
	max_request_parallelism,
	avg_request_duration,
	max_request_duration
  FROM pg_catalog.svl_s3query_summary
  ORDER BY starttime DESC
  LIMIT 1;

Value proposition

Benefits of using Amazon EMR

The positives

The positives seem to be all operational:

  1. Can scale up to very large pools without owning all the hardware.

  2. Security via IAM and security groups (firewalls), as well as other AWS features (VPC).

  3. AWS manages the Hadoop software, updating it for you.

  4. Integration with S3, a data lake.

  5. Maybe its fault-tolerance for broken worker nodes? Or is that also in regular Apache Hadoop?

  6. Run computations on EKS-managed nodes, sharing computational capacity.

  7. Under EKS, run on Fargate, not thinking about servers.

  8. Integration with other AWS services, in particular:
    • Lake Formation
    • Data Pipeline
    • Cloud Trail for audit trails
  9. Centralized management of a shared cluster (especially with EMR Studio).

The negatives

  1. Very hard to get logs from driver.

UI Oddnesses (for G & G)

  1. Top half of cluster page is updated from Starting to Running to Waiting at startup but not updated when a step is started.
  2. Sometimes Spark History Never shows a job as completed, even though the EMR Step tabe shows it as completed.
  3. When a cluster is terminated, the Spark History will no longer work. However, if you click on the Spark History link again (from the cluster Summary tab), you will get a persistent history of all Spark jobs on that cluster.
  4. The resource lists appear to be eventually (in)consistent. In both the list of Instance Groups (Hardware tab) and the list of YARN Applications (Application user interfaces tab) I have seen the lists “lose” an item that was already there. The only way to regain that item on the list was to go back to the list of clusters (click on Clusters in the sidebar), select the cluster, and return to the appropriate tab. The “lost” item will now reappear. Mystery!

  5. It appears that you can set a CloudWatch Billing Alert on your root AWS account but not an IAM account. Or maybe my IAM account just needs more privilege. In any case, I think this approach is now deprecated. In the exercise, I walk students through the currently-recommended approach, setting a Budget Alert. This can definitely be done from an IAM account.

    I’m just telling you this because you, like me, might have one of the old CloudWatch Billing Alerts set and wonder why you can’t find it under Budget Alerts.

  6. Redshift EDITOR pane: Drops database connection when shifted to another pane.

  7. Redshift external tables with struct cannot use SELECT * nor can it simply use the name of the STRUCT column but must instead specify the full path of any requested fields in the struct.

  8. If you have a SELECT * live on the Redshift query editor when Select schema is set to an external schema, and the FROM matches one or more table names in the external schema (even without the schema name as a prefix), you will periodically get a red SELECT * not permitted on nested tables message at the top of the query page. This is because the query editor occasionally ships the current query to Redshift.