April 14, 2014

Improving cache control for VOD re-streaming

One of the most popular use cases of Nimble Streamer is the ability to re-stream VOD transmission from origin servers to viewers. This allows building media content delivery networks. The common VOD scenario looks like this:

  1. An edge server is getting request for a file from a media player. This file may be a chunk for HLS or SmoothStreaming, or progressive download file.
  2. This request is made to the origin server and the file is downloaded.
  3. As soon as part of the file is available, it's returned to a viewer.
  4. When the file is downloaded, it's placed into file cache.
  5. If file cache is full, the file is placed into RAM cache.
  6. When this file is requested again, it's taken from edge cache rather than from origin server.
This scenario allows media players continue to play video from the latest chunk in case of edge server restarting (due to update procedure or some crash).

The media which is stored on origin may be delivered via HLS, SmoothStreaming and progressive download. The origin server may be based on any software, including Nimble. Please read VOD HLS streaming real-life example for it.

Here's a brief picture describing the possible VOD delivery network configuration.
Example of Nimble-based progressive download infrastructure.

Caching is an important part of re-streaming process. It allows saving origin resources and bring the content closer to end users. As any cache, Nimble's cache has its life cycle. Let's see how VOD cache works and how you can control it.

Cache is stored on edge server in a designated directory which is set up in the configuration file via "cache_path" variable. Its default value is "/var/cache/nimble".

There are several parameters you can use for controlling cache size.

Max file cache size. In order to avoid the disk space overflow, you can limit the cache size by specifying "Max file cache size (MB)" parameter via web UI. This will limit the space available for cache.

Cache timeout. You may still face a situation when Nimble needs more space than it's been provided.
To avoid this, set "vod_cache_timeout" parameter which contains amount of hours to keep the files and chunks. Its default value is "24" which means a file will be kept for a day and then cleaned up. If you have limited number of files and wish them all be stored on edge servers for as long as possible, you may set it up for some big number like 720 (an average month).

Minimum storage time. You've set cache timeout and you still have a space limitation, however your VOD files may overdue fast. In this case you can use Least Recently Used (LRU) caching mechanism. Nimble discards the least recently used items first using the time from the config. You may set this time via "vod_cache_min_storage_time" parameter. If Nimble needs to store new file or chunk in cache and the cache is full, then the chunks with earlier time of usage will be removed. Use this parameters after you've set "vod_ cache_timeout" described above.

See also: FAQ: How can I clear Nimble Streamer cache?

These settings allow effectively controlling cache behavior and building flexible and reliable delivery networks.

You can also take a look the video where Jan Ozer of Streaming Learning Center and Yury Udovichenko of Softvelum discuss pros and cons of dynamic packetizing of live, VOD and DVR content. It gives more details about Nimble Streamer VOD streaming.



Related documentation


VOD streaming features of Nimble StreamerMP4 transmuxing to HLS VOD streamingStreaming VOD with Nimble Streamer, Nimble Streamer configuration