Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Nosql East October 2009

1,356 views

Published on

My Cascading Presentation from NoSQL East presentation in Atlanta 10/30/2009

Published in: Technology, Education
  • Be the first to comment

Nosql East October 2009

  1. 1. Hadoop and Cascading<br />Christopher Curtin<br />
  2. 2. About Me<br />19+ years in Technology<br />Background in Factory Automation, Warehouse Management and Food Safety system development before Silverpop<br />CTO of Silverpop<br />Silverpop is the world’s only provider of both email marketing and marketing automation solutions specifically tailored to the unique needs of B2C and B2B marketers.<br />
  3. 3. NOSQL<br />SQL/RDBMS have their place<br />Lots of things we couldn’t do without one<br />However …<br />
  4. 4. Not all data is a nail!<br />
  5. 5. To quote Don Brown (@tensigma)<br />“pig makes easy things really easy. cascading makes the hard stuff possible”<br />
  6. 6. What is Map/Reduce?<br />Pioneered by Google<br />Parallel processing of large data sets across many computers<br />Highly fault tolerant<br />Splits work into two steps<br />Map<br />Reduce<br />
  7. 7. Map<br />Identifies what is in the input that you want to process<br />Can be simple: occurrence of a word<br />Can be difficult: evaluate each row and toss those older than 90 days or from IP Range 192.168.1.*<br />Output is a list of name/value pairs<br />Name and value do not have to be primitives<br />
  8. 8. Reduce<br />Takes the name/value pairs from the Map step and does something useful with them<br />Map/Reduce Framework determines which Reduce instance to call for which Map values so a Reduce only ‘sees’ one set of ‘Name’ values<br />Output is the ‘answer’ to the question<br />Example: bytes streamed by IP address from Apache logs<br />
  9. 9. Hadoop<br />Apache’s Map/Reduce framework<br />Apache License<br />Yahoo! Uses a version and they release their enhancements back to the community<br />
  10. 10. Runtime Distribution © Concurrent 2009<br />
  11. 11. Getting Started with Map/Reduce<br />First challenge: real examples<br />Second challenge: when to map and when to reduce?<br />Third challenge: what if I need more than one of each? How to coordinate?<br />Fourth challenge: non-trivial business logic<br />
  12. 12. Cascading<br />Open Source<br />Puts a wrapper on top of Hadoop<br />And so much more …<br />
  13. 13. Main Concepts<br />Tuple<br />Operations<br />Pipes<br />Flows<br />
  14. 14. Tuple<br />A single ‘row’ of data being processed<br />Each column is named<br />Can access data by name or position<br />
  15. 15. Operations<br />Define what to do on the data<br />“Relational”-like operations (Can I say that here?)<br />Each – for each “tuple” in data do this to it<br />Group – similar to a ‘group by’ in SQL<br />CoGroup – joins of tuple streams together<br />Every – for every key in the Group or CoGroup do this<br />
  16. 16. Operations - advanced<br />Each operations allow logic on the tuple, such a parsing dates, creating new attributes etc.<br />Every operations allow you to iterate over the ‘group’ of tuples to do non-trivial operations.<br />Both allow multiple operations in same function, so no nested function calls!<br />
  17. 17. Pipes<br />Pipes tie Operations together<br />Pipes can be thought of as ‘tuple streams’<br />Pipes can be split, allowing parallel execution of Operations<br />
  18. 18. Example Operation<br />RowAggregator aggr = new RowAggregator(row);<br />Fields groupBy = new Fields(MetricColumnDefinition.RECIPIENT_ID_NAME);<br />Pipe formatPipe = new Each(&quot;reformat_“ new Fields(&quot;line&quot;), a_sentFile);<br />formatPipe = new GroupBy(formatPipe, groupBy);<br />formatPipe = new Every(formatPipe, Fields.ALL, aggr);<br />
  19. 19. Flows<br />Flows are reusable combinations of Taps, Pipes and Operations<br />Allows you to build library of functions <br />Flows are where the Cascading scheduler comes into play<br />
  20. 20. Cascading Scheduler<br />Once the Flows and Cascades are defined, looks for dependencies<br />When executed, tells Hadoop what Map, Reduce or Shuffle steps to take based on what Operations were used<br />Knows what can be executed in parallel<br />Knows when a step completes what other steps can execute<br />
  21. 21. Dynamic Flow Creation<br />Flows can be created at run time based on inputs.<br />5 input files one week, 10 the next, Java code creates 10 Flows instead of 5<br />Group and Every don’t care how many input Pipes<br />
  22. 22. Dynamic Tuple Definition<br />Each operations on input Taps can parse text lines into different Fields<br />So one source may have 5 inputs, another 10<br />Each operations can used meta data to know how to parse<br />Can write Each operations to output common Tuples<br />Every operations can output new Tuples as well<br />
  23. 23. Mixing non-Hadoop code<br />Cascading allows you to mix regular java between Flows in a Cascade<br />So you can call out to databases, write intermediates to a file etc.<br />We use it to load meta data about the columns in the source files<br />Can be run via a daemon<br />Listen on a JMS queue<br />Schedule job based on job definition<br />
  24. 24. Real Example<br />For the hundreds of mailings sent last year<br />To millions of recipients<br />Show me who opened, how often<br />Break it down by how long they have been a subscriber<br />And their Gender<br />And the number of times clicked on the offer<br />
  25. 25. RDBMS solution<br />Lots of million+ row joins<br />Lots of million+ row counts<br />Temporary tables since we want multiple answers<br />Lots of memory<br />Lots of CPU and I/O<br />$$ becomes bottleneck to adding more rows or more clients to same logic<br />
  26. 26. Cascading Solution<br />Let Hadoop parse input files<br />Let Hadoop group all inputs by recipient’s email<br />Let Cascading call Every functions to look at all rows for a recipient and ‘flatten’ data (one row per recipient)<br />Split ‘flattened’ data Pipes to process in parallel: time in list, gender, clicked on links<br />Bandwidth to export data from RDBMS becomes bottleneck<br />
  27. 27. Example Continued<br />Adding a new ‘pivot’ means:<br />add a new Pipe to existing flow<br />Define the new Aggregation function if not something common<br />Defining the new output Tap<br />Dynamic Flow creation allows me to do this in a function and configure ‘outputs’ from a well known set<br />Desired Results defined per job run<br />
  28. 28. Another Example: ISP Bandwidth<br />Operations would like to know what ISPs do we send the most email to?<br /># of recipients can be obtained from the database easily<br />Bandwidth can’t<br />
  29. 29. Bandwidth Example<br />Daily load the logs from our MTA servers into Hadoop<br />Run a Cascading job to aggregate by destination IP, # of messages, # of bytes<br />Save daily into HDFS ‘intermediate’<br />Weekly run a Cascading job against the daily files to determine weekly usage, top domains, change in domain ranking<br />
  30. 30. Pros and Cons<br />Pros<br />Mix java between map/reduce steps<br />Don’t have to worry about when to map, when to reduce<br />Don’t have to think about dependencies or how to process<br />Data definition can change on the fly<br />Cons<br />Level above Hadoop – sometimes ‘black magic’<br />Data must (should) be outside of database to get most concurrency <br />
  31. 31. Resources<br />Me: ccurtin@silverpop.com @ChrisCurtin<br />Chris Wensel: @cwensel <br />Web site: www.cascading.org<br />Mailing list off website<br />AWSome Atlanta Group: http://www.meetup.com/awsomeatlanta/<br />O’Reilly Hadoop Book: <br />http://oreilly.com/catalog/9780596521974/<br />

×