diff --git a/hadoop-project/src/site/site.xml b/hadoop-project/src/site/site.xml index a88f0e3..44551fe 100644 --- a/hadoop-project/src/site/site.xml +++ b/hadoop-project/src/site/site.xml @@ -142,6 +142,7 @@ + diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/SharedCache.md b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/SharedCache.md new file mode 100644 index 0000000..b217833 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/SharedCache.md @@ -0,0 +1,127 @@ + + +YARN Shared Cache +=================== + + + +Overview +-------- + +The YARN Shared Cache provides the facility to upload and manage shared +application resources to HDFS in a safe and scalable manner. YARN applications +can leverage resources uploaded by other applications or previous +runs of the same application without having to reĀ­upload and localize identical files +multiple times. This will save network resources and reduce YARN application +startup time. + +Current Status and Future Plans +------------ + +Currently the YARN Shared Cache is released and ready to use. The major +components are implemented and have been deployed in a large-scale +production setting. There are still some pieces missing (i.e. strong +authentication). These missing features will be implemented as part of a +follow-up phase 2 effort. Please see +[YARN-7282](https://issues.apache.org/jira/browse/YARN-7282) for more information. + +Architecture +------------ + +The shared cache feature consists of 4 major components: + +1. The shared cache client. +2. The HDFS directory that acts as a cache. +3. The shared cache manager (aka. SCM). +4. The localization service and uploader. + +### The Shared Cache Client + +YARN application developers and users, should interact with the shared cache using +the shared cache client. This client is responsible for interacting with the +shared cache manager, computing the checksum of application resources, and +claiming application resources in the shared cache. Once an application has claimed +a resource, it is free to use that resource for the life-cycle of the application. +Please see the SharedCacheClient.java javadoc for further documentation. + +### The Shared Cache HDFS Directory + +The shared cache HDFS directory stores all of the shared cache resources. It is protected +by HDFS permissions and is globally readable, but writing is restricted to a trusted user. +This HDFS directory is only modified by the shared cache manager and the resource uploader +on the node manager. Resources are spread across a set of subdirectories using the resources's +checksum: +``` +/sharedcache/a/8/9/a896857d078/foo.jar +/sharedcache/5/0/f/50f11b09f87/bar.jar +/sharedcache/a/6/7/a678cb1aa8f/job.jar +``` + +### Shared Cache Manager (SCM) + +The shared cache manager is responsible for serving requests from the client and +managing the contents of the shared cache. It looks after both the meta data as +well as the persisted resources in HDFS. It is made up of two major components, +a back end store and a cleaner service. The SCM runs as a separate daemon +process that can be placed on any node in the cluster. This allows for +administrators to start/stop/upgrade the SCM without affecting other YARN +components (i.e. the resource manager or node managers). + +The back end store is responsible for maintaining and persisting metadata about +the shared cache. This includes the resources in the cache, when a resource was +last used and a list of applications that are currently using the resource. The +implementation for the backing store is pluggable and it currently uses an +in-memory store that recreates its state after a restart. + +The cleaner service maintains the persisted resources in HDFS by ensuring that +resources that are no longer used are removed from the cache. It scans the +resources in the cache periodically and evicts resources if they are both stale +and there are no live applications currently using the application. + +### The Shared Cache uploader and localization + +The shared cache uploader is a service that runs on the node manager and adds +resources to the shared cache. It is responsible for verifying a resources +checksum, uploading the resource to HDFS and notifying the shared cache +manager that a resource has been added to the cache. It is important to note +that the uploader service is asynchronous from the container launch and does not +block the startup of a yarn application. In addition adding things to the cache +is done in a best effort way and does not impact running applications. Once the +uploader has placed a resource in the shared cache, YARN uses the normal node +manager localization mechanism to make resources available to the application. + +Developing YARN applications with the Shared Cache +------------ + +To support the YARN shared cache, an application must use the shared cache +client during application submission. The shared cache client returns a +URL corresponding to a resource if it is in the shared cache. To use the cached +resource, a YARN application simply uses the cached URL to create a +LocalResource object during application submission. + +Administrating the Shared Cache +------------ +An administrator can initially set up the shared cache by following these steps: + +1. Create an HDFS directory for the shared cache (default: /sharedcache). +2. Set the shared cache directory permissions to 0755. +3. Ensure that the shared cache directory is owned by the user that runs the +shared cache manager daemon and the node manager. +4. In the yarn-site.xml file, set yarn.sharedcache.enabled to true and +yarn.sharedcache.root-dir to the directory specified in step 1. +5. Start the shared cache manager: +``` +/hadoop/bin/yarn --daemon start sharedcachemanager +```