Design and Implementation of Streaming Media Server Cluster Based on FFMpeg

Poor performance and network congestion are commonly observed in the streaming media single server system. This paper proposes a scheme to construct a streaming media server cluster system based on FFMpeg. In this scheme, different users are distributed to different servers according to their locations and the balance among servers is maintained by the dynamic load-balancing algorithm based on active feedback. Furthermore, a service redirection algorithm is proposed to improve the transmission efficiency of streaming media data. The experiment results show that the server cluster system has significantly alleviated the network congestion and improved the performance in comparison with the single server system.


Introduction
With the rapid development of streaming media technology and the expansion of its application fields, more and more users want to enjoy high definition video. As a result, large volume of media data needs to be transmitted over the network and the server loads increase dramatically [1]. In order to handle the massive volume of data, the streaming media system has to alleviate the load of backbone network to avoid network congestion.
In conventional streaming media single server system, all the tasks are processed by only one server. This kind of data processing causes low parallel service and poor capacity of streaming media server. It is difficult to meet the current network requirements of large quantity of VOD (video on demand) and low data transmission of the streaming media system. The streaming media server cluster with superb scalability and fault tolerance is an effective method to resolve the problem of servers overloading and provide high quality service. For the purpose of improving the service performance, tasks are assigned to different nodes by using load-balancing scheduling mechanisms [2][3][4]. With regard to streaming media system, most of the studies focus on the load-balancing algorithm. For instance, Wonjae Lee propose a load-balancing system for IPTV Web application virtualization which supports high availability and distributes tasks based on server loads [5]. A new load-balancing policy, named ADuS, is proposed in [6], which attempts to partition jobs according to their present sizes and further rank servers based on their loads. Although these algorithms have been used to improve the performance of streaming media server cluster in the simulation experiments, they did not consider the whole layout and specific applications. And few of them have proved their feasibilities in a real streaming media server cluster system. However, there are only a few studies focusing on the protocols. For example, in [7], the streaming media content type and streaming protocols are used to relieve the bandwidth bottleneck and make smooth transmission of streaming media data. But when the number of the users increases, the service performance will become unsatisfactory. FFMpeg [8] is the excellent software to provide streaming media system platform. It not only contains some crucial and indispensable tools for streaming media system, such as FFPlay, FFServer [9,10], but supports most of the codec which can enhance the applicability of streaming media system, such as H.264, MPEG [11,12].
In this paper, we propose a scheme to construct a streaming media server cluster based on FFMpeg. In this server 2 The Scientific World Journal cluster, the user management of partition is used to scatter streaming media data in various areas, which can alleviate the load of backbone network and avoid network congestion. Meanwhile, a dynamic load-balancing algorithm based on active feedback and an improved redirection algorithm are used to improve the service ability of the streaming media system.

The Limit of Streaming Media Single Server System Based on FFMpeg
In the streaming media single server system based on FFMpeg, all relevant manipulations, such as authentication, establishing connection, and providing streaming media data, are processed by FFServer. However, with the increasing of VOD quantity, the bandwidth and server loads will be increased, which becomes the bottleneck of streaming media single server system based on FFMpeg. The analysis of occupied bandwidth is described as follows: where is the occupied bandwidth of user ( = 1, 2, . . . , ) and is the output bandwidth of FFServer. From (1), the larger the , the greater . It indicates that server loads and backbone bandwidth of the network occupied by server will be increased by the number of connected users. All of these do not adapt to the development of the streaming media technology.

Design of Streaming Media Server Cluster System Based on FFMpeg
Compared with streaming media single server system, the streaming media server cluster system based on FFMpeg consists of a central server and multiple regional servers that are deployed on the edge of the network with multiple copies of objects. The load-balancing and redirection algorithms are used by the central server to select optimal servers for users so that the data transmission is in relatively small scope. Thus, the pressure on the backbone network can be alleviated effectively. Two kinds of streaming media system models are shown in Figure 1.

Design of Central Server
Central Server. The central server, which is the center of the streaming service system, is implemented based on FFServer.
For the purpose of better serving the VOD requests which are sent by users, the central server not only has massive storage and powerful data processing ability but also holds copies of all the media files, all the regional servers' IP and the streaming media server cluster diagrams. By using a specific scheduling algorithm, it keeps the server loads in balance. Meanwhile, it can provide streaming data to other users and regional servers. Some indispensable elements are implemented as follows.
(1) The Establishment of the Video Streaming List. In the central server, a crucial data structure, named FFStream, records all the information of each multimedia stream. All the media files are stored in first stream that is a list linked to FFStream. Furthermore, as shown in Figure 2, the URL (uniform resource locator) is the full path to other servers which include corresponding streaming media files.
(2) The Establishment of Server Addresses Array. The array is used to store all servers' IP address and load conditions of each server (load level) and the information of regional movie (reg movie infor). As shown in Figure 3, the information of regional film (reg movie infor) is defined as follows: Int movie hot; }; movie index: the positions of requested movie (it has not been downloaded to regional server) in the first stream.
movie hot: demand-rate (demand times per day) of the movie (no more than the specific threshold).

(3) The Establishment of Streaming Media Server Cluster
Graph. It is a weighted undirected graph which is composed by the routing hops among servers and stored in an adjacency matrix. The weight of each edge represents the corresponding routing hops between two servers. By using the adjacency matrix and video streaming list, the central server selects the optimal server which has a relatively small cost and smooth route for the user to transmit streaming data. An example is shown in Figure 4, where represents the central server, and ( = 1, 2 . . . , ) represents the regional server.

Design of Regional Server
Regional Server. There are multiple regional servers in the streaming media service system, and all of them are deployed in different regions, which are only responsible for specific region transmission of the media data and only store the higher-demand movies. Compared to the central server, the regional servers have lower demands for storage but require powerful processing capacity because they are responsible for data transmission among the whole regions. Regional servers can be implemented in using FFServer. They play dual rules: one is the server that provides streaming data for the user when it receives requirement of VOD and the other is the user that will download the media resources from other servers.

The Schedule Process of Server Cluster
System. The central server controls the schedule process of the server cluster system. The schedule process is shown in Figure 5.
The Scientific World Journal Central server Regional server Regional server Regional server (a) Streaming media server cluster system C1 C2

C3
Streaming media single server (b) Streaming media single server system Figure 1: Two kinds of streaming media service system models.   Figure 3, assume that users are distributed to regional servers and is the occupied bandwidth of network when user ( = 1, 2, 3, . . . , ) demands media resources. The total bandwidth of all the users is = ∑ =1 . The average bandwidth is

The Analysis of Network Bandwidth. For
According to YU et al. analysis of China telecom Power Info system data shows that approximate demand of 80% is concentrated on the film of 23%, which follows the 80-20 rule. Based on this, 20% of the hot films are stored in regional servers in this system, if users are distributed to regional servers on average, (1-80%) of K users need to get streaming data from other servers instead of their own regional servers; meanwhile, some regional servers need to download requested data from other servers. Therefore, the occupied bandwidth of backbone is defined as follows: where is the total bandwidth occupied by regional servers that download the streaming media files from other servers, which is given by where is the heat threshold of regional films and is the bandwidth of downloading video of a single region server. Representing using the average bandwidth, the occupied bandwidth of backbone can be rewritten as follows: The parameter can be set dynamically according to the network congestion degree and server performance. When < 4 ⋅ , we can get inequalities (6) from formula (5). Consider the following: Obviously, inequality (6) shows that the streaming media server cluster can reduce the bandwidth of backbone network compared with the streaming media single server system.

Load-Balancing Algorithm.
Load-balancing is to effectively disperse a large volume data to a limited number of regional servers, which provides load balance between servers and avoids network bottleneck.
In the existing load-balancing algorithms [13,14], the dynamic load-balancing algorithm is well-developed, such as the content-based dynamic load-balancing algorithm [15]. However, the algorithms do not use real-time feedbacks. In this paper, a dynamic load-balancing algorithm using active feedback is proposed and described as follows.
(1) Regional servers monitor their own load situation in real time by getting their own load information , which is defined as follows: where is occupation rate of CPU, is occupation rate of memory, and is occupation rate of hard disk. Meanwhile, every regional server will set the threshold values , , and for each of their own conditions of hardware loads , , and . And the field of 10 is divided into five grades, that is, grade 1 , grade 2 , grade 3 , grade 4 , and threshold grade , which meets the following condition: 0 < grade < grade < grade < 10 (0 < < < 5), where grade is set based on the actual situation. The divided process of grade is shown as follows: (2) When regional servers find that their own load grade has changed, they will send the information of changed grade, that is, the feedback of local load grade , to the central server immediately. If the hardware loads of the regional servers or whole loads reach the threshold value, the regional servers will send the corresponding threshold value ( = , , ) or grade .
(3) When the central server receives the information of changed loads level, it will update the corresponding regional server loads grade in the server addresses  array immediately for routing selection. If it receives the loads grade which is the threshold value, the central server will not assign tasks for the regional servers. (4) When the central server selects the optimal server for user , it looks up the server cluster adjacency matrix, finds out the route hops from regional server to , and retrieves server loads grade from the server addresses array. The optimal server which is selected gives the maximum value of (9): MAX { 1 1/grade + } ( = 1, 2, . . . , , ̸ = ) , (9) where grade is the load grade of and is the route hops from regional server to the optimal server .

Redirection Algorithm.
In conventional redirection algorithms, user requests are sent to the central server which selects the optimal server and returns its IP back to the user. Then the user will resend the request to the optimal server to obtain streaming data. There is a drawback in this redirection algorithm that the user must wait until the center server returns the optimal server IP. As a result, the response time is long.
In this paper, the redirection algorithm is modified to reduce the response time. The algorithm is described as follows.
(1) When the requests are sent to the central server, the central server will select an optimal server for the user who sends the request and transmit the request to the optimal server. Meanwhile, the optimal server's IP will be sent to the user. (2) When the optimal server receives the request which is transmitted from the central server, it establishes connection for the user immediately and sends central server IP and confirmation information to the user.
Then it provides streaming data to the user directly.
(3) When the user receives the returning information from central server or optimal server, it will get ready to receive streaming data. Streaming media single server system: FFServer is used as the server.

Analysis of Experiment
Streaming media server cluster is based on FFMpeg: One central server and two regional servers have been set in this experiment. Users have been distributed across two regional servers on average. The heat threshold is set to 2. The downloading bandwidth of a single server is 4508 kbps. The loads level of each server is grade 1 = 4, grade 2 = 5, grade 3 = 6, and grade 4 = 7 and the threshold value grade is 8. During the experiment, the demanded streaming media files do not exist in their own server with 20% probability, and Bmon and Luyougang tools are used to detect network bandwidth at the same time. All the recorded data are illustrated in Table 1.
The data given in Table 1 shows that when the number of users increases up to 20 in the single server system, the bandwidth of backbone network increases to 11.32 by degrees. Until the number of users reaches 22, the bandwidth is close to the upper limit load of Ethernet card equipped in the single server. As a result, the response time becomes significantly longer and the packages begin to be lost which lead to an unsmooth video. However, in the server cluster system, the load and bandwidth of the central server have declined significantly. The two regional servers undertake most of data transmission, which can guarantee loads balance of the system basically. Due to the fact that all the data are scattered 6 The Scientific World Journal  The Scientific World Journal 7 in various areas effectively, bandwidth of backbone network is much smaller than the single server system.

Conclusion
In this paper, we proposed an advanced load-balancing algorithm and an improved redirection algorithm for the streaming media server cluster based on FFMpeg. The system not only provides load-balancing among servers but also reduces the bandwidth of backbone network effectively. In the future work, the technology of voluntary server and P2P will be introduced to the streaming media cluster system to establish the video grid of multilevel scalable architecture.