WO2018127013A1 - 一种流数据的并发传输方法和装置 - Google Patents
一种流数据的并发传输方法和装置 Download PDFInfo
- Publication number
- WO2018127013A1 WO2018127013A1 PCT/CN2017/120143 CN2017120143W WO2018127013A1 WO 2018127013 A1 WO2018127013 A1 WO 2018127013A1 CN 2017120143 W CN2017120143 W CN 2017120143W WO 2018127013 A1 WO2018127013 A1 WO 2018127013A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- thread
- type
- transmission
- stream data
- target stream
- Prior art date
Links
- 230000005540 biological transmission Effects 0.000 title claims abstract description 340
- 238000000034 method Methods 0.000 title claims abstract description 58
- 238000004590 computer program Methods 0.000 claims description 10
- 238000012546 transfer Methods 0.000 claims description 8
- 230000004044 response Effects 0.000 abstract description 6
- 230000008901 benefit Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 1
- 239000000969 carrier Substances 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
Definitions
- the present invention relates to the field of streaming data transmission technologies, and in particular, to a concurrent transmission method of streaming data and a concurrent transmission apparatus for streaming data.
- Streaming data is data that can be transmitted over the network by means of streaming.
- Large website systems often rely on the Content Delivery Network (CDN) to transmit streaming data.
- CDN Content Delivery Network
- the content distribution network is added to the existing network.
- a new layer of network structure allows users to transfer data to or near the nearest node.
- a transmission node is deployed to buffer the stream data and provide services to the user nearby.
- a thread is randomly assigned to each connection to establish a connection for streaming data transmission, thereby implementing concurrent transmission of stream data.
- the present invention has been made in order to provide a concurrent transmission method and corresponding apparatus for streaming data that overcomes the above problems or at least partially solves or alleviates the above problems.
- a method for concurrent transmission of stream data including:
- the first type of thread is called to concurrently execute a plurality of transmission tasks, and the target stream data is transmitted to each transmission destination through a corresponding transmission channel.
- a concurrent transmission apparatus for streaming data including:
- a thread allocation module configured to allocate a first type of thread to receive stream data, and each first type thread receives a stream data
- a transmission task determining module configured to determine a transmission destination end corresponding to each transmission request and create a corresponding transmission task when receiving a plurality of transmission requests for the target stream data
- a transmission channel creation module configured to create a transmission channel between the first type of thread receiving the target stream data and each transmission destination end, where each transmission channel carries a transmission task
- the transmission task invoking module is configured to invoke the first type of thread to concurrently execute a plurality of transmission tasks, and transmit the target stream data to each transmission destination end through a corresponding transmission channel.
- a computer program comprising computer readable code that, when executed on a computing device, causes the computing device to perform streaming data as described above Concurrent transmission method.
- a computer readable medium wherein the computer program described above is stored.
- a concurrent transmission method and apparatus for streaming data receives a plurality of transmission requests for target stream data by allocating a first type of thread to receive stream data, and determines a transmission destination end corresponding to each transmission request and creates a corresponding one. Transmitting a task, creating a transmission channel between the first type of thread receiving the target stream data and each of the transmission destinations, calling the first type of thread to concurrently execute a plurality of transmission tasks, and transmitting the target stream data through corresponding transmission Channels are transmitted to each transmission destination.
- the transmission of the streaming data to the transmission destination is directly performed on the thread that receives the streaming data, thereby avoiding the problem that the thread receiving the streaming data needs to forward the streaming data to the thread that sends the streaming data, thereby reducing the data forwarding between the threads. Performance consumption while also reducing response time.
- FIG. 1 is a flow chart showing the steps of a method for concurrently transmitting stream data according to a first embodiment of the present invention
- FIG. 2 is a schematic flow chart showing the steps of a method for concurrently transmitting stream data according to Embodiment 2 of the present invention
- FIG. 3 is a block diagram showing the structure of a concurrent transmission device for streaming data according to Embodiment 3 of the present invention.
- Figure 4 is a schematic block diagram showing a computing device for performing the method according to the present invention.
- Fig. 5 schematically shows a storage unit for holding or carrying program code implementing the method according to the invention.
- FIG. 1 a flow chart of steps of a method for concurrently transmitting stream data according to a first embodiment of the present invention is shown.
- step 101 the first type of thread is allocated to receive the stream data.
- Stream data is data that can be transmitted over the network by means of streaming.
- Stream data can be transmitted between network devices such as clients or servers.
- network devices such as clients or servers.
- threads are classified into several classes according to different tasks performed, wherein a thread is allocated in a thread pool to perform a task of receiving stream data, and the thread that performs the task of receiving the stream data is referred to as a first class. Threads, and each first class thread receives a stream of data.
- content distribution networks are utilized to provide high performance, scalable, and low cost web content delivery to users.
- On the server for transmitting stream data in the content distribution network there may be multiple tasks for receiving stream data at the same time.
- a stream data receiving request is responded, a first type thread is allocated for receiving stream data, specifically A connection is established with the streaming data sender on the assigned first type thread, and the transmitted stream data is received.
- Step 102 When receiving multiple transmission requests for the target stream data, determine a transmission destination end corresponding to each transmission request and create a corresponding transmission task.
- the transmission request is a transmission request initiated by the target stream data, and the transmission request specifically includes information of the target stream data, the transmission destination end, the transmission mode, and the like, wherein the target stream data is stream data requested to be transmitted, and one transmission request may request at least one target stream. Data, the destination of the transmission is the end of the received stream data specified in the transmission request.
- the transmission task is a task of establishing a connection with the transmission destination to transmit the target stream data.
- the pointer when multiple transmission requests for the target stream data are received, the pointer has multiple transmission requests for one stream data, and specifically, the transmission request may be received on a random thread, when multiple transmissions are received.
- the transmission destinations corresponding to the respective transmission requests are determined, and each transmission task corresponding to each transmission request is created.
- Step 103 Create a transmission channel between the first type of thread that receives the target stream data and each of the transmission destinations.
- a transmission channel is a channel established between a local and a transmission destination for performing transmission of data, and may be used for a byte buffer and for transmitting data for a data entity on the other side of the channel.
- the transmission channel may refer to a Socket (the original meaning of the socket is "hole” or “socket”.
- Socket the original meaning of the socket is "hole” or "socket”.
- Address and port is a handle to a communication chain that can be used to communicate between different virtual machines or different computers.
- the first type thread that is receiving the target stream data of the transmission task is found, and the transmission channel between the first type thread and each transmission destination end is created according to the transmission task, and each transmission channel carries a transmission correspondingly. task.
- step 104 the first type of thread is invoked to perform multiple transmission tasks concurrently, and the target stream data is transmitted to each transmission destination through a corresponding transmission channel.
- multiple transmission tasks may be performed concurrently on the first type of thread, where each transmission task corresponds to transmitting the target stream data to each transmission destination through the created transmission channel.
- the maximum number of transmission tasks that can be executed concurrently on the first type of thread depends on the CPU resources consumed by the transmission task, and may be any applicable number, which is not limited by the present invention.
- the transmission destination end corresponding to each transmission request is determined and a corresponding transmission task is created.
- Creating a transmission channel between the first type of thread receiving the target stream data and each of the transmission destinations calling the first type of thread to concurrently perform a plurality of transmission tasks, and transmitting the target stream data to the corresponding transmission channel to Each transmission destination.
- the transmission of the streaming data to the transmission destination is directly performed on the thread that receives the streaming data, thereby avoiding the problem that the thread receiving the streaming data needs to forward the streaming data to the thread that sends the streaming data, thereby reducing the data forwarding between the threads. Performance consumption while also reducing response time.
- the method may further include the following steps:
- the second type of thread is used to receive transmission requests for all stream data.
- a thread is called from a thread pool to receive a transfer request for all stream data, which may be referred to as a second type of thread.
- the respective transmission requests of the respective flow data may be respectively executed by using different threads, which is not limited by the embodiment of the present invention.
- the method may further include the step of: invoking the second type of thread A plurality of transmission tasks are sent to the first type of thread, and the transmission task carries an identifier of a corresponding transmission destination.
- the second type of thread determines the transmission destination end corresponding to each transmission request and creates a corresponding transmission task, and then sends the plurality of transmission tasks to the target stream data corresponding to the transmission task.
- a type of thread, and the transmission task carries an identifier of the corresponding transmission destination.
- the transmission destination is a server, and the identifier may include a network address of the server.
- the method may further include: identifying that the flow data corresponding to each transmission request is The target stream data, and determines that the thread receiving the target stream data is the first type of thread.
- the transmission request carries the identifier of the requested target stream data, and after receiving each transmission request, identifies the stream data corresponding to each transmission request request, identifies the stream data as the target stream data, and finds the thread that receives the target stream data, and determines that The first type of thread.
- FIG. 2 is a flow chart showing the steps of a method for concurrently transmitting stream data according to a second embodiment of the present invention. Specifically, the method may include the following steps:
- Step 201 randomly select a thread from the preset thread pool as the first type thread for receiving the stream data to be received.
- a thread pool is a form of multi-threaded processing that adds tasks to a queue during processing and then automatically starts them after the thread is created.
- Thread pool threads are background threads. Each thread uses the default stack size, runs at the default priority, and is in a multithreaded apartment. If a thread is idle in managed code (such as waiting for an event), another worker thread is inserted in the thread pool to keep all processors busy. If all thread pool threads are always busy, but the queue contains pending work, another worker thread will be created in the thread pool after a period of time but the number of threads will never exceed the maximum. Threads that exceed the maximum value can be queued, but they will not start until other threads have completed.
- the preset thread pool is a thread pool preset for processing stream data related tasks.
- a thread is randomly selected from the preset thread pool to receive the stream data to be received as the first type of thread.
- Step 202 invoking a second type of thread for receiving a transmission request for all stream data.
- a thread is called from a thread pool to receive a transfer request for all stream data, which may be referred to as a second type of thread.
- the respective transmission requests of the respective flow data may be respectively executed by using different threads, which is not limited by the embodiment of the present invention.
- Step 203 When receiving a plurality of transmission requests for the target stream data, determine a transmission destination end corresponding to each transmission request and create a corresponding transmission task.
- Step 204 Determine whether the thread for transmitting the target stream data includes only the first type of thread.
- the transfer task of executing the target stream data after the creation, forwards the stream data received in the first type of thread to the newly created thread. It is judged whether the thread currently used to send the target stream data includes only the first type of thread.
- step 205 is performed.
- Step 205 Determine that the first type of thread meets the first setting condition.
- the first setting condition includes at least one of the following: the total number of transmission channels corresponding to the creation does not exceed the set number, and the set load amount is not exceeded. Get the total number of transmission channels created on the first type of thread.
- the first setting condition is that the total number does not exceed the set number or does not exceed the set load.
- the total number of transmission channels created on the first type of thread of the target stream data is obtained, and whether the first type of thread is determined according to whether the total number exceeds the set number or exceeds the set load amount.
- the first setting condition is satisfied, and it is determined that the first type of thread satisfies the first setting condition.
- the number of the settings and the amount of the set load may be any applicable, which is not limited in the embodiment of the present invention.
- the third type of thread is created to perform transmission of the target stream data.
- a thread is created for the transmission of the target stream data.
- the created thread is a third type of thread. Creating a third type of thread requires the first type of thread to forward the stream data to the third type of thread.
- the implementation of the third type of thread to perform the transmission of the target stream data is: randomly selecting a thread from the preset thread pool as the third type thread;
- the three types of threads acquire target stream data from the first type of thread that receives the target stream data, and transmit the target stream data.
- a thread is randomly selected from the preset thread pool as the third type thread, and the third type thread is called to acquire the required target stream data from the first type thread, and the target stream data is transmitted according to the transmission task.
- the method may further include: selecting, in the first type thread and the at least one third type thread, a thread that satisfies the first setting condition, and determining that the first setting is satisfied
- the thread of the condition is a thread of the first type
- the first setting condition includes at least one of the following: the total number of transmission channels corresponding to the creation does not exceed the set number, and the set load amount is not exceeded.
- the thread for sending the target stream data includes the first type thread and the at least one third type thread, finding the thread satisfying the first setting condition in the first type thread and the third type thread, the first setting condition includes At least one of the following: the total number of transmission channels created correspondingly does not exceed the set number, and the set load amount is not exceeded. Get the total number of transmission channels created on the first type of thread and the third type of thread respectively.
- the first setting condition is that the total number does not exceed the set number or does not exceed the set load. And determining that the thread satisfying the first setting condition is the first type thread, and the third type thread does not satisfy the first setting condition.
- the third type thread that satisfies the first setting condition is called to perform the transmission of the target stream data.
- the third type of thread is called to perform the transmission of the target stream data, specifically transmitting the transmission task to the third type thread, and the third type thread
- the connection with the transmission destination is established, and the streaming data is transmitted.
- the thread that satisfies the first setting condition includes the first type thread and the at least one third type thread, randomly selecting one thread from the first type thread and the at least one third type thread And determine that the randomly selected thread is the first type of thread.
- the thread satisfying the first setting condition includes the first type thread and the at least one third type thread
- one thread is randomly selected from the first type thread and the at least one third type thread, and in one case, randomly selected
- the thread is the first type of thread, and the first type of thread is used to transmit the target stream data.
- the thread that satisfies the first setting condition includes the first type of thread and the at least one third type of thread, further determining that the thread that satisfies the second setting condition is the first type of thread,
- the second setting condition includes at least one of the following: the total number of transmission channels corresponding to the creation is the smallest, and the corresponding load amount is the least.
- the second setting condition is that the total number of transmission channels corresponding to the creation is the smallest, or the corresponding load amount is the least.
- the thread satisfying the first setting condition includes the first type thread and the at least one third type thread, it is also possible to find a thread in which the second setting condition is satisfied, and in one case, the thread satisfying the second setting condition For the first type of thread, the first type of thread is used to transmit the target stream data.
- the third type thread that satisfies the second setting condition is called to perform the transmission of the target stream data.
- the third type thread that satisfies the second setting condition is searched for the target stream data transmission, and the third type thread and the transmission destination satisfying the second setting condition are satisfied.
- the terminal establishes a connection and transmits the target stream data.
- a new third type thread is created.
- a new third type thread is created, and the target stream data and the first type thread are forwarded to the newly created third type thread.
- the transmission task is sent to the newly created third type thread to complete the transmission of the target stream data according to the transmission task.
- Step 206 Create a transmission channel between the first type of thread that receives the target stream data and each of the transmission destinations.
- each transmission channel carries a transmission task.
- the specific manner is consistent with the description in other embodiments, and details are not described herein.
- Step 207 Update the total number of transmission channels recorded for the first type of thread according to the number of established transmission channels.
- the total number of transmission channels recorded for the first type of thread is updated according to the number of established transmission channels, and specifically, the transmission channel recorded for the first type of thread is established every time one transmission channel is established. The total number is increased by one. If there is a transmission task completed or other reasons lead to a reduction in the transmission channel, the total number of transmission channels recorded by the first type of thread is reduced accordingly.
- Step 208 invoking the first type of thread to concurrently perform multiple transmission tasks, and transmitting the target stream data to each transmission destination end through a corresponding transmission channel.
- one thread is randomly selected from the preset thread pool as the first type thread for receiving the stream data to be received, and the second type thread is used to receive the transmission for all stream data. Determining, when receiving a plurality of transmission requests for the target stream data, determining a transmission destination end corresponding to each transmission request and creating a corresponding transmission task, determining whether the thread for transmitting the target stream data includes only the first type of thread, Determining that the first type of thread meets the first setting condition, creating a transmission channel between the first type of thread receiving the target stream data and each transmission destination end, and updating the target according to the number of established transmission channels The total number of transmission channels recorded by the first type of thread is recorded, and the first type of thread is invoked to perform multiple transmission tasks concurrently, and the target stream data is transmitted to each transmission destination through a corresponding transmission channel.
- the above solution makes the transmission of the stream data to the transmission destination directly on the thread receiving the stream data, avoiding the problem that the thread receiving the stream data needs to forward the stream data to the thread that sends the stream data, and reduces the data band between the threads. The performance is consumed, and the response time is also reduced.
- FIG. 3 a structural block diagram of a concurrent transmission device for streaming data according to Embodiment 3 of the present invention is shown, which may specifically include the following modules:
- a thread allocation module 301 configured to allocate a first type of thread to receive stream data, and each of the first type of threads corresponding to receive one stream data;
- the transmission task determining module 302 is configured to: when receiving a plurality of transmission requests for the target stream data, determine a transmission destination end corresponding to each transmission request and create a corresponding transmission task;
- a transmission channel creation module 303 configured to create a transmission channel between the first type of thread that receives the target stream data and each of the transmission destination ends, where each transmission channel carries a transmission task;
- the transmission task invoking module 304 is configured to invoke the first type of thread to concurrently execute a plurality of transmission tasks, and transmit the target stream data to each transmission destination end through a corresponding transmission channel.
- the device further includes:
- a transmission request receiving module configured to: when the plurality of transmission requests for the target stream data are received, determine a transmission destination corresponding to each transmission request and create a corresponding transmission task, call the second type of thread to receive for all Stream data transfer request.
- the device further includes:
- a transmission task sending module configured to send the second type of thread to send the plurality of transmission tasks to the transmission channel before the creating a transmission channel between the first type thread that receives the target stream data and each transmission destination end
- the first type of thread, the transmission task carries an identifier of a corresponding transmission destination.
- the device further includes:
- a stream data identification module configured to: before the calling the second type of thread sends a plurality of transmission tasks to the first type of thread, identify stream data corresponding to each transmission request as target stream data, and determine a receiving station The thread of the target stream data is the first type of thread.
- the device further includes:
- a thread judging module configured to determine, before the creating a transmission channel between the first type of thread that receives the target stream data and each of the transmission destinations, whether the thread for transmitting the target stream data includes only the first class Thread.
- the device further includes:
- a first condition determining module configured to: if the thread used to send the target stream data includes only the first type of thread, and transmit the transmission between the first type of thread that receives the target stream data and each of the transmission destinations Before the channel, determining that the first type of thread meets the first setting condition, the first setting condition includes at least one of the following: the total number of corresponding created transmission channels does not exceed the set number, and the setting is not exceeded. The amount of load.
- the device further includes:
- the third thread creation module is configured to: if the first type thread does not satisfy the first setting condition, create a third type thread to perform target stream data transmission.
- the third thread creation module includes:
- the third thread selects a sub-module for randomly selecting one thread from the preset thread pool as the third type thread
- the stream data obtaining submodule is configured to invoke the third type thread to acquire target stream data from the first type thread that receives the target stream data, and transmit the target stream data.
- the device further includes:
- a first condition satisfaction module configured to: if the thread for transmitting the target stream data includes a first type of thread and at least one third type of thread, create a first type of thread and each of the target stream data Before transmitting the transmission channel between the destination ends, selecting, in the first type of thread and the at least one third type of thread, a thread that satisfies the first setting condition, and determining that the thread that satisfies the first setting condition is the first type Thread, the first setting condition includes at least one of the following: the total number of corresponding created transmission channels does not exceed the set number, and the set load amount is not exceeded.
- the device further includes:
- the third thread invokes a module, if it is determined that the thread satisfying the first setting condition is not the first type thread, the third type thread that satisfies the first setting condition is called to perform the target stream data transmission.
- the device further includes:
- a thread random module configured to: if the thread satisfying the first setting condition includes the first type thread and the at least one third type thread, randomly select one thread from the first type thread and the at least one third type thread, and determine a random The selected thread is the first type of thread.
- the device further includes:
- a second condition satisfaction module configured to: if the thread satisfying the first setting condition includes the first type thread and the at least one third type thread, further determining that the thread satisfying the second setting condition is the first type thread,
- the second setting condition includes at least one of the following: the total number of transmission channels corresponding to the creation is the smallest, and the corresponding load amount is the least.
- the device further includes:
- the third thread invokes a module, configured to: if the first type of thread does not satisfy the second set condition, invoke a third type of thread that satisfies the second set condition to perform target stream data transmission.
- the device further includes:
- the third creating module is configured to create a new third type thread if the existing first type thread and the third type thread do not satisfy the first setting condition.
- the device further includes:
- a number update module configured to update, according to the number of established transmission channels, the record for the first type of thread after the creating a transmission channel between the first type of thread and each of the transmission destinations The total number of transmission channels.
- the thread allocation module is specifically configured to randomly select one thread from the preset thread pool as the first type thread for receiving the stream data to be received.
- the transmission destination end corresponding to each transmission request is determined and a corresponding transmission task is created.
- Creating a transmission channel between the first type of thread receiving the target stream data and each of the transmission destinations calling the first type of thread to concurrently perform a plurality of transmission tasks, and transmitting the target stream data to the corresponding transmission channel to Each transmission destination.
- the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
- a microprocessor or digital signal processor may be used in practice to implement some of some or all of the components of a concurrent method and apparatus for streaming data in accordance with embodiments of the present invention. Or all features.
- the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
- Such a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
- Figure 4 illustrates a concurrent transmission computing device, such as an application server, that can implement streaming data in accordance with the present invention.
- the computing device conventionally includes a processor 410 and a computer program product or computer readable medium in the form of a memory 420.
- the memory 420 may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read Only Memory), an EPROM, a hard disk, or a ROM.
- Memory 420 has a memory space 430 for program code 431 for performing any of the method steps described above.
- storage space 430 for program code may include various program code 431 for implementing various steps in the above methods, respectively.
- the program code can be read from or written to one or more computer program products.
- These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such computer program products are typically portable or fixed storage units as described with reference to FIG.
- the storage unit may have storage segments, storage spaces, and the like that are similarly arranged to memory 420 in the computing device of FIG.
- the program code can be compressed, for example, in an appropriate form.
- the storage unit includes computer readable code 431', ie, code readable by a processor, such as 410, that when executed by a computing device causes the computing device to perform each of the methods described above step.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
一种流数据的并发传输方法和装置,所述方法包括:分配第一类线程接收流数据,接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务,创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。上述技术方案使得将流数据传输至传输目的端直接在接收流数据的线程上完成,避免了接收流数据的线程要向多个发送流数据的线程转发流数据的问题,减少了线程间转发数据带来的性能消耗,同时也减少了响应时间。
Description
本发明涉及流数据传输技术领域,尤其涉及一种流数据的并发传输方法以及一种流数据的并发传输装置。
流数据为可以采用流式传输的方式在网络上传输的数据,大型网站系统经常依赖于内容分发网络(Content Delivery Network,CDN)对流数据进行传输,内容分发网络是通过在现有的网络中增加一层新的网络结构,使用户可以将数据传输到就近的节点上或从就近的节点获取所需的数据。在内容分发网络中,部署有传输节点,用于缓冲流数据,就近给用户提供服务。
在内容分发网络中的传输节点上,如果对于同一流数据存在多个连接,通常为每个连接随机分配一个线程,让其建立连接进行流数据的传输,以此来实现并发传输流数据。
然而在多个连接的情况下,接收流数据的线程就需要将流数据转发到多个连接所在的线程,线程间通信性能消耗大,且响应时间增长。
发明内容
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决或减缓上述问题的一种流数据的并发传输方法和相应的装置。
根据本发明的一个方面,提供了一种流数据的并发传输方法,包括:
分配第一类线程接收流数据,每个第一类线程对应接收一个流数据;
接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务;
创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,各传输通道对应承载一个传输任务;
调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。
根据本发明的另一方面,提供了一种流数据的并发传输装置,包括:
线程分配模块,用于分配第一类线程接收流数据,每个第一类线程对应接收一个流数据;
传输任务确定模块,用于接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务;
传输通道创建模块,用于创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,各传输通道对应承载一个传输任务;
传输任务调用模块,用于调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。
根据本发明的又一个方面,提供了一种计算机程序,其包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行如上文所述的流数据的并发传输方法。
根据本发明的再一个方面,提供了一种计算机可读介质,其中存储了上述的计算机程序。
本发明的有益效果为:
根据本发明的一种流数据的并发传输方法和装置通过分配第一类线程接收流数据,接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务,创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。使得将流数据传输至传输目的端直接是在接收流数据的线程上完成,避免了接收流数据的线程要向多个发送流数据的线程转发流数据的问题,减少了线程间转发数据带来的性能消耗,同时也减少了响应时间。
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:
图1示意性地示出了根据本发明实施例一的一种流数据的并发传输方法的步骤流程图示意图;
图2示意性地示出了根据本发明实施例二的一种流数据的并发传输方法的步骤流程图示意图;
图3示意性地示出了根据本发明实施例三的一种流数据的并发传输装置的结构框图;
图4示意性地示出了用于执行根据本发明的方法的计算设备的框图;以及;
图5示意性地示出了用于保持或者携带实现根据本发明的方法的程序代码的存储单元。
下面结合附图和具体的实施方式对本发明作进一步的描述。
参见图1,示出了根据本发明实施例一的一种流数据的并发传输方法的步骤流程图示意图,具体可以包括如下步骤:
步骤101,分配第一类线程接收流数据。
流数据为可以采用流式传输的方式在网络上传输的数据,流数据可以在客户端或服务器等网络设备间传输。在多线程环境下,需要分配相同或不同线程来处理流数据的接收、发送、存储等任务,来实现多个线程并发执行的技术。
在本发明实施例中,线程根据执行的不同任务被分为几类,其中,在线程池中分配线程来执行接收流数据的任务,将这种执行接收流数据任务的线程称为第一类线程,并且每个第一类线程对应接收一个流数据。
例如,在视频直播领域,利用内容分发网络来提供高性能、可扩展性及低成本的网络内容传递给用户。在内容分发网络中的用于传输流数据的服务器上,可以同时有多个接收流数据的任务,当有流数据接收请求被响应,分配一个第一类线程用于接收流数据,具体可以是在分配的第一类线程上执行与流数据发送端建立连接,并接收传输来的流数据。
步骤102,接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务。
传输请求为对目标流数据发起的传输请求,传输请求具体包括目标流数据、传输目的端、传输方式等信息,其中目标流数据为被请求传输的流数据,一个传输请求可以请求至少一个目标流数据,传输目的端为传输请求中指定的接收流数据的一端。传输任务为与传输目的端建立连接传输目标流数据的任务。
在本发明实施例中,接收到针对目标流数据的多个传输请求是指针对一个流数据有多个传输请求的情况,具体可以在随机的一个线程上接收传输请求,当接收到多个传输请求时,根据传输请求中的信息,确定各个传输请求 对应的传输目的端,并且创建各传输请求对应的各传输任务。
步骤103,创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道。
传输通道是指本地与传输目的端之间建立的用于执行传输数据的通道,具体可以用于字节缓冲区和为了通道另一边的数据实体执行传输数据。在本发明实施例中,传输通道可以是指Socket(Socket的英文原义是“孔”或“插座”。作为BSD UNIX的进程通信机制,也称“套接字”)连接,用于描述IP地址和端口,是一个通信链的句柄,可以用来实现不同虚拟机或不同计算机之间的通信。
在本发明实施例中,查找到正在接收传输任务的目标流数据的第一类线程,根据传输任务创建该第一类线程与各传输目的端之间的传输通道,各传输通道对应承载一个传输任务。
步骤104,调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。
在本发明实施例中,第一类线程上可以并发执行多个传输任务,其中每个传输任务对应将目标流数据通过创建的传输通道传输至各个传输目的端。在一定的硬件条件下,第一类线程上可以并发执行的传输任务的个数的最大值取决于传输任务消耗的CPU资源,具体可以为任意适用的个数,本发明对此不作限制。
综上所述,依据本发明实施例,通过分配第一类线程接收流数据,接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务,创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。使得将流数据传输至传输目的端直接是在接收流数据的线程上完成,避免了接收流数据的线程要向多个发送流数据的线程转发流数据的问题,减少了线程间转发数据带来的性能消耗,同时也减少了响应时间。
在本发明实施例中,优选地,在所述接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务之前,还可以包括步骤:调用第二类线程用于接收针对所有流数据的传输请求。
从线程池中调用线程,来接收针对所有流数据的传输请求,该线程可以称为第二类线程。具体可以为各个流数据的各个传输请求分别调用不同的线程来执行,本发明实施例对此不作限制。
在本发明实施例中,优选地,在所述创建接收所述目标流数据的第一类 线程与各个传输目的端之间的传输通道之前,还可以包括步骤:调用所述第二类线程将多个传输任务发送至所述第一类线程,所述传输任务携带对应的传输目的端的标识。
第二类线程接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务,然后将多个传输任务发送至传输任务对应的目标流数据的第一类线程,并且传输任务携带有对应的传输目的端的标识,例如传输目的端为服务器,标识可以包括服务器的网络地址。
在本发明实施例中,优选地,在所述调用所述第二类线程将多个传输任务发送至所述第一类线程之前,还可以包括步骤:识别各个传输请求对应请求的流数据为目标流数据,并确定接收所述目标流数据的线程为第一类线程。
传输请求携带有请求的目标流数据的标识,接收到各传输请求后,识别各传输请求对应请求的流数据,识别到流数据为目标流数据,并查找到接收目标流数据的线程,确定为第一类线程。
参见图2,示出了根据本发明实施例二的一种流数据的并发传输方法的步骤流程图示意图,具体可以包括如下步骤:
步骤201,针对待接收的流数据,从预置线程池随机选取一个线程作为第一类线程进行接收。
线程池是一种多线程处理形式,处理过程中将任务添加到队列,然后在创建线程后自动启动这些任务。线程池线程都是后台线程。每个线程都使用默认的堆栈大小,以默认的优先级运行,并处于多线程单元中。如果某个线程在托管代码中空闲(如正在等待某个事件),则线程池中将插入另一个辅助线程来使所有处理器保持繁忙。如果所有线程池线程都始终保持繁忙,但队列中包含挂起的工作,则线程池中将在一段时间后创建另一个辅助线程但线程的数目永远不会超过最大值。超过最大值的线程可以排队,但他们要等到其他线程完成后才启动。
在本发明实施例中,预置线程池为预先设置的用于处理流数据相关任务的线程池。从预置线程池中随机选取一个线程,用来接收待接收的流数据,作为第一类线程。
步骤202,调用第二类线程用于接收针对所有流数据的传输请求。
从线程池中调用线程,来接收针对所有流数据的传输请求,该线程可以称为第二类线程。具体可以为各个流数据的各个传输请求分别调用不同的线程来执行,本发明实施例对此不作限制。
步骤203,接收到针对目标流数据的多个传输请求时,确定各传输请求 对应的传输目的端并创建对应的传输任务。
在本发明实施例中,具体方式与其他实施例中描述一致,此处不做赘述。
步骤204,判断用于发送所述目标流数据的线程是否仅包括第一类线程。
在本发明实施例中,发送目标流数据的线程可以有多个,其中一个为第一类线程,其他发送目标流数据的线程可以是在第一类线程达到并发上限时,创建新的线程用于执行目标流数据的传输任务,在创建后将第一类线程中接收的流数据转发到新创建的线程上。判断当前用于发送目标流数据的线程是否仅包括第一类线程。
若用于发送所述目标流数据的线程仅包括第一类线程,则执行步骤205。
步骤205,判定所述第一类线程满足第一设定条件。
第一设定条件包括如下至少一种:对应创建的传输通道的总个数未超出设定个数、未超出设定负载量。获取在第一类线程上创建的传输通道的总个数,第一设定条件为总个数未超出设定个数、或者未超出设定负载量。
在本发明实施例中,获取目标流数据的第一类线程上创建的传输通道的总个数,根据总个数是否超出设定个数、或者超出设定负载量,判断第一类线程是否满足第一设定条件,且判定第一类线程满足第一设定条件。设定个数和设定负载量可以为任意适用的,本发明实施例对此不作限定。
在本发明实施例中,优选地,若所述第一类线程不满足第一设定条件,则创建第三类线程进行目标流数据的传输。
如果第一类线程不满足第一设定条件,也就是第一类线程上的传输通道的总个数超出设定个数或设定负载量,则创建线程来用于目标流数据的传输,创建的线程为第三类线程,创建第三类线程需要第一类线程将流数据转发到第三类线程上。
在本发明实施例中,优选地,所述创建第三类线程进行目标流数据的传输的一种实现方式为:从预置线程池中随机选取一个线程作为第三类线程;调用所述第三类线程从接收目标流数据的第一类线程获取目标流数据,并对目标流数据进行传输。
从预置线程池中随机选取一个线程作为第三类线程,调用第三类线程从第一类线程获取所需的目标流数据,并将目标流数据根据传输任务进行传输。
在本发明实施例中,优选地,若用于发送所述目标流数据的线程包括第一类线程和至少一个第三类线程,则在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,还可以包括步骤:在所述第一类线程和至少一个第三类线程中,选取满足第一设定条件的线程,并确定满足第一设定条件的线程为第一类线程,所述第一设定条件包括如下至少一 种:对应创建的传输通道的总个数未超出设定个数、未超出设定负载量。
如果用于发送目标流数据的线程包括第一类线程和至少一个第三类线程,在第一类线程和第三类线程中查找出满足第一设定条件的线程,第一设定条件包括如下至少一种:对应创建的传输通道的总个数未超出设定个数、未超出设定负载量。获取在第一类线程和第三类线程上分别创建的传输通道的总个数,第一设定条件为总个数未超出设定个数、或者未超出设定负载量。并且确定满足第一设定条件的线程为第一类线程,第三类线程都不满足第一设定条件。
在本发明实施例中,优选地,若确定满足第一设定条件的线程并非第一类线程,则调用满足第一设定条件的第三类线程进行目标流数据的传输。
具体而言,如果满足第一设定条件的线程不是第一类线程,那么就调用第三类线程进行目标流数据的传输,具体将传输任务发送到第三类线程上,在第三类线程上建立与传输目的端的连接,进行流数据的传输。
在本发明实施例中,优选地,若满足第一设定条件的线程包括第一类线程和至少一个第三类线程,则从第一类线程和至少一个第三类线程中随机选取一个线程,并确定随机选取的线程为第一类线程。
如果满足第一设定条件的线程包括第一类线程和至少一个第三类线程,则从第一类线程和至少一个第三类线程中随机选取一个线程,并且在一种情况下,随机选的线程为第一类线程,则用第一类线程来进行目标流数据的传输。
在本发明实施例中,优选地,若满足第一设定条件的线程包括第一类线程和至少一个第三类线程,则进一步确定满足第二设定条件的线程为第一类线程,所述第二设定条件包括如下至少一种:对应创建的传输通道的总个数最少、对应负载量最少。
第二设定条件为对应创建的传输通道的总个数最少、或者对应负载量最少。
若满足第一设定条件的线程包括第一类线程和至少一个第三类线程,还可以查找其中满足第二设定条件的线程,并且在一种情况下,满足第二设定条件的线程为第一类线程,则用第一类线程来进行目标流数据的传输。
在本发明实施例中,优选地,若所述第一类线程不满足第二设定条件,则调用满足第二设定条件的第三类线程进行目标流数据的传输。
如果第一类线程不满足第二设定条件,则查找到满足第二设定条件的第三类线程来进行目标流数据的传输,又满足第二设定条件的第三类线程与传输目的端建立连接,进行目标流数据的传输。
在本发明实施例中,优选地,若已有的第一类线程和第三类线程均不满足第一设定条件,则创建新的第三类线程。
如果已有的第一类线程和第三类线程均不满足第一设定条件,则创建新的第三类线程,将目标流数据又第一类线程转发到新创建的第三类线程上,将传输任务发送到新创建的第三类线程上,来根据传输任务完成目标流数据的传输。
步骤206,创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道。
在本发明实施例中,各传输通道对应承载一个传输任务。具体方式与其他实施例中描述一致,此处不做赘述。
步骤207,根据所建立的传输通道的个数,更新针对所述第一类线程记录的传输通道总个数。
在本发明实施例中,根据建立的传输通道的个数,更新针对第一类线程记录的传输通道总个数,具体可以是每有一个传输通道建立,就对第一类线程记录的传输通道总个数增加一。如果有传输任务完成或其他原因导致传输通道减少,则相应减少第一类线程记录的传输通道总个数。
步骤208,调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。
在本发明实施例中,具体方式与其他实施例中描述一致,此处不做赘述。
综上所述,依据本发明实施例,通过针对待接收的流数据,从预置线程池随机选取一个线程作为第一类线程进行接收,调用第二类线程用于接收针对所有流数据的传输请求,接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务,判断用于发送所述目标流数据的线程是否仅包括第一类线程,判定所述第一类线程满足第一设定条件,创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,根据所建立的传输通道的个数,更新针对所述第一类线程记录的传输通道总个数,调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。上述方案使得将流数据传输至传输目的端直接在接收流数据的线程上完成,避免了接收流数据的线程要向多个发送流数据的线程转发流数据的问题,减少了线程间转发数据带来的性能消耗,同时也减少了响应时间。
参照图3,示出了根据本发明实施例三的一种流数据的并发传输装置的结构框图,具体可以包括如下模块:
线程分配模块301,用于分配第一类线程接收流数据,每个第一类线程对应接收一个流数据;
传输任务确定模块302,用于接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务;
传输通道创建模块303,用于创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,各传输通道对应承载一个传输任务;
传输任务调用模块304,用于调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。
在本发明实施例中,优选地,所述装置还包括:
传输请求接收模块,用于在所述接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务之前,调用第二类线程用于接收针对所有流数据的传输请求。
在本发明实施例中,优选地,所述装置还包括:
传输任务发送模块,用于在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,调用所述第二类线程将多个传输任务发送至所述第一类线程,所述传输任务携带对应的传输目的端的标识。
在本发明实施例中,优选地,所述装置还包括:
流数据识别模块,用于在所述调用所述第二类线程将多个传输任务发送至所述第一类线程之前,识别各个传输请求对应请求的流数据为目标流数据,并确定接收所述目标流数据的线程为第一类线程。
在本发明实施例中,优选地,所述装置还包括:
线程判断模块,用于在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,判断用于发送所述目标流数据的线程是否仅包括第一类线程。
在本发明实施例中,优选地,所述装置还包括:
第一条件判定模块,用于若用于发送所述目标流数据的线程仅包括第一类线程,在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,判定所述第一类线程满足第一设定条件,所述第一设定条件包括如下至少一种:对应创建的传输通道的总个数未超出设定个数、未超出设定负载量。
在本发明实施例中,优选地,所述装置还包括:
第三线程创建模块,用于若所述第一类线程不满足第一设定条件,则创建第三类线程进行目标流数据的传输。
在本发明实施例中,优选地,所述第三线程创建模块包括:
第三线程选取子模块,用于从预置线程池中随机选取一个线程作为第三类线程;
流数据获取子模块,用于调用所述第三类线程从接收目标流数据的第一类线程获取目标流数据,并对目标流数据进行传输。
在本发明实施例中,优选地,所述装置还包括:
第一条件满足模块,用于若用于发送所述目标流数据的线程包括第一类线程和至少一个第三类线程,则在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,在所述第一类线程和至少一个第三类线程中,选取满足第一设定条件的线程,并确定满足第一设定条件的线程为第一类线程,所述第一设定条件包括如下至少一种:对应创建的传输通道的总个数未超出设定个数、未超出设定负载量。
在本发明实施例中,优选地,所述装置还包括:
第三线程调用模块,用于若确定满足第一设定条件的线程并非第一类线程,则调用满足第一设定条件的第三类线程进行目标流数据的传输。
在本发明实施例中,优选地,所述装置还包括:
线程随机模块,用于若满足第一设定条件的线程包括第一类线程和至少一个第三类线程,则从第一类线程和至少一个第三类线程中随机选取一个线程,并确定随机选取的线程为第一类线程。
在本发明实施例中,优选地,所述装置还包括:
第二条件满足模块,用于若满足第一设定条件的线程包括第一类线程和至少一个第三类线程,则进一步确定满足第二设定条件的线程为第一类线程,所述第二设定条件包括如下至少一种:对应创建的传输通道的总个数最少、对应负载量最少。
在本发明实施例中,优选地,所述装置还包括:
第三线程调用模块,用于若所述第一类线程不满足第二设定条件,则调用满足第二设定条件的第三类线程进行目标流数据的传输。
在本发明实施例中,优选地,所述装置还包括:
第三创建模块,用于若已有的第一类线程和第三类线程均不满足第一设定条件,则创建新的第三类线程。
在本发明实施例中,优选地,所述装置还包括:
个数更新模块,用于在所述创建所述第一类线程分别与各个传输目的端之间的传输通道之后,根据所建立的传输通道的个数,更新针对所述第一类线程记录的传输通道总个数。
在本发明实施例中,优选地,所述线程分配模块,具体用于针对待接收 的流数据,从预置线程池随机选取一个线程作为第一类线程进行接收。
综上所述,依据本发明实施例,通过分配第一类线程接收流数据,接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务,创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。上述方案使得将流数据传输至传输目的端直接在接收流数据的线程上完成,避免了接收流数据的线程要向多个发送流数据的线程转发流数据的问题,减少了线程间转发数据带来的性能消耗,同时也减少了响应时间。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的一种流数据的并发传输方法和装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。
例如,图4示出了可以实现根据本发明的流数据的并发传输计算设备,例如应用服务器。该计算设备传统上包括处理器410和以存储器420形式的计算机程序产品或者计算机可读介质。存储器420可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器420具有用于执行上述方法中的任何方法步骤的程序代码431的存储空间430。例如,用于程序代码的存储空间430可以包括分别用于实现上面的方法中的各种步骤的各个程序代码431。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图5所述的便携式或者固定存储单元。该存储单元可以具有与图4的计算设备中的存储器420类似布置的存储段、存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元包括计算机可读代码431’,即可以由例如诸如410之类的处理器读取的代码,这些代码当由计算设备运行时,导致该计算设备执行上面所描述的方法中的各个步骤。
本文中所称的“一个实施例”、“实施例”或者“一个或者多个实施例”意味着,结合实施例描述的特定特征、结构或者特性包括在本发明的至少一个实施例中。此外,请注意,这里“在一个实施例中”的词语例子不一定全指同一个实施例。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下被实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
此外,还应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所做的公开是说明性的,而非限制性的,本发明的范围由所附权利要求书限定。
Claims (34)
- 一种流数据的并发传输方法,包括步骤:分配第一类线程接收流数据,每个第一类线程对应接收一个流数据;接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务;创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,各传输通道对应承载一个传输任务;调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。
- 根据权利要求1所述的方法,其中,在所述接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务之前,所述方法还包括:调用第二类线程用于接收针对所有流数据的传输请求。
- 根据权利要求2所述的方法,其中,在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,所述方法还包括:调用所述第二类线程将多个传输任务发送至所述第一类线程,所述传输任务携带对应的传输目的端的标识。
- 根据权利要求3所述的方法,其中,在所述调用所述第二类线程将多个传输任务发送至所述第一类线程之前,所述方法还包括:识别各个传输请求对应请求的流数据为目标流数据,并确定接收所述目标流数据的线程为第一类线程。
- 根据权利要求1所述的方法,其中,在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,所述方法还包括:判断用于发送所述目标流数据的线程是否仅包括第一类线程。
- 根据权利要求5所述的方法,其中,若用于发送所述目标流数据的线程仅包括第一类线程,在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,所述方法还包括:判定所述第一类线程满足第一设定条件,所述第一设定条件包括如下至少一种:对应创建的传输通道的总个数未超出设定个数、未超出设定负载量。
- 根据权利要求6所述的方法,其中,所述方法还包括:若所述第一类线程不满足第一设定条件,则创建第三类线程进行目标流数据的传输。
- 根据权利要求7所述的方法,其中,所述创建第三类线程进行目标流数据的传输包括:从预置线程池中随机选取一个线程作为第三类线程;调用所述第三类线程从接收目标流数据的第一类线程获取目标流数据,并对目标流数据进行传输。
- 根据权利要求5所述的方法,其中,若用于发送所述目标流数据的线程包括第一类线程和至少一个第三类线程,则在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,所述方法还包括:在所述第一类线程和至少一个第三类线程中,选取满足第一设定条件的线程,并确定满足第一设定条件的线程为第一类线程,所述第一设定条件包括如下至少一种:对应创建的传输通道的总个数未超出设定个数、未超出设定负载量。
- 根据权利要求9所述的方法,其中,所述方法还包括:若确定满足第一设定条件的线程并非第一类线程,则调用满足第一设定条件的第三类线程进行目标流数据的传输。
- 根据权利要求9所述的方法,其中,所述方法还包括:若满足第一设定条件的线程包括第一类线程和至少一个第三类线程,则从第一类线程和至少一个第三类线程中随机选取一个线程,并确定随机选取的线程为第一类线程。
- 根据权利要求9所述的方法,其中,所述方法还包括:若满足第一设定条件的线程包括第一类线程和至少一个第三类线程,则进一步确定满足第二设定条件的线程为第一类线程,所述第二设定条件包括如下至少一种:对应创建的传输通道的总个数最少、对应负载量最少。
- 根据权利要求12所述的方法,其中,所述方法还包括:若所述第一类线程不满足第二设定条件,则调用满足第二设定条件的第三类线程进行目标流数据的传输。
- 根据权利要求7所述的方法,其中,所述方法还包括:若已有的第一类线程和第三类线程均不满足第一设定条件,则创建新的第三类线程。
- 根据权利要求1或6所述的方法,其中,在所述创建所述第一类线程分别与各个传输目的端之间的传输通道之后,所述方法还包括:根据所建立的传输通道的个数,更新针对所述第一类线程记录的传输通道总个数。
- 根据权利要求1所述的方法,其中,所述分配第一类线程接收流数据包括:针对待接收的流数据,从预置线程池随机选取一个线程作为第一类线程 进行接收。
- 一种流数据的并发传输装置,包括:线程分配模块,用于分配第一类线程接收流数据,每个第一类线程对应接收一个流数据;传输任务确定模块,用于接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务;传输通道创建模块,用于创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道,各传输通道对应承载一个传输任务;传输任务调用模块,用于调用所述第一类线程并发执行多个传输任务,将所述目标流数据通过对应的传输通道传输至各个传输目的端。
- 根据权利要求17所述的装置,其中,所述装置还包括:传输请求接收模块,用于在所述接收到针对目标流数据的多个传输请求时,确定各传输请求对应的传输目的端并创建对应的传输任务之前,调用第二类线程用于接收针对所有流数据的传输请求。
- 根据权利要求18所述的装置,其中,所述装置还包括:传输任务发送模块,用于在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,调用所述第二类线程将多个传输任务发送至所述第一类线程,所述传输任务携带对应的传输目的端的标识。
- 根据权利要求19所述的装置,其中,所述装置还包括:流数据识别模块,用于在所述调用所述第二类线程将多个传输任务发送至所述第一类线程之前,识别各个传输请求对应请求的流数据为目标流数据,并确定接收所述目标流数据的线程为第一类线程。
- 根据权利要求17所述的装置,其中,所述装置还包括:线程判断模块,用于在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,判断用于发送所述目标流数据的线程是否仅包括第一类线程。
- 根据权利要求21所述的装置,其中,所述装置还包括:第一条件判定模块,用于若用于发送所述目标流数据的线程仅包括第一类线程,在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,判定所述第一类线程满足第一设定条件,所述第一设定条件包括如下至少一种:对应创建的传输通道的总个数未超出设定个数、未超出设定负载量。
- 根据权利要求22所述的装置,其中,所述装置还包括:第三线程创建模块,用于若所述第一类线程不满足第一设定条件,则创建第三类线程进行目标流数据的传输。
- 根据权利要求23所述的装置,其中,所述第三线程创建模块包括:第三线程选取子模块,用于从预置线程池中随机选取一个线程作为第三类线程;流数据获取子模块,用于调用所述第三类线程从接收目标流数据的第一类线程获取目标流数据,并对目标流数据进行传输。
- 根据权利要求21所述的装置,其中,所述装置还包括:第一条件满足模块,用于若用于发送所述目标流数据的线程包括第一类线程和至少一个第三类线程,则在所述创建接收所述目标流数据的第一类线程与各个传输目的端之间的传输通道之前,在所述第一类线程和至少一个第三类线程中,选取满足第一设定条件的线程,并确定满足第一设定条件的线程为第一类线程,所述第一设定条件包括如下至少一种:对应创建的传输通道的总个数未超出设定个数、未超出设定负载量。
- 根据权利要求25所述的装置,其中,所述装置还包括:第三线程调用模块,用于若确定满足第一设定条件的线程并非第一类线程,则调用满足第一设定条件的第三类线程进行目标流数据的传输。
- 根据权利要求25所述的装置,其中,所述装置还包括:线程随机模块,用于若满足第一设定条件的线程包括第一类线程和至少一个第三类线程,则从第一类线程和至少一个第三类线程中随机选取一个线程,并确定随机选取的线程为第一类线程。
- 根据权利要求25所述的装置,其中,所述装置还包括:第二条件满足模块,用于若满足第一设定条件的线程包括第一类线程和至少一个第三类线程,则进一步确定满足第二设定条件的线程为第一类线程,所述第二设定条件包括如下至少一种:对应创建的传输通道的总个数最少、对应负载量最少。
- 根据权利要求28所述的装置,其中,所述装置还包括:第三线程调用模块,用于若所述第一类线程不满足第二设定条件,则调用满足第二设定条件的第三类线程进行目标流数据的传输。
- 根据权利要求23所述的装置,其中,所述装置还包括:第三创建模块,用于若已有的第一类线程和第三类线程均不满足第一设定条件,则创建新的第三类线程。
- 根据权利要求17或22所述的装置,其中,所述装置还包括:个数更新模块,用于在所述创建所述第一类线程分别与各个传输目的端 之间的传输通道之后,根据所建立的传输通道的个数,更新针对所述第一类线程记录的传输通道总个数。
- 根据权利要求17所述的装置,其中,所述线程分配模块,具体用于针对待接收的流数据,从预置线程池随机选取一个线程作为第一类线程进行接收。
- 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行根据权利要求1-16中的任一个所述的流数据的并发传输方法。
- 一种计算机可读介质,其中存储了如权利要求33所述的计算机程序。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710002598.1A CN106790632B (zh) | 2017-01-03 | 2017-01-03 | 一种流数据的并发传输方法和装置 |
CN201710002598.1 | 2017-01-03 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2018127013A1 true WO2018127013A1 (zh) | 2018-07-12 |
Family
ID=58949391
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2017/120143 WO2018127013A1 (zh) | 2017-01-03 | 2017-12-29 | 一种流数据的并发传输方法和装置 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN106790632B (zh) |
WO (1) | WO2018127013A1 (zh) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106790632B (zh) * | 2017-01-03 | 2020-07-14 | 北京奇虎科技有限公司 | 一种流数据的并发传输方法和装置 |
CN111026543B (zh) * | 2019-10-31 | 2023-06-16 | 北京浪潮数据技术有限公司 | 一种存储系统转发数据的方法、装置、设备及介质 |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110225302A1 (en) * | 2010-03-12 | 2011-09-15 | Park Anthony N | Parallel streaming |
CN104283694A (zh) * | 2013-07-02 | 2015-01-14 | 北京邮电大学 | 基于ip组播及p2p补偿的流媒体传输方法 |
CN104346135A (zh) * | 2013-08-08 | 2015-02-11 | 腾讯科技(深圳)有限公司 | 数据流并行处理的方法、设备及系统 |
CN104539727A (zh) * | 2015-01-15 | 2015-04-22 | 北京国创富盛通信股份有限公司 | 一种基于ap平台的缓存方法和系统 |
US20150281114A1 (en) * | 2014-03-28 | 2015-10-01 | Akamai Technologies, Inc. | Systems and methods for allocating work for various types of services among nodes in a distributed computing system |
CN106790632A (zh) * | 2017-01-03 | 2017-05-31 | 北京奇虎科技有限公司 | 一种流数据的并发传输方法和装置 |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104572290A (zh) * | 2013-10-11 | 2015-04-29 | 中兴通讯股份有限公司 | 消息处理线程的控制方法及装置 |
US9575825B2 (en) * | 2014-12-23 | 2017-02-21 | International Business Machines Corporation | Push instruction for pushing a message payload from a sending thread to a receiving thread |
CN105045681A (zh) * | 2015-07-10 | 2015-11-11 | 上海爱数软件有限公司 | 一种Oracle多通道并行备份及恢复方法 |
CN105162634B (zh) * | 2015-09-24 | 2018-05-15 | 成都广达新网科技股份有限公司 | 在同一线程中收发oam协议包的处理方法 |
CN106095597B (zh) * | 2016-05-30 | 2017-09-26 | 深圳市鼎盛智能科技有限公司 | 客户端数据处理方法及装置 |
-
2017
- 2017-01-03 CN CN201710002598.1A patent/CN106790632B/zh active Active
- 2017-12-29 WO PCT/CN2017/120143 patent/WO2018127013A1/zh active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110225302A1 (en) * | 2010-03-12 | 2011-09-15 | Park Anthony N | Parallel streaming |
CN104283694A (zh) * | 2013-07-02 | 2015-01-14 | 北京邮电大学 | 基于ip组播及p2p补偿的流媒体传输方法 |
CN104346135A (zh) * | 2013-08-08 | 2015-02-11 | 腾讯科技(深圳)有限公司 | 数据流并行处理的方法、设备及系统 |
US20150281114A1 (en) * | 2014-03-28 | 2015-10-01 | Akamai Technologies, Inc. | Systems and methods for allocating work for various types of services among nodes in a distributed computing system |
CN104539727A (zh) * | 2015-01-15 | 2015-04-22 | 北京国创富盛通信股份有限公司 | 一种基于ap平台的缓存方法和系统 |
CN106790632A (zh) * | 2017-01-03 | 2017-05-31 | 北京奇虎科技有限公司 | 一种流数据的并发传输方法和装置 |
Also Published As
Publication number | Publication date |
---|---|
CN106790632A (zh) | 2017-05-31 |
CN106790632B (zh) | 2020-07-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109688235B (zh) | 虚拟网络业务处理方法、装置和系统,控制器,存储介质 | |
US8090790B2 (en) | Method and system for splicing remote direct memory access (RDMA) transactions in an RDMA-aware system | |
JP3382953B2 (ja) | 有限メモリコンピュータシステム上におけるクライアント管理フロー制御方法及び装置 | |
US9264369B2 (en) | Technique for managing traffic at a router | |
CN113132489A (zh) | 下载文件的方法、装置、计算设备和介质 | |
WO2017041398A1 (zh) | 数据传输方法和装置 | |
JP2009251708A (ja) | I/oノード制御方式及び方法 | |
EP2755363A1 (en) | Data-fast-distribution method and device | |
CN105577801A (zh) | 一种业务加速方法及装置 | |
CN112491066B (zh) | 负载均衡方法、装置、系统、目标负载均衡设备及介质 | |
CN114153581B (zh) | 数据处理方法、装置、计算机设备和存储介质 | |
US10212259B2 (en) | Management of transmission control blocks (TCBs) supporting TCP connection requests in multiprocessing environments | |
US6934761B1 (en) | User level web server cache control of in-kernel http cache | |
CN103166845A (zh) | 数据处理方法和装置 | |
US10154116B1 (en) | Efficient synchronization of locally-available content | |
CN118200253A (zh) | 面向rdma ud传输的可靠通信方法、电子设备及可读介质 | |
WO2018127013A1 (zh) | 一种流数据的并发传输方法和装置 | |
WO2020124726A1 (zh) | 音视频流分发系统中的音视频流分发方法及动态父节点 | |
CN110290009B (zh) | 一种数据调度方法、装置及计算机可读存储介质 | |
US6668279B1 (en) | User level web server in-kernel network I/O accelerator | |
CN107294911A (zh) | 一种数据包监听方法及装置、远程过程调用系统、设备 | |
CN104394095A (zh) | 数据传输方法、系统及源服务器 | |
CN111756649A (zh) | 一种数据传输方法、装置、设备及计算机可读存储介质 | |
CN116074553B (zh) | 视频流传输方法、装置、电子设备及存储介质 | |
JP2002342193A (ja) | データ転送先サーバ選定方法及び装置及びデータ転送先サーバ選定プログラム及びデータ転送先サーバ選定プログラムを格納した記憶媒体 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17890253 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 17890253 Country of ref document: EP Kind code of ref document: A1 |