Have you used Lua for MapReduce?

Lua as a cross platform programming language has been popularly used in games and embedded systems. However, due to its excellent use for configuration, it has found wider acceptance in other user cases as well.

Lua was inspired from SOL (Simple Object Language) and DEL(Data-Entry Language)  and created by Roberto Ierusalimschy, Waldemar Celes, and Luiz Henrique de Figueiredo at the Pontifical Catholic University of Rio de Janeiro, Brazil.  Roughly translated to ‘Moon’ in Portuguese, it has found many big takers like Adobe, Nginx, Wikipedia.

Quick Overview of key aspects:
8 Basic types
nil, boolean, number, string, function, userdata, thread, and table
3 Kinds of variables
global variables, local variables and table fields
Control structures
- if statements
- while
- repeat
- for
Similar to functions in other languages.
Closures: A function which returns a function
Similar to threads but not exactly the same;
Co-routines are collaborative
Object Oriented Programming
Tables in Lua are objects and have states like objects
Garbage Collection
Lua performs automatic memory management

A good explanation of Lua versus other scripting languages is given in a discussion chain on MediaWiki. Essentially, Lua, over the years, has been gaining wider acceptability due to it’s:
- Extensibility (through Lua or other languages like C)
- Small Size (few MBs)
- Technical USPs (for recursion, first class functions etc)
- Efficient (among the faster scripting languages)
- Portable (various platforms including Windows, Unix flavors, Playstation etc.)

A recent implementation utilizing Lua has been in the Kitten project made by Josh Wills (Cloudera) who is also the author of Apache Crunch. Much like Crunch which eases the task of invoking MapReduce jobs, Kitten simplifies YARN (aka MRv2) applications implementation as a series of patterns. Kitten is written in Java but uses Lua based configuration files for configuring, launching, and monitoring YARN applications. As part of the Lua configuration files, the resources needed by the application are specified.

As Josh writes in the Readme for Kitten project:
Kitten makes extensive use of Lua’s table type to organize information about how a YARN application should be executed… (Lua) has a number of desirable properties for the use case of configuring YARN applications, namely:
  1. It integrates well with both Java and C++. We expect to see YARN applications written in both languages, and expect that Kitten will need to support both. Having a single configuration format for both languages reduces the cognitive overhead for developers.
  2. It is a programming language, but not much of one. Lua provides a complete programming environment when you need it, but mainly stays out of your way and lets you focus on configuration.
  3. It tolerates missing values well. It is easy to reference values in a configuration file that may not be defined until much later. For example, we can specify parameters that will eventually contain the value of the master's hostname and port, but are undefined when the client application is initially configured.
That said, we fully expect that other languages (e.g., Lisp) would make excellent configuration languages for YARN applications…

Another significant experimental project for MRv1 has been Rohit Joshi’s lua-mapreduce. The project inspired by Octopy in Python has been used to demonstrate parallel execution of MapReduce tasks. Source code for this project can also be found on github.

Please note both these projects are still for development environment and we may have to wait a bit more to see successful implementations in MapReduce and Hadoop production environment.

No comments:

Post a Comment