Efficient nginx-based multi-process live stream sharing method

文档序号:1908594 发布日期:2021-11-30 浏览:14次 中文

阅读说明:本技术 一种高效的基于nginx的多进程直播流共享方法 (Efficient nginx-based multi-process live stream sharing method ) 是由 蔡坤松 于 2021-08-31 设计创作,主要内容包括:本发明公开了一种高效的基于nginx的多进程直播流共享方法,包括如下步骤:S1:调度中心收到播放APP的播放服务请求,并获取到播放服务请求的直播地址;S2:调度中心将各worker进程上报的直播流数据与直播地址匹配,并查找到与直播地址相匹配的worker进程;S3:匹配的worker进程向播放APP推送直播流数据,同时匹配的worker进程向未匹配的worker进程发出回源请求;S4:未匹配的worker进程向匹配的worker进程实时推送播放APP请求但匹配的worker进程不含有的直播流数据。各worker进程分开协同工作,不再互推流,只有在播放APP观看时发现匹配的worker进程没有当前请求的流数据时才发起回源拉流,降低服务器负载,保证推流工作的稳定性。(The invention discloses an efficient nginx-based multi-process live stream sharing method, which comprises the following steps: s1: the scheduling center receives a playing service request for playing the APP and obtains a live broadcast address of the playing service request; s2: the scheduling center matches live broadcast stream data reported by each worker process with a live broadcast address, and searches for the worker process matched with the live broadcast address; s3: the matched worker process pushes live streaming data to the playing APP, and meanwhile, the matched worker process sends a source returning request to an unmatched worker process; s4: and the unmatched worker process pushes and plays the APP request to the matched worker process in real time, but the matched worker process does not contain live streaming data. Each worker process is separated and cooperated to work, mutual flow pushing is not performed, and source return flow pulling is initiated only when the matched worker process is found to have no current requested flow data when the APP is played for watching, so that the load of a server is reduced, and the stability of flow pushing work is ensured.)

1. An efficient nginx-based multi-process live stream sharing method is characterized by comprising the following steps:

s1: the scheduling center receives a playing service request for playing the APP and obtains a live broadcast address of the playing service request;

s2: the scheduling center matches live broadcast stream data reported by each worker process with a live broadcast address, and searches for the worker process matched with the live broadcast address;

s3: the matched worker process pushes live streaming data to the playing APP, and meanwhile, the matched worker process sends a source returning request to an unmatched worker process;

s4: and the unmatched worker process pushes and plays the APP request to the matched worker process in real time, but the matched worker process does not contain live streaming data.

2. The efficient nginx-based multi-process live stream sharing method as claimed in claim 1, wherein live stream data of each process is pushed by a push stream camera, each worker process receives push stream data and then stores the push stream data separately, and the live stream data stored in each worker process are different from each other.

3. The efficient nginx-based multi-process live stream sharing method as claimed in claim 1, wherein live stream ids are attached to live addresses, and each live stream id has a unique corresponding live stream data.

4. The efficient nginx-based multi-process live stream sharing method as claimed in claim 1, wherein the mutual source returning process of worker processes is as follows:

a1: the matched worker process does not contain live streaming data for playing the APP real-time request;

a2: the scheduling center finds a worker process corresponding to the live streaming data playing the APP real-time request according to the live streaming data reported by the unmatched worker process;

a3: the matched worker process initiates a source returning request to a corresponding unmatched worker process;

a4: and pushing live streaming data to the matched worker process by the corresponding unmatched worker process.

5. The efficient nginx-based multi-process live stream sharing method as claimed in claim 1, wherein the push stream camera pushes live data streams to unused worker processes in real time, each worker process is automatically emptied after one-time inter-process push service is performed, and a next push stream of the push stream camera is received.

Technical Field

The invention relates to the technical field of communication, in particular to an efficient nginx-based multi-process live stream sharing method.

Background

Media refers to a form of media that streams audio, video, and multimedia files over a network. Compared with the network playing mode of watching after downloading, the streaming media is typically characterized in that continuous audio and video information is compressed and then put on a network server, and a user can watch while downloading without waiting for the whole file to be downloaded. Due to the superiority of the streaming media technology, the technology is widely applied to video-on-demand, video conference, remote education, remote medical treatment and online live broadcast systems.

The streaming media server is realized by a master and a plurality of worker frameworks, and the master is responsible for managing the running condition of the worker process, quitting and re-pulling the worker process and recording the task of the life and death state of the worker process. After receiving the camera push stream, the worker processes mutually push to other worker processes so as to ensure that each worker process in the current nginx server contains current stream data. The flow pushing mode enables each worker process to need extra burden of other worker process flow pushing loads, extra burden is caused on the server, flow pushing efficiency is affected, and the conditions of server paralysis and the like are prone to occurring.

Disclosure of Invention

The invention aims to provide an efficient nginx-based multi-process live stream sharing method, which is used for solving the technical problems in the background technology.

The technical scheme of the invention is an efficient nginx-based multi-process live stream sharing method, which comprises the following steps:

s1: the scheduling center receives a playing service request for playing the APP and obtains a live broadcast address of the playing service request;

s2: the scheduling center matches live broadcast stream data reported by each worker process with a live broadcast address, and searches for the worker process matched with the live broadcast address;

s3: the matched worker process pushes live streaming data to the playing APP, and meanwhile, the matched worker process sends a source returning request to an unmatched worker process;

s4: and the unmatched worker process pushes and plays the APP request to the matched worker process in real time, but the matched worker process does not contain live streaming data.

In a preferred embodiment, the live streaming data of each process is pushed by a push streaming camera, each worker process receives the push streaming data and then stores the push streaming data separately, and the live streaming data stored in each worker process are different from each other.

In a preferred embodiment, live stream ids are appended to the live addresses, and each live stream id has a unique corresponding live stream data.

In a preferred embodiment, the mutual source returning process of worker processes is as follows:

a1: the matched worker process does not contain live streaming data for playing the APP real-time request;

a2: the scheduling center finds a worker process corresponding to the live streaming data playing the APP real-time request according to the live streaming data reported by the unmatched worker process;

a3: the matched worker process initiates a source returning request to a corresponding unmatched worker process;

a4: and pushing live streaming data to the matched worker process by the corresponding unmatched worker process.

In a preferred embodiment, the push stream camera pushes a live data stream to unused worker processes in real time, each worker process is automatically emptied after performing an inter-process push service, and a next push stream of the push stream camera is received.

The technical scheme of the invention has the beneficial effects that:

1. each worker process is separated and cooperated to work, mutual flow pushing is not performed, and source return flow pulling is initiated only when the matched worker process is found to have no current requested flow data when the APP is played for watching, so that the load of a server is reduced, and the stability of flow pushing work is ensured.

2. And each worker thread manages live streaming data and reports scheduling to the scheduling center in real time so that the scheduling center can acquire the live streaming data of the playing APP request, and the effectiveness of pushing streaming is ensured.

3. Each worker process independently monitors a socket port of a domain, return-source service among the worker processes is provided, and accuracy and safety of return-source are improved.

Drawings

Figure 1 is a prior art overall flow diagram,

figure 2 is an overall flow chart of the present invention,

figure 3 is a step frame of the present invention,

FIG. 4 is a flow chart of the worker processes returning to the source.

Detailed Description

The present invention will be described in further detail with reference to the accompanying drawings and specific embodiments. The embodiments of the present invention have been presented for purposes of illustration and description, and are not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiment was chosen and described in order to best explain the principles of the invention and the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.

Fig. 1 is a flowchart of a sharing method of a multi-process live stream in the prior art, after receiving a camera push stream, an order process pushes another worker process to ensure that each worker process in a current nginx server contains current stream data. The flow pushing mode enables each worker process to need extra burden of other worker process flow pushing loads, extra burden is caused on the server, flow pushing efficiency is affected, and the conditions of server paralysis and the like are prone to occurring. Therefore, the method and the device for pushing the flow change the flow pushing mode and the flow pushing time among the worker processes so as to reduce the load of the server and improve the flow pushing efficiency.

Referring to fig. 2 to 4, in the technical solution of the present invention, an efficient nginx-based multi-process live stream sharing method includes the following steps:

s1: and the dispatching center receives a playing service request of playing the APP and acquires a live broadcast address of the playing service request. The live address is attached with live stream id, and each live stream id has only corresponding live stream data.

S2: and the scheduling center matches the live broadcast stream data reported by each worker process with the live broadcast address and searches the worker process matched with the live broadcast address.

S3: and the matched worker process pushes the live streaming data to the playing APP, and meanwhile, the matched worker process sends a source returning request to the unmatched worker process. And only when the matched worker process does not contain live streaming data for playing the APP real-time request, the matched worker process can initiate a source returning request to the unmatched worker.

S4: and the unmatched worker process pushes and plays the APP request to the matched worker process in real time, but the matched worker process does not contain live streaming data.

The mutual source returning process of each worker process comprises the following steps:

a1: the matched worker process does not contain live streaming data for playing the APP real-time request;

a2: the scheduling center finds a worker process corresponding to the live streaming data playing the APP real-time request according to the live streaming data reported by the unmatched worker process;

a3: the matched worker process initiates a source returning request to a corresponding unmatched worker process;

a4: and pushing live streaming data to the matched worker process by the corresponding unmatched worker process.

Live streaming data of each process is pushed by a push stream camera, each worker process receives the push stream data and then stores the push stream data independently, and the live streaming data stored in each worker process are different from each other. The push stream camera pushes live broadcast data streams to unused worker processes in real time, each worker process is automatically emptied after one-time inter-process pushing service, and the next push stream of the push stream camera is received.

Each worker process is separated and cooperated to work, mutual flow pushing is not performed, and source return flow pulling is initiated only when the matched worker process is found to have no current requested flow data when the APP is played for watching, so that the load of a server is reduced, and the stability of flow pushing work is ensured.

And each worker thread manages live streaming data and reports scheduling to the scheduling center in real time so that the scheduling center can acquire the live streaming data of the playing APP request, and the effectiveness of pushing streaming is ensured.

Each worker process independently monitors a socket port of a domain, return-source service among the worker processes is provided, and accuracy and safety of return-source are improved.

It is to be understood that the described embodiments are merely a few embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by one of ordinary skill in the art and related arts based on the embodiments of the present invention without any creative effort, shall fall within the protection scope of the present invention. Structures, devices, and methods of operation not specifically described or illustrated herein are generally practiced in the art without specific recitation or limitation.

8页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种超高清视频分布式实时处理系统、方法、设备及介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类