Archive for the ‘ Apache ’ Category

Using Hadoop for Video Streaming

 

Hadoop

 

Internet Memory supplies a service to browse archived Web pages, including multimedia content. We use Hadoop, HDFS and HBase for storing and indexing our data, and associates this storage with a Web server that lets users navigate through the archive and retrieve documents. In the present post, we focus on videos and detail the solution adopted to serve true streaming from HDFS storage.

Basics

Many video formats are found on the Web, including Windows Media (.wmv), RealMedia (.rm), Quicktime (.mov), MPEG, Adobe Flash (.flv), etc. In order to display a video, we need a player, which can be incorporated in the Web browser. The player depends on the specific video format, but most browsers are able to detect the format and choose the appropriate player. Firefox for instance comes with a lot of plugins, which can be quickly integrated in the presence of a specific video to display it content.

There are basically two ways to play a video. The simplest one is a two-steps process: first the whole file is downloaded from the Web server to the user’s computer, and then displayed by the player running the local copy. It has the disadvantage that the download step may take a while is the file is big (hundreds of megabytes are not uncommon). The second one uses (true) streaming: the video file is split into fragments which are sent from the Web server to the player, giving the illusion of a continuous stream. From the user point of view, it looks as if a window is swept over the video content, saving the need of a full initial download of the whole file.

Obviously, streaming is a more involved method because it requires a strong coordination between the components involved in the process, namely the player, the Web server, and the file system from which the video is retrieved. We examine this technical issue in the context of a Hadoop system where files are stored in HDFS, a file system dedicated to large distributed storage.

 

File seeking with HDFS

At explained above, streaming requires a strong coordination between the Web server and the file system. The former produces requests to access chunks of the video file (think to what happens when the user suddenly requires a move to a specific part of the video), whereas the later must be able to seek in the file to position the cursor at a specific location. When using HDFS, enabling such a close cooperation turns out to be a problem because HDFS can in principle only be accessed through a Hadoop client, which the standard Apache server is not. We investigated two possible solutions: Hoop, the Hadoop web server, and Apache/FUSE.

Hoop (see http:///cloudera.github.com/hoop/) is an HTTP-HDFS-Connector. It allows the HDFS file system to be accessed via HTTP. A working local prototype has been developed using JW Player and a large video file. Streaming works, but seeking in an unbuffered part results in the playback stopping. It seems that the Hoop API does not support seeking in a file, so we had to give up this approach.

The second solution is based on HDFS/FUSE. FUSE (File System in User Space) is an API that captures the file system operations and allows to implement them with ad-hoc functions running in the the user’s processus space (thereby saving the need to change the operating system kernel, a tricky and dangerous option). FUSE is provided in Hadoop as a component named “Mountable HDFS” (see http://wiki.apache.org/hadoop/MountableHDFS). It lets the standard file system user or program see the HDFS name space as a locally mounted directory. All file system operations, including directory browsing, file opening and content access, are enabled over HDFS content through the FUSE interface.

Apache server configuration

It remained to configure Apache to access the mounted FUSE system and load content from video files. How this is done depends on the video format. At the moment, we tested and validated .mp4 files and Flash video files. For the first format we use H264 Streaming Module (see http://h264.code-shop.com/trac), an Apache plugin, which enables adaptive streaming. For FLV we used pseudo-stream module for Apache named “mod_flv”. Both behave nicely and go along with the mountable HDFS without problem.

Conclusion

The solution based on Apache + Mountable HDFS (FUSE) turned out to be both reliable, functionally adequate (seeking is well supported) and efficient. The architecture is simple and easy to set up, and allows to combine the benefits of HDFS for very large repositories and standard Web server streaming solutions. Although we chose to adopt Apache plugins in our current service, nothing keeps you from using a more powerful streaming server since the FUSE approach (virtually) moves all the HDFS content in the standard file system scope.

Hoop remains a potential option for the future, but it appeared not mature enough when we tested it, at least for the complex operations (seeking at a specific offset in a file) required by video streaming.

by: Philippe Rigaux, Fri 06 Apr 2012

via Internet Memory Foundation : Synapse : Using Hadoop for Video Streaming.

apache – How can I change from prefork to worker MPM on CentOS

I’m running CentOS 64 bit, and jsut found out I am running prefork MPM on my dual quad xeon. I was told worker will give me lower memory usage, and higher performance, since I run a very high traffic website.

If this is true, how do I do it?

Edit: /etc/sysconfig/httpd

Uncomment:

HTTPD=/usr/sbin/httpd.worker

Restart, voila!

After restarting httpd, I ran “ps -ef | grep -i http” and got this:

[root@localhost httpd]# ps -ef | grep -i http
root     16334 17289  0 10:44 pts/1    00:00:00 grep -i http
root     30536     1  0 10:00 ?        00:00:00 /usr/sbin/httpd.worker
apache   30539 30536  0 10:00 ?        00:00:00 /usr/sbin/httpd.worker
apache   30541 30536  0 10:00 ?        00:00:02 /usr/sbin/httpd.worker
[root@localhost httpd]# 

 

If I switch the /etc/sysconfig/httpd back to the default, the ps output is like this:

[root@localhost httpd]# ps -ef | grep -i http
root     16447     1  0 10:47 ?        00:00:00 /usr/sbin/httpd
apache   16448 16447  0 10:47 ?        00:00:00 /usr/sbin/httpd
apache   16449 16447  0 10:47 ?        00:00:00 /usr/sbin/httpd
apache   16450 16447  0 10:47 ?        00:00:00 /usr/sbin/httpd
apache   16451 16447  0 10:47 ?        00:00:00 /usr/sbin/httpd
apache   16453 16447  0 10:47 ?        00:00:00 /usr/sbin/httpd
apache   16454 16447  0 10:47 ?        00:00:00 /usr/sbin/httpd
apache   16455 16447  0 10:47 ?        00:00:00 /usr/sbin/httpd
apache   16456 16447  0 10:47 ?        00:00:00 /usr/sbin/httpd
root     16458 17289  0 10:47 pts/1    00:00:00 grep -i http
[root@localhost httpd]# 

via apache – How can I change from prefork to worker MPM on CentOS 64bit? – Server Fault.

Professional Apache Tomcat 6 (Part 1)

[issuu viewmode=presentation layout=http%3A%2F%2Fskin.issuu.com%2Fv%2Fdark%2Flayout.xml showflipbtn=true documentid=080319061418-0e21aa3f251f4eeea9f71278021708d9 docname=professional_apache_tomcat_6_part_1 username=abdagli loadinginfotext=Professional%20Apache%20Tomcat%206%20(Part%201) showhtmllink=true tag=6 width=650 height=780 unit=px]

Direct Link to part 1
Direct Link to part 2