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

7 comments:

  1. I'd like to keep VOD content in cache for 3 weeks (provided there's sufficient space) but also for a minimum of 12 hours. So I would configure as follows.
    vod_cache_timeout = 504
    vod_cache_min_storage_time = 12
    Question 1: if disk cache is full will it discard the Least Recently Used file or chunk older than 12 hours?
    Question 2: With the above configuration, would it ever use RAM cache? “If file cache is full, the file is placed into RAM cache.” http://blog.wmspanel.com/2014/04/improving-cache-control-for-vod-restreaming.html

    ReplyDelete
    Replies
    1. Hello Paul,

      1. Nimble will try to discard items from LRU list, which should remove oldest unused chunks in cache that are already stored vod_cache_min_storage_time (12 hours in your case).

      2. Yes, if there is no items to discard Nimble will use RAM cache.

      Delete
    2. Is the LRU caching mechanism invoked by setting the optional vod_cache_min_storage_time parameter?

      Delete
    3. Hello Friend.

      I'm from Brazil and would help to set the Nimble Streaming only to MPEG-TS to MPEG DASH Transmuxing ABR.
      Would you help me?
      What's your Skype ID?
      My Skype ID is: jadsonwelder

      Delete
  2. There are two parameters vod_cache_timeout and vod_cache_min_storage_time.
    vod_cache_timeout is 86400 seconds (i.e 3600*24, 1 day) by default.
    vod_cache_min_storage_time is 3600 seconds i.e 1 hour.
    All chanks will be removed from cache after vod_cache_timeout.
    Chunk may be removed from cache only if vod_cache_min_storage_time exeeded.
    If it's enough space to store additional chunks then chunks with vod_cache_min_storage_time exeeded will not be removed. If we removed all chunks with
    vod_cache_min_storage_time exeeded but still cannot put new chunk to ROM we use RAM then.
    You can force to use RAM first if you set vod_to_ram_cache_first = true. this way Nimble will try to allocate item in RAM by default. All rules above work even in this case.
    LRU works always as both values have default values.

    NOTE:
    if you need to set vod_cache_min_storage_time to 12 minutes you need to set it to 12*60 = 720

    ReplyDelete
  3. so at the end of the day what is default units for vod_cache_timeout and vod_cache_min_storage_time?
    Is that seconds or hours???

    ReplyDelete
    Replies
    1. For both parameters it's 1 hour.
      Please refer to config reference: http://blog.wmspanel.com/p/nimble-streamer-configuration.html

      Delete

If you face any specific issue or want to ask some question to our team,
PLEASE USE OUR HELPDESK

This will give much faster and precise response.
Thank you.

Note: Only a member of this blog may post a comment.