WO2015096656A1 - 线程创建方法、业务请求处理方法及相关设备 - Google Patents

线程创建方法、业务请求处理方法及相关设备 Download PDF

Info

Publication number
WO2015096656A1
WO2015096656A1 PCT/CN2014/094208 CN2014094208W WO2015096656A1 WO 2015096656 A1 WO2015096656 A1 WO 2015096656A1 CN 2014094208 W CN2014094208 W CN 2014094208W WO 2015096656 A1 WO2015096656 A1 WO 2015096656A1
Authority
WO
WIPO (PCT)
Prior art keywords
queue
network card
thread
created
bound
Prior art date
Application number
PCT/CN2014/094208
Other languages
English (en)
French (fr)
Inventor
沈晴霓
李才
郭明宇
张甜
陈克平
蔡毅
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP14873894.1A priority Critical patent/EP3073374B1/en
Publication of WO2015096656A1 publication Critical patent/WO2015096656A1/zh
Priority to US15/191,996 priority patent/US20160306680A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3017Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is implementing multitasking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • G06F11/3093Configuration details thereof, e.g. installation, enabling, spatial arrangement of the probes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/865Monitoring of software

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a thread creation method, a service request processing method, and related devices.
  • multi-core operating systems based on many-core processors are also evolving.
  • each hardware core has its own kernel and does not share memory, which is different from existing Windows and Linux kernel-based operating systems.
  • the communication between the kernels is better than the traditional shared memory in the case of a large number of cores through message passing.
  • the letter method can make full use of many core processing chips.
  • applications based on multi-core operating systems such as Barrelfish-based Haskell compilers, virtual machines, and so on. In a nuclear environment, their performance is significantly higher than traditional operating systems.
  • the current Web server software is a process thread model for the operating system, using a specific way to create and manage process threads for multitasking management, thereby responding to concurrent requests. If the existing multitasking management method is directly applied to the multi-core operating system, it will lead to unnecessary system overhead, which will not be able to play the superiority of the multi-core environment.
  • Prefork implements a non-threaded, pre-derived web server.
  • a separate control process (parent process) is responsible for generating child processes that are used to listen for requests and respond. Moreover, the web server always tries to keep some spare or idle child processes, ready to process the incoming request, so that the client does not need to wait for the child process before getting the service, so as to improve The processing efficiency of the request.
  • Too many processes will occupy too many unnecessary system resources, waste the space resources of the system, increase the overhead of the operating system scheduling process, waste the time resources of the system, and use the process to complete the processing of the request, without Taking advantage of threads is costly.
  • multiple processes can be created, for example, process 1 to process 4, and a thread created under one process can include a listener and multiple workers, and each Threads are randomly scheduled to idle hardware cores, such as hardware core 1 to hardware core 8 in Figure 1.
  • multiple listening threads of multiple processes request the system to compete for a lock, and can only listen after the request is locked, and assign the intercepted business request to the same process as itself. Idle worker thread.
  • the embodiment of the present invention provides a thread creation method, a service request processing method, and related devices, which are used to solve the problem that the thread creation is unreasonable in the prior art, and thus the server is less efficient in processing concurrent service requests.
  • the problem is not limited to:
  • the first aspect provides a thread creation method, which is applied to a server having a multi-queue network card, where the network card queue of the multi-queue network card stores a service request from a client, including:
  • Each listener thread created is bound to a different NIC queue.
  • the server has multiple hardware core processors
  • Each listener thread created is bound to a different NIC queue, including:
  • Each of the created listening threads is respectively bound to a different target hardware core in the multiple hardware core processors, and each of the multi-queue network cards is respectively different from the hardware core in the target hardware core. Binding, so that each of the listening threads that are created is bound to a different network card queue; wherein the target hardware core is used to bind the listening thread and the network card queue in the multiple hardware core processor. For all hardware cores, the number of NIC queues is equal to the number of target hardware cores.
  • the method further includes:
  • the hardware cores bound by the worker threads created in different processes are different.
  • the method further includes:
  • Also includes:
  • the listener thread created in the new process is bound to the newly added NIC queue.
  • Also includes:
  • the worker thread in the idle state is revoked in the process, and the worker thread created in the process is in the process thread after the cancellation
  • the number of worker threads in the idle state is not greater than the second preset number threshold.
  • the second aspect provides a service request processing method, which is applied to a multi-queue network card of a server, where a service card request from a client is stored in a network card queue of the multi-queue network card, and a network card with the multi-queue network card is created on the server.
  • the number of queues is equal to the number of processes, and one listener thread and multiple worker threads are created in each process, and each listener thread created is bound to a different network card queue, and the method includes:
  • the multi-queue network card obtains a service request from a client from its own network card queue
  • the method before obtaining the service request from the client from the NIC queue of the user, the method further includes:
  • the server has multiple hardware core processors, and each of the created listening threads is respectively bound to a different target hardware core in the multiple hardware core processors.
  • Each of the plurality of queued network cards is bound to a different hardware core in the target hardware core, so that each of the created listening threads is respectively bound to a different network card queue;
  • the target hardware is a core of the plurality of hardware core processors for binding the listening thread and the network card queue, the number of the network card queues being equal to the number of the target hardware cores;
  • Sending the service request to a listening thread bound to the NIC queue including:
  • the service request is sent to a listening thread running on a target hardware core bound to the NIC queue.
  • the worker thread created in each process is bound to a hardware core.
  • the hardware cores bound by the worker threads created in different processes are different.
  • the third aspect provides a service request processing method, which is applied to a listening thread created on a server, where the server has a multi-queue network card, and the network card queue of the multi-queue network card stores a service request from a client, and the server creates There are a number of processes equal to the number of network card queues of the multi-queue network card, and one listener thread and multiple worker threads are created in each process, and each of the created listener threads is respectively bound with a different network card queue, Methods include:
  • the listening thread receives the service request from the client that is obtained by the multi-queue network card of the server and is obtained from the network card queue bound to the listening thread;
  • the method before receiving the service request from the client that is sent by the multi-queue network card of the server and received from the network card queue bound to the monitoring thread, the method further includes:
  • the server has multiple hardware core processors, and each of the created listening threads is respectively bound to a different target hardware core in the multiple hardware core processors.
  • Each of the plurality of queued network cards is bound to a different hardware core in the target hardware core, so that each of the created listening threads is respectively bound to a different network card queue;
  • the target hardware is a core of the plurality of hardware core processors for binding the listening thread and the network card queue, the number of the network card queues being equal to the number of the target hardware cores;
  • the listening thread receives the service request from the client that is sent by the multi-queue network card of the server and is obtained from the network card queue bound to the listening thread, and includes:
  • the listener thread receives a service request from the client that is obtained by the multi-queue network card of the server and is obtained from a network card queue bound to a target hardware core running the interception thread.
  • the worker thread created in each process is bound to a hardware core.
  • the hardware cores bound by the worker threads created in different processes are different.
  • the implementation manner, in the fifth possible implementation manner further includes:
  • the worker thread in the idle state is revoked in the process, and the work created in the process is revoked
  • the number of worker threads in the idle state in the thread is not greater than the second preset number threshold.
  • a thread creation apparatus for a server having a multi-queue network card,
  • the network card queue of the multi-queue network card stores the service request from the client, including:
  • a quantity obtaining unit configured to acquire a number of network card queues of the multi-queue network card of the server
  • a process creation unit configured to create an equal number of processes with the number of NIC queues
  • a thread creation unit for creating a listener thread and a plurality of worker threads in each process
  • Binding unit which is used to bind each of the created listening threads to different NIC queues.
  • the server has multiple hardware core processors
  • the binding unit is specifically configured to bind each of the created listening threads to different target hardware cores in the multiple hardware core processors, and respectively configure each network card queue in the multi-queue network card Different hardware core bindings in the target hardware core, so that each of the listening threads created is bound to a different network card queue; wherein the target hardware core is used in the multi-hardware core processor for binding The listening thread and all hardware cores of the network card queue, the number of the network card queues being equal to the number of the target hardware cores.
  • the binding unit is further configured to bind a worker thread created in each process to a hardware core.
  • the hardware cores bound by the worker threads created in different processes are different.
  • the thread The creating unit is further configured to: when the hardware core of the multi-hardware core processor of the server increases, create a new worker thread in a process for each added hardware core;
  • the binding unit is further configured to bind the created new worker thread to the newly added hardware core.
  • the process creation unit is further configured to: when the NIC queue of the multi-queue network card of the server increases, create a new process for each added NIC queue;
  • the thread creation unit is further configured to create a listener thread and a worker thread in the created new process
  • the binding unit is further configured to bind the monitoring thread created in the new process to the newly added NIC queue.
  • the thread creation unit is further configured to create a new worker thread in the process when the number of worker threads in the idle state created in the process is less than the first preset number threshold;
  • the worker thread in the idle state is revoked in the process, and the work created in the process is revoked
  • the number of worker threads in the idle state in the thread is not greater than the second preset number threshold.
  • a fifth aspect provides a service request processing apparatus, which is applied to a multi-queue network card of a server, wherein a network card queue of the multi-queue network card stores a service request from a client, and a network card with the multi-queue network card is created on the server.
  • the number of queues is equal to the number of processes, and one listener thread and multiple worker threads are created in each process, and each listener thread created is bound to a different network card queue, and the device includes:
  • a service request obtaining unit configured to obtain a service request from a client from a network card queue of the multi-queue network card
  • a first sending unit configured to send the service request to a listening thread bound to the network card queue
  • a receiving unit configured to receive a service processing result sent by a worker thread that belongs to the same process as the listening thread after performing service processing on the service request;
  • a second sending unit configured to return the service processing result to the client.
  • the receiving unit is further configured to: before the service request obtaining unit acquires a service request from a client in a network card queue of the multi-queue network card, receive a service request acquisition message sent by each of the created listening threads, the service The request to obtain the queue identifier of the network card queue bound by the monitoring thread;
  • the device further includes:
  • the binding relationship determining unit is configured to determine that the listening thread that sends the service request obtaining message is bound to the network card queue corresponding to the queue identifier carried in the service request obtaining message.
  • the server has multiple hardware core processors, and each of the created listening threads is respectively bound to a different target hardware core in the multiple hardware core processors, Each of the plurality of queued network cards is bound to a different hardware core in the target hardware core, so that each of the created listening threads is respectively bound to a different network card queue; wherein the target hardware is a core of the plurality of hardware core processors for binding the listening thread and the network card queue, the number of the network card queues being equal to the number of the target hardware cores;
  • the first sending unit is specifically configured to send the service request to a listening thread running on a target hardware core bound to the network card queue.
  • the worker thread created in each process is bound to a hardware core.
  • the hardware cores bound by the worker threads created in different processes are different.
  • a service request processing apparatus which is applied to a listening thread created on a server, wherein the server has a multi-queue network card, and a network card queue of the multi-queue network card stores a service request from a client, and the server creates There are a number of processes equal to the number of network card queues of the multi-queue network card, and one listener thread and multiple worker threads are created in each process, and each of the created listener threads is respectively bound with a different network card queue,
  • the device includes:
  • a receiving unit configured to receive, by the multi-queue network card of the server, a service request from a client obtained from a network card queue bound to the listening thread;
  • a first sending unit configured to send the service request to a working thread in an idle state that belongs to the same process as the listening thread, to instruct the worker thread to perform service processing on the service request, and process the obtained service
  • the result is sent to the multi-queue network card.
  • the method further includes:
  • a second sending unit configured to send a service to the multi-queue network card before the receiving unit receives a service request from the client that is sent by the multi-queue network card of the server from a network card queue bound to the monitoring thread And obtaining a message, where the service request acquisition message carries a queue identifier of the network card queue bound by the monitoring thread, and the multi-queue network card determines that the monitoring thread is bound to the network card queue corresponding to the queue identifier.
  • the server has multiple hardware core processors, and each of the created listening threads is respectively bound to a different target hardware core in the multiple hardware core processors, Each of the plurality of queued network cards is bound to a different hardware core in the target hardware core, so that each of the created listening threads is respectively bound to a different network card queue; wherein the target hardware is a core of the plurality of hardware core processors for binding the listening thread and the network card queue, the number of the network card queues being equal to the number of the target hardware cores;
  • the receiving unit is configured to receive, by the multi-queue network card of the server, a service request from a client that is obtained from a network card queue bound to a target hardware core that runs the listening thread.
  • the worker thread created in each process is bound to a hardware core.
  • the hardware cores bound by the worker threads created in different processes are different.
  • a thread creation unit configured to create a new worker thread in the process when the number of worker threads in the idle thread created in the process to which the listener thread belongs is less than the first preset number threshold;
  • the number of worker threads that are idle in the worker thread created in the process after the revocation is not greater than the second preset number threshold.
  • a server including:
  • a multi-queue network card for receiving a service request from a client and storing a service request from the client in its own network card queue
  • a processor configured to acquire a number of network card queues of the multi-queue network card of the server; and create a process equal to the number of the network card queues; and create a listening thread and multiple working threads in each process; Each listener thread created is bound to a different NIC queue.
  • the processor is a multi-hardware core processor
  • a processor specifically configured to bind each of the created listening threads to different target hardware cores in the multiple hardware core processors, and each of the multi-queue network card queues and the target hardware respectively Different hardware cores in the core are bound, so that each of the listening threads that are created is respectively bound to a different network card queue; wherein the target hardware core is used to bind the listening thread in the multiple hardware core processor And all hardware cores of the network card queue, the number of the network card queues being equal to the number of the target hardware cores.
  • the processor is further configured to bind a worker thread created in each process to a hardware core.
  • the hardware cores bound by the worker threads created in different processes are different.
  • the processor Also used to create a new worker thread in one process for each added hardware core when the hardware core of the multi-hardware core processor of the server is increased; and to create a new worker thread with the newly added Hardware core binding.
  • the processor is further configured to: when the NIC queue of the multi-queue NIC of the server increases, create a new process for each added NIC queue; and create a listening thread and multiple working threads in the created new process. ; and bind the listener thread created in the new process to the newly added NIC queue.
  • the processor is further configured to create a new worker thread in the process when the number of worker threads in the worker thread created in a process is less than the first preset number threshold;
  • the worker thread in the idle state is revoked in the process, and the worker thread created in the process is in the process thread after the cancellation
  • the number of worker threads in the idle state is not greater than the second preset number threshold.
  • a multi-queue network card of a server where a number of processes equal to the number of network card queues of the multi-queue network card are created, and one listening thread and multiple working threads are created in each process. Each of the created listening threads is bound to a different network card queue, and the multi-queue network card includes:
  • An interface configured to receive a service request from a client, and store the request in a network card queue
  • Processing a chip configured to obtain a service request from a client from a network card queue of the multi-queue network card; and send the service request to a listening thread bound to the network card queue; and receive a worker thread pair that belongs to the same process as the monitoring thread Transmitting, by the service, a service processing result sent after the service processing; and returning the service processing result to the client;
  • a memory for storing a service request from a client in a network card queue.
  • the processing chip is further configured to: before receiving the service request from the client in the network card queue of the multi-queue network card, receive the service request separately sent by each of the created listening threads. Obtaining a message, where the service request acquisition message carries a queue identifier of a network card queue bound by a monitoring thread;
  • the NIC queue corresponding to the queue identifier is bound.
  • the server has multiple hardware core processors, and each of the created listening threads is respectively bound to a different target hardware core in the multiple hardware core processors, Each of the plurality of queued network cards is bound to a different hardware core in the target hardware core, so that each of the created listening threads is respectively bound to a different network card queue; wherein the target hardware is a core of the plurality of hardware core processors for binding the listening thread and the network card queue, the number of the network card queues being equal to the number of the target hardware cores;
  • the processing chip is specifically configured to send the service request to a listening thread running on a target hardware core bound to the network card queue.
  • the worker thread created in each process is bound to a hardware core.
  • the hardware cores bound by the worker threads created in different processes are different.
  • the solution provided by the embodiment of the present invention is applied to a server having a multi-queue network card, where the network card queue of the multi-queue network card stores a service request from the client, and when the server creates a process and a thread after the startup, the number of the network card queue is equal to the number of the network card queue.
  • FIG. 1 is a schematic diagram of multi-process and multi-threading created by using the worker method in the prior art
  • FIG. 2 is a flowchart of a thread creation method provided in Embodiment 1 of the present invention.
  • FIG. 3 is a second flowchart of a thread creation method according to Embodiment 1 of the present invention.
  • FIG. 5 is a schematic diagram of a process and a network card queue bound in Embodiment 1 of the present invention.
  • FIG. 6 is a flowchart of a process of creating a new thread when a hardware core is added in Embodiment 1 of the present invention
  • FIG. 7 is a flowchart of processing for creating a new process and a new thread when a network card queue of a multi-queue network card is increased according to Embodiment 1 of the present invention
  • FIG. 8 is a flowchart of a service request processing method for a multi-queue network card applied to a server according to Embodiment 2 of the present invention.
  • FIG. 9 is a flowchart of a service request processing method applied to a listening thread according to Embodiment 2 of the present invention.
  • FIG. 10 is a flowchart of a service request processing method according to Embodiment 2 of the present invention.
  • FIG. 11 is a schematic structural diagram of a thread creation apparatus according to Embodiment 3 of the present invention.
  • FIG. 12 is a schematic structural diagram of a service request processing apparatus according to Embodiment 4 of the present invention.
  • FIG. 13 is a schematic structural diagram of a service request processing apparatus according to Embodiment 5 of the present invention.
  • FIG. 14 is a schematic structural diagram of a server according to Embodiment 6 of the present invention.
  • FIG. 15 is a schematic structural diagram of a multi-queue network card according to Embodiment 7 of the present invention.
  • the embodiment of the present invention provides a thread creation method, a service request processing method, and related devices.
  • the preferred embodiments of the invention are to be considered as illustrative and not restrictive. And in the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
  • the embodiment 1 of the present invention provides a thread creation method, which is applied to a server having a multi-queue network card, and the service card request from the client is stored in the network card queue of the multi-queue network card, as shown in FIG. 2, including:
  • Step 201 Obtain a number of network card queues of the server's multi-queue network card.
  • Step 202 Create an equal number of processes with the number of network card queues.
  • Step 203 Create a listener thread and multiple worker threads in each process.
  • Step 204 Bind each of the created listening threads to different network card queues.
  • the number of processes created is equal to the number of network card queues, and the listening threads created in the process are bound to different network card queues, so that the service requests in each network card queue can be subsequently assigned to the thread.
  • the listening thread of the NIC queue is processed by the listening thread, thereby avoiding multiple listening threads competing for a lock, which makes the creation of processes and threads more reasonable.
  • Each of the created listening threads is bound to a different target hardware core in the multi-hardware core processor, and each NIC queue in the multi-queue NIC is respectively bound to a different hardware core in the target hardware core, thereby realizing creation.
  • Each listening thread is bound to a different network card queue; wherein the target hardware core is all hardware cores in the multi-hardware core processor for binding the listening thread and the network card queue, and the number of network card queues is equal to the number of target hardware cores. .
  • the worker thread created in each process may be bound to a hardware core, and the hardware cores bound by the worker threads created in different processes are different, so that each thread is randomly scheduled to be idle compared to the prior art.
  • the solution on the hardware core reduces the overhead of thread scheduling, making even a large amount of The thread does not cause a significant drop in server performance due to thread scheduling on the hardware core.
  • the hardware core of the multi-hardware core processor of the server can also be obtained, and the binding is performed based on the hardware core number, so that each process is created in each process.
  • the number of hardware threads bound to the listening thread and the worker thread created in different processes is not more than one, so as to maximize the processing power of each hardware core and improve the server to concurrent services. The overall processing performance of the request.
  • the hardware core of the multi-hardware core processor may be added, the network card queue of the multi-queue network card may be increased, the new process and the thread may be created correspondingly, and the working thread in the idle state may also be targeted.
  • Step 301 After the server is started, obtain the number of network card queues of the server's multi-queue network card.
  • Step 302 Further, the hardware core of the multi-hardware core processor of the server may also be obtained.
  • step 301 There is no strict sequence between step 301 and step 302.
  • Step 303 Create an equal number of processes with the number of network card queues.
  • the number of network card queues of the server's multi-queue network card is 4, and according to the maximum parallel principle, a process equal to the number of network card queues is created, that is, process 1 - process 4.
  • Step 304 Create a listener and a worker in each process.
  • a listening thread and multiple working threads can be created in each process, wherein the number of multiple working threads can be based on the actual application scenario of the server, for example, expected throughput. The number of concurrent service requests and response time requirements, as well as the actual physical hardware processing capabilities of the server.
  • the initial state is idle, and when it subsequently receives the service request, In the process of business processing of a business request, its state is a working state.
  • Step 305 Bind each of the created listening threads to different network card queues.
  • the number of listener threads created is the same as the number of network card queues, and multiple monitor threads of equal number can be bound to multiple network card queues one by one, as shown in FIG.
  • the listening thread 1 - the listening thread 4 respectively created in the process 1 - process 4 are respectively bound in the network card queue 1 - the network card queue 4 one by one.
  • multiple target hardware cores equal to the number of network card queues can be selected from the hardware cores of the multiple hardware core processors, and each of the created monitoring threads is different from each other.
  • the target hardware core is bound, and each NIC queue in the multi-queue NIC is respectively bound to a different target hardware core, so that each of the created listening threads is respectively bound to a different NIC queue.
  • the worker thread created in each process may be bound to a hardware core, and the hardware cores bound by the worker threads created in different processes are different, so that the listening thread and the worker thread are fixedly bound by themselves.
  • the hardware core runs, avoiding system resources consumed by multiple hardware cores randomly scheduling the listening thread and the worker thread, and improving processing efficiency.
  • the maximum number of service requests processed by multiple hardware cores may be maximized, and the listening threads and jobs created in different processes may be made according to the hardware cores of multiple hardware core processors.
  • the number of thread-bound hardware cores differs by no more than one.
  • the multi-hardware core processor of the server has a hardware core of 8, and the number of created processes is four, and each process can allocate a hardware core for binding to the listening thread and the worker thread, and the process 1
  • the corresponding hardware core includes a hardware core 1 and a hardware core 2.
  • the hardware core corresponding to the process 2 includes a hardware core 3 and a hardware core 4.
  • the hardware core corresponding to the process 3 includes a hardware core 5 and a hardware core 6.
  • the hardware core corresponding to the process 4 includes Hardware core 7 and hardware core 8.
  • the listening thread and part of the working thread created in the process 1 are bound to the hardware core 1, and the remaining working threads are bound to the hardware core 2, and the binding threads created by the process 2 - process 3 and the binding relationship between the worker thread and the hardware core, such as Figure 4 shows.
  • the multi-queue network card port allocation requires comprehensive support of the physical hardware, the operating system, and the upper layer application.
  • multi-queue NICs can receive network packets from Ethernet in parallel.
  • the operating system obtains network packets through the network card driver, packages and delivers them to the module responsible for network distribution. In traditional operating systems, this process is usually done by kernel modules, and in multi-core operating systems, this task is primarily done by a service running in user mode. The service distributes the network packet to the running listening thread on the physical hardware core, and the listening thread parses the transaction logic, and then performs corresponding forwarding processing according to the state.
  • Concurrent request processing is the core function of the multitasking management system.
  • the smallest unit that processes the multitasking is a thread.
  • these worker threads are fixedly bound to the corresponding hardware core and do not need to be scheduled.
  • the worker thread can be saved in the work queue and the idle queue according to whether the current state is in a working state or an idle state. After the initial deployment is complete, all worker threads are in the idle queue.
  • a listener thread in a process that is responsible for listening to a service request receives a service request, it triggers a processing event.
  • an idle worker thread is fetched in the idle queue, and the listener thread hands the business request from the client to the worker thread for processing.
  • the worker thread is sent to the work queue to process the task. After the processing is finished, it is automatically taken out from the work queue, enters the idle queue, and returns to the idle state. Changes in state can be accomplished by triggering different events.
  • the same number of the plurality of listening threads that are created in the same number as the number of the network card queues are respectively associated with the network card queues, and are used for subsequently receiving the services from the client in the bound network card queue.
  • the request is distributed to the worker thread in the idle state that belongs to the same process for business processing, thereby making the process and thread creation more reasonable, so as to improve the processing efficiency of the server for concurrent business requests.
  • each listener thread and worker thread created can also be bound to a hardware core and fixedly run by the bound hardware core, thereby avoiding system resources consumed by the plurality of hardware cores randomly scheduling the listener thread and the worker thread, and Increased processing efficiency.
  • the processing power of the server is extended. For example, when the computing power of the server needs to be increased, the number of hardware cores can be expanded. When the network throughput needs to be increased, the number of network card queues of the multi-queue network card can be expanded.
  • Figure 6 shows the process of creating a new thread when the hardware core is added, including:
  • Step 601 When the hardware core of the multi-hardware core processor of the server increases, a new worker thread is created in one process for each added hardware core.
  • Step 602 Bind the created new worker thread to the newly added hardware core.
  • Figure 7 shows the process of creating a new process and a new thread when the NIC queue of the multi-queue NIC is added.
  • the details include:
  • Step 701 When the NIC queue of the multi-queue network card of the server increases, a new process is created for each added NIC queue.
  • Step 702 Create a listener thread and multiple worker threads in the created new process.
  • Step 703 Bind the listening thread created in the new process to the newly added NIC queue.
  • a hardware core other than the target hardware core of the multiple hardware core processor may be selected as a new target hardware core, and the monitoring thread created in the new process is bound to the new target hardware core.
  • the newly added NIC queue is bound to the new target hardware core, so that the monitoring thread created in the new process is bound to the newly added NIC queue.
  • the worker thread created in the new process may be bound to a hardware core. If there is a newly added hardware core at this time, it may be bound to the newly added hardware core, if there is no newly added hardware.
  • the core can unbind a working thread bound to the original hardware core and bind the original hardware core to the worker thread created in the new process.
  • the server can perform business processing on the service request from the client, and the state of the worker thread is in the working state during the processing. Switching from idle state, currently working line in idle state The number of processes can represent the current load of the server and the ability to process future concurrent business requests.
  • the server can have some dynamic expansion capabilities.
  • the service request load is too high, if the current number of worker threads cannot reach the concurrent amount, the number of worker threads needs to be increased to maximize the computing power of the hardware.
  • the server has too few business requests during a certain period of time, if a large number of worker threads are always maintained, hardware resources such as power consumption will be wasted.
  • the first method is: monitoring, for each process, the relationship between the number of working threads in the idle thread created in the process and the first preset threshold, and being idle in the working thread created in the process.
  • the number of worker threads is less than the first predetermined number of thresholds, a new worker thread is created in the process in preparation for timely processing of future concurrent service requests.
  • the created new worker thread can be bound to a hardware core, which is the hardware core corresponding to the process to which the new worker thread belongs.
  • the second method is: for each process, monitoring the relationship between the number of working threads in the idle thread created in the process and the second preset threshold, and is idle in the working thread created in a process.
  • the number of worker threads is greater than the second preset number threshold, the worker thread in the idle state is revoked in the process, and the number of worker threads in the idle state created in the process after the undo is not greater than the second pre-second Set the number threshold.
  • the number of working threads that are in an idle state after being revoked is not less than a first preset number threshold, wherein the first preset number threshold is smaller than the second pre-
  • the number of thresholds is set, and the specific values can be flexibly set according to the actual application scenarios and needs, and will not be described in detail here.
  • the combination of the above two methods can effectively save the system resources consumed by the created worker thread while ensuring timely processing of concurrent business requests.
  • the second embodiment of the present invention provides a service request processing method, which is applied to a multi-queue network card of a server, and the network card queue of the multi-queue network card stores the service from the client.
  • the request includes:
  • Step 801 The multi-queue network card obtains a service request from the client from its own network card queue.
  • Step 802 Send the service request to a listening thread bound to the NIC queue.
  • Step 803 Receive a service processing result that is sent after the service thread that belongs to the same process as the monitoring thread performs service processing on the service request.
  • Step 804 Return a business processing result to the client.
  • Embodiment 2 of the present invention further provides a service request processing method, which is applied to a listening thread, as shown in FIG. 9, and includes:
  • Step 901 The listening thread receives a service request from the client that is obtained by the multi-queue network card sent by the server from the network card queue bound to the listening thread.
  • Step 902 Send the service request to the worker thread in the idle state that belongs to the same process as the interception thread, and instruct the worker thread to perform service processing on the service request, and send the obtained service processing result to the multi-queue network card.
  • Step 1001 The client sends a service request to the server.
  • the service request processing method provided by the embodiment of the present invention can be applied to various specific service scenarios.
  • the server can be a web server
  • the service request sent by the client is a web request.
  • Step 1002 After receiving the service request sent by the client, the server saves the service request to the network card queue, and waits to be distributed to the worker thread for service processing.
  • Step 1003 The multi-queue network card obtains a service request from the network card queue, and binds to the network card queue.
  • the fixed listener thread sends the service request.
  • the binding relationship between the network card queue and the listening thread stored on the side of the multi-queue network card may be configured on the side of the multi-queue network card before the process and the thread are created, or may be created.
  • Each of the listening threads respectively sends a service request acquisition message to the multi-queue network card, where the service request acquisition message carries the queue identifier of the network card queue bound by the monitoring thread, and the multi-queue network card obtains a message based on each received service request, and determines to send the service.
  • the listening thread that requests the acquisition of the message is bound to the network card queue corresponding to the queue identifier carried in the service request acquisition message.
  • the monitoring may be performed on the target hardware core bound to the NIC queue.
  • the thread sends the service request.
  • Step 1004 After receiving the service request sent by the server's multi-queue network card, the monitoring thread determines a worker thread that belongs to the same process and is in an idle state as a worker thread that will subsequently process the service request.
  • the listening thread can select a working thread from all the working threads that belong to the same process and are currently in an idle state, and when there is no working thread in the idle state, a new working thread can be created, and After the creation is complete, the new worker thread is used as the worker thread for subsequent processing of the business request.
  • the new worker thread can also be bound to a hardware core, and the hardware core is the hardware core corresponding to the process to which the new worker thread belongs.
  • Step 1005 The listening thread sends the service request to the determined worker thread.
  • Step 1006 After receiving the service request, the worker thread performs service processing on the service request to obtain a service processing result.
  • the specific processing mode can be determined based on different service application scenarios. For example, when the service request is a web request, the URL address carried in the web request can be parsed, and the processing operation is performed by processing a file or the like from a disk. No detailed description will be given.
  • a worker thread When a worker thread is bound to a hardware core, the worker thread is run by the bound hardware core and The service request performs business processing, avoids random scheduling of the worker thread among multiple hardware cores, saves system resources consumed by the scheduling worker thread, and improves processing efficiency.
  • Step 1007 The worker thread returns a service processing result obtained after processing the service request to the multi-queue network card.
  • Step 1008 The multi-queue network card returns the service processing result to the corresponding client, and completes the response to the service request of the client.
  • the service request may be sent to a listening thread bound to the network card queue, and the monitoring thread selects The working thread that belongs to the same process as itself processes the service request.
  • the multiple listening processes are prevented from competing for the lock when requesting the service request, and the service request in the network queue can be directly sent to the The bound listener thread can be used, which improves the efficiency of the server's processing of concurrent business requests.
  • each worker thread can be run by the bound hardware core, avoiding scheduling of multiple hardware check worker threads, saving system resource consumption, and further improving the processing efficiency of concurrent service requests.
  • the thread creation method according to the above embodiment of the present invention correspondingly, the third embodiment of the present invention further provides a thread creation apparatus, which is applied to a server having a multi-queue network card, and a network card of the multi-queue network card.
  • the service request from the client is stored in the queue.
  • the structure of the service is shown in Figure 11.
  • the quantity obtaining unit 1101 is configured to acquire the number of network card queues of the multi-queue network card of the server;
  • a process creation unit 1102 configured to create an equal number of processes with the number of network card queues
  • a thread creation unit 1103, configured to create a listener thread and a plurality of worker threads in each process
  • the binding unit 1104 is configured to bind each of the created listening threads to different network card queues.
  • the server has multiple hardware core processors
  • the binding unit 1104 is specifically configured to bind each of the created listening threads to different target hardware cores in the multiple hardware core processors, and each of the multi-queue network cards is respectively configured with the Different hardware cores in the target hardware core are bound, so that each of the listening threads that are created is respectively bound to a different network card queue; wherein the target hardware core is used to bind the multi-hardware core processor. Listening to the thread and all hardware cores of the NIC queue, the number of NIC queues being equal to the number of target hardware cores.
  • binding unit 1104 is further configured to bind a worker thread created in each process to a hardware core.
  • the thread creation unit 1103 is further configured to: when the hardware core of the multi-hardware core processor of the server increases, create a new worker thread in a process for each added hardware core;
  • the binding unit 1104 is further configured to bind the created new worker thread to the newly added hardware core.
  • process creation unit 1102 is further configured to: when the network card queue of the multi-queue network card of the server increases, create a new process for each added network card queue;
  • the thread creation unit 1103 is further configured to create a listener thread and a worker thread in the created new process
  • the binding unit 1104 is further configured to bind the monitoring thread created in the new process to the newly added NIC queue.
  • the thread creating unit 1103 is further configured to: when the number of working threads in the idle state in the working thread created in one process is less than the first preset number threshold, create a new worker thread in the process; and/or
  • the worker thread in the idle state is revoked in the process, and the work created in the process is revoked
  • the number of worker threads in the idle state in the thread is not greater than the second preset number threshold.
  • each unit in the above process and thread creation device may correspond to FIG. 2, FIG. 3, FIG. 6 and The corresponding processing steps in the flow shown in FIG. 7 are not described herein again.
  • the fourth embodiment of the present invention further provides a service request processing apparatus, which is applied to a multi-queue network card of a server.
  • the network card queue of the multi-queue network card stores a service request from a client, and the server creates an equal number of processes with the number of network card queues of the multi-queue network card, and each process has one listening thread and multiple The working thread, and each of the created listening threads is respectively bound to a different network card queue, and its structure is shown in FIG. 12, which specifically includes:
  • the service request obtaining unit 1201 is configured to obtain a service request from the client from the network card queue of the multi-queue network card;
  • the first sending unit 1202 is configured to send the service request to a listening thread bound to the network card queue
  • the receiving unit 1203 is configured to receive a service processing result that is sent after the service thread that belongs to the same process as the monitoring thread performs service processing on the service request.
  • the second sending unit 1204 is configured to return the service processing result to the client.
  • the receiving unit 1203 is further configured to receive, by the service request obtaining unit 1201, a service request acquisition message separately sent by each of the created listening threads before acquiring the service request from the client from the network card queue of the multi-queue network card.
  • the service request acquisition message carries a queue identifier of a network card queue bound by a monitoring thread;
  • the device further includes:
  • the binding relationship determining unit 1205 is configured to determine that the listening thread that sends the service request obtaining message is bound to the network card queue corresponding to the queue identifier carried in the service request obtaining message.
  • the server has multiple hardware core processors, each of which is separately bound to a different target hardware core in the multiple hardware core processors, and each network card queue in the multi-queue network card is respectively Different hardware cores in the target hardware core are bound, so that each of the created listening threads is respectively bound to a different network card queue; wherein the target hardware core is the multiple hardware core processor All hardware cores for binding the listening thread and the network card queue, the number of the network card queues being equal to the number of the target hardware cores;
  • the first sending unit 1202 is specifically configured to send the service request to a listening thread running on a target hardware core bound to the network card queue.
  • worker thread created in each process is bound to a hardware core.
  • the functions of the units in the service request processing apparatus shown in FIG. 12 may correspond to the corresponding processing steps in the processes shown in FIG. 8, FIG. 9, and FIG. 10, and details are not described herein again.
  • the service request processing method applied to the monitoring thread according to the above embodiment of the present invention, correspondingly, the fifth embodiment of the present invention further provides a service request processing apparatus, which is applied to a monitoring thread created on a server.
  • the server has a multi-queue network card, and the network card queue of the multi-queue network card stores a service request from a client, and the server creates an equal number of processes with the number of network card queues of the multi-queue network card, and each process is in progress A listener thread and a plurality of worker threads are created, and each of the created monitor threads is respectively bound to a different network card queue.
  • the structure of the network is as shown in FIG.
  • the receiving unit 1301 is configured to receive, by the multi-queue network card of the server, a service request from a client that is obtained from a network card queue bound to the listening thread;
  • the first sending unit 1302 is configured to send the service request to the working thread in an idle state that belongs to the same process as the listening thread, and is used to instruct the worker thread to perform service processing on the service request, and obtain the obtained service.
  • the processing result is sent to the multi-queue network card.
  • the second sending unit 1303 is configured to: before the receiving unit 1301 receives the service request sent by the multi-queue network card of the server from the network card queue bound to the listening thread, to the multi-queue network card Sending a service request acquisition message, where the service request acquisition message carries a queue identifier of a network card queue bound by the interception thread, and the multi-queue network card determines the supervisor
  • the listening thread is bound to the NIC queue corresponding to the queue identifier.
  • the server has multiple hardware core processors, each of which is separately bound to a different target hardware core in the multiple hardware core processors, and each network card queue in the multi-queue network card Separating with different hardware cores in the target hardware core, respectively, so that each of the listening threads that are created is respectively bound to a different network card queue; wherein the target hardware core is used in the multiple hardware core processor Binding the listening thread and all hardware cores of the network card queue, the number of the network card queues being equal to the number of the target hardware cores;
  • the receiving unit 1301 is configured to receive, by the multi-queue network card of the server, a service request from a client that is obtained from a network card queue bound to a target hardware core that runs the intercepting thread.
  • worker thread created in each process is bound to a hardware core.
  • a thread creation unit 1304, configured to create a new worker thread in the process when the number of worker threads in the idle state created in the worker thread created by the listener thread is less than the first preset number threshold;
  • the worker thread in the idle state is revoked in the process, and the process is cancelled in the process.
  • the number of worker threads that are idle in the created worker thread is not greater than the second preset number threshold.
  • the functions of the units in the service request processing apparatus shown in FIG. 13 may correspond to the corresponding processing steps in the processes shown in FIG. 8, FIG. 9, and FIG. 10, and details are not described herein again.
  • the thread creation method according to the above embodiment of the present invention, correspondingly, the embodiment 6 of the present invention further provides a server, and the schematic diagram of the structure is as shown in FIG.
  • a multi-queue network card 1401 configured to receive a service request from a client, and store a service request from the client in its own network card queue;
  • the processor 1402 is configured to acquire a number of network card queues of the multi-queue network card of the server, and create a process that is equal to the number of the network card queues; and create a listening thread and multiple working threads in each process; And each listener thread that is created is bound to a different NIC queue.
  • processor is a multi-hardware core processor
  • the processor 1402 is specifically configured to bind each of the created listening threads to different target hardware cores in the multiple hardware core processors, and respectively configure each network card queue in the multi-queue network card with the target Different hardware cores in the hardware core are bound, so that each of the listening threads created is bound to a different network card queue; wherein the target hardware core is used to bind the monitoring in the multiple hardware core processor. Threads and all hardware cores of the NIC queue, the number of NIC queues being equal to the number of target hardware cores.
  • processor 1402 is further configured to bind a worker thread created in each process to a hardware core.
  • processor 1402 is further configured to: when the hardware core of the multi-hardware core processor of the server increases, create a new worker thread in a process for each added hardware core; and create a new one The worker thread is bound to the newly added hardware core.
  • the processor 1402 is further configured to: when the NIC queue of the multi-queue NIC of the server increases, create a new process for each added NIC queue; and create a listening thread and multiple jobs in the created new process. Thread; and bind the listener thread created in the new process to the newly added NIC queue.
  • processor 1402 is further configured to: when the number of working threads in the idle state in the working thread created in one process is less than the first preset number threshold, create a new worker thread in the process; and/or
  • the worker thread in the idle state is revoked in the process, and the worker thread created in the process is in the process thread after the cancellation
  • the number of worker threads in the idle state is not greater than the second preset number Threshold.
  • the seventh embodiment of the present invention further provides a multi-queue network card of the server, where the server is created with The number of network card queues of the multi-queue network card is equal to the number of processes, and one listening thread and multiple working threads are created in each process, and each of the created listening threads is respectively bound with a different network card queue, and the structure diagram thereof is as follows: As shown in Figure 15, the specific includes:
  • An interface 1501 configured to receive a service request from a client, and store the request in a network card queue
  • Processing chip 1502 configured to obtain a service request from a client from a network card queue of the multi-queue network card; and send the service request to a listening thread bound to the network card queue; and receive a worker thread that belongs to the same process as the monitoring thread a service processing result sent after performing service processing on the service request; and returning the service processing result to the client;
  • the memory 1503 is configured to store a service request from the client in the network card queue.
  • processing chip 1502 is further configured to: before receiving the service request from the client in the network card queue of the multi-queue network card, receive a service request acquisition message separately sent by each of the created listening threads, where the service request acquisition message is carried Listening queue ID of the NIC queue bound by the thread;
  • the server has multiple hardware core processors, each of which is separately bound to a different target hardware core in the multiple hardware core processors, and each network card queue in the multi-queue network card Separating with different hardware cores in the target hardware core, respectively, so that each of the listening threads that are created is respectively bound to a different network card queue; wherein the target hardware core is used in the multiple hardware core processor Binding the listening thread and all hardware cores of the network card queue, the number of the network card queues being equal to the number of the target hardware cores;
  • the processing chip 1502 is specifically configured to send the service request to a listening thread running on a target hardware core bound to the network card queue.
  • worker thread created in each process is bound to a hardware core.
  • the solution provided by the embodiment of the present invention includes: acquiring the number of network card queues of the multi-queue network card of the server; and creating a process equal to the number of network card queues; and creating a monitoring thread and multiple processes in each process. Worker threads; and each listener thread that is created is bound to a different NIC queue.
  • the solution provided by the embodiment of the invention makes the process and thread creation more reasonable, and improves the processing efficiency of the server for concurrent service requests.
  • the monitoring thread by using the characteristics of the multi-queue network card and the system hardware computing unit (hardware core) binding, the monitoring thread that needs to listen for the service request is sequentially deployed on the corresponding hardware core, so that multiple networks can be simultaneously monitored. Client's business request.
  • the network card driver forwards the service request to each listening thread in parallel, which improves the performance problem caused by the serial forwarding service request in the traditional server system. At the same time, more worker threads can be processed for business requests at the same time.
  • the solution provided by the embodiment of the present invention has scalability.
  • the scalability mentioned here refers to the creation of new processes and/or new network cores and new network card queues while updating hardware resources, improving processor computing power and network processing capabilities. Or threads, the performance of the entire system can be effectively improved.
  • the solution provided by the embodiment of the present invention utilizes the advantage of linear expansion of the multi-core operating system, and performs process thread deployment for the model of the server.
  • This new structure when the number of computing units is large, continues to increase hardware resources, and can still effectively improve server performance.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • the present invention is directed to a method, apparatus (system), and computer program according to an embodiment of the present invention.
  • the flow chart and/or block diagram of the product is described. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG.
  • These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • Mathematical Physics (AREA)
  • Telephonic Communication Services (AREA)
  • Information Transfer Between Computers (AREA)
  • Computer And Data Communications (AREA)

Abstract

本发明公开了一种线程创建方法、业务请求处理方法及相关设备,包括:获取服务器的多队列网卡的网卡队列数;并创建与网卡队列数相等数量的进程;并在每个进程中创建一个监听线程和多个工作线程;以及将创建的每个监听线程分别与不同的网卡队列绑定。采用本发明实施例提供的方案,使得进程和线程创建更合理,且提高了服务器对并发的业务请求的处理效率。

Description

线程创建方法、业务请求处理方法及相关设备 技术领域
本发明涉及计算机技术领域,尤其涉及一种线程创建方法、业务请求处理方法及相关设备。
背景技术
随着Internet的迅猛发展,人们对Web服务器的访问日益频繁,从而对Web服务器的性能也提出越来越高的要求。为了能够向用户提供更加快捷的服务,Web服务器对处理并发访问的要求越来越高。当用户并发访问量过高时,服务器就会超载,Web站点的访问速度就会下降。为了能够容纳更多的用户同时访问,尽可能提升Web服务器性能,需要尽量改善Web服务器的处理器能力,使用更加强大的计算机芯片。
近几年,计算机芯片制作工艺的不断提高,众核处理器已经成为了处理器发展的一个重要趋势。众核处理器比多核处理器中的处理内核数量还要多,计算能力更强大。当前的软件结构可以在当前的多核结构上得到较好的扩展,但如果超过八个处理器核,当前软件结构的扩展能力将会很差。超过八个处理器核的设计即被称为“众核”处理器。
众核处理器拥有比普通的多核处理器更多的处理单元,以及更加强大的并行处理能力。越来越多的Web服务器正在采用这种强大的众核环境作为其提升性能的基础。当今的软件结构已经可以在普通的多核处理器上得到较好的扩展。但是,在众核处理器环境下,如何保证软件能够随着硬件核数地增多更加高效地扩展,已经逐渐变成众核软件设计的核心问题。
另一方面,基于众核处理器的多内核操作系统也在不断发展。在多内核操作系统中,每一个硬件核(core)都有自已的一个内核(kernel),并且不共享内存,这一点有别于现存的Windows与基于Linux内核的操作系统。内核之间的通信通过消息传递方式,在内核数量很大的情况下要优于传统的共享内存的通 信方式,能充分利用众核处理芯片。目前,已经有一些基于多内核操作系统的应用,例如基于Barrelfish的Haskell编译器、虚拟机等。在众核环境下,它们的性能明显地高出传统的操作系统。
伴随着Web服务器对处理器的需求显著增加,如果能够利用多内核操作系统的优势,就可以尽可能充分发挥众核环境的处理能力,所以,如何将Web服务器的软件部署在多内核操作系统中即成为核心的问题。
在Windows、Linux等操作系统中,目前的Web服务器软件是针对操作系统的进程线程模型,使用特定的方式创建和管理进程线程来进行多任务的管理,从而同时响应并发请求。如果将现有的多任务管理方式直接地运用在多内核操作系统中,会引人一些不必要的系统开销,从而导致无法发挥众核环境的优越性。
在针对多任务管理的问题上,现有技术中已经存在了一些成熟的方法和模型。一个典型的多任务管理方法叫做Prefork(预派生)。Prefork实现了一个非线程型的、预派生的web服务器。
在Prefork方法中,一个单独的控制进程(父进程)负责产生子进程,这些子进程用于监听请求并作出应答。并且,Web服务器总是试图保持一些备用的(spare)或者是空闲的子进程,用于准备对将到来的请求进行处理,从而使得客户端不需要在得到服务前等候子进程的产生,以提高对请求的处理效率。
然而,在上述Prefork方法中,虽然可以让预先创建好的进程处理新的请求,以避免客户端等待服务端创建处理进程而影响响应速度,但仍然存在如下问题:
进程过多会占有过多的不必要的系统资源,浪费了系统的空间资源,并且增加操作系统调度进程的开销,浪费了系统的时间资源,并且是利用进程来完成对请求的处理,而没有利用线程的优势,代价较大。
另一种常用的Web服务器的多任务管理方法是Worker,Worker方法支持混合的多线程多进程。
在Worker方法中,总是试图维持一个备用(spare)或是空闲的服务线程池,这样,客户端的请求无须等待新线程或新进程的建立即可得到处理。初始化时建立一定数量进程,随后父进程检测所有子进程中空闲线程的总数,并新建或结束子进程使空闲线程的总数维持在一定的范围内。
并且,如图1所示,可以创建多个进程,例如,进程1至进程4,一个进程下所创建的线程中,可以包括一个监听线程(listener)和多个工作线程(worker),且各个线程会被随机调度到空闲的硬件核上,如图1中的硬件核1至硬件核8。在创建多进程和多线程后,由多个进程的多个监听线程向系统请求竞争一个锁,并在请求到锁后才能监听,并将监听得到的业务请求分配给与自身属于同一个进程的空闲的工作线程。
在Worker方法中,由于使用线程来处理业务请求,所以可以处理海量请求,而系统资源的开销小于基于进程的管理方法。
然而,由于多个监听线程需要向系统请求竞争一个锁,随着硬件核数的增加,竞争加剧,导致服务器的处理能力无法随着硬件核数的增加而线性增加,进而由于进程和线程创建的不合理,导致服务器对并发的多业务请求的处理效率较低。
发明内容
本发明实施例提供一种线程创建方法、业务请求处理方法及相关设备,用以解决现有技术中存在的线程创建不合理的问题,以及因此导致的服务器对并发的业务请求的处理效率较低的问题。
第一方面,提供一种线程创建方法,应用于具有多队列网卡的服务器,所述多队列网卡的网卡队列中存储来自客户端的业务请求,包括:
获取所述服务器的所述多队列网卡的网卡队列数;
创建与所述网卡队列数相等数量的进程;
在每个进程中创建一个监听线程和多个工作线程;
将创建的每个监听线程分别与不同的网卡队列绑定。
结合第一方面,在第一种可能的实现方式中,所述服务器具有多硬件核处理器;
将创建的每个监听线程分别与不同的网卡队列绑定,包括:
将创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,将所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量。
结合第一方面的第一种可能的实现方式,在第二种可能的实现方式中,还包括:
将每个进程中创建的工作线程绑定一个硬件核。
结合第一方面的第二种可能的实现方式,在第三种可能的实现方式中,不同进程中创建的工作线程绑定的硬件核不同。
结合第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式或者第一方面的第三种可能的实现方式,在第四种可能的实现方式中,还包括:
当所述服务器的多硬件核处理器的硬件核增加时,针对每个增加的硬件核,在一个进程中创建新的工作线程;
将创建的新的工作线程与新增加的该硬件核绑定。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式或者第一方面的第三种可能的实现方式,在第五种可能的实现方式中,还包括:
当所述服务器的多队列网卡的网卡队列增加时,针对每个增加的网卡队列创建新进程;
在创建的新进程中创建一个监听线程和多个工作线程;
将在新进程中创建的监听线程与新增加的该网卡队列绑定。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式或者第一方面的第三种可能的实现方式,在第六种可能的实现方式中,还包括:
当一个进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
当一个进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
第二方面,提供一种业务请求处理方法,应用于服务器的多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,所述方法包括:
所述多队列网卡从自身的网卡队列中获取来自客户端的业务请求;
向与该网卡队列绑定的监听线程发送所述业务请求;
接收与该监听线程属于同一进程的工作线程对所述业务请求进行业务处理后发送的业务处理结果;
向所述客户端返回所述业务处理结果。
结合第二方面,在第一种可能的实现方式中,在从自身的网卡队列中获取来自客户端的业务请求之前,还包括:
接收已创建的各监听线程分别发送的业务请求获取消息,所述业务请求获取消息中携带监听线程绑定的网卡队列的队列标识;
确定发送所述业务请求获取消息的监听线程,与所述业务请求获取消息中携带的所述队列标识对应的网卡队列相绑定。
结合第二方面,在第二种可能的实现方式中,所述服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
向与该网卡队列绑定的监听线程发送所述业务请求,包括:
向与该网卡队列绑定的目标硬件核上运行的监听线程发送所述业务请求。
结合第二方面的第二种可能的实现方式,在第三种可能的实现方式中,每个进程中创建的工作线程绑定一个硬件核。
结合第二方面的第三种可能的实现方式,在第四种可能的实现方式中,不同进程中创建的工作线程绑定的硬件核不同。
第三方面,提供一种业务请求处理方法,应用于服务器上创建的监听线程,所述服务器具有多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,所述方法包括:
监听线程接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求;
向与该监听线程属于同一进程的处于空闲状态的工作线程发送所述业务请求,用于指示该工作线程对所述业务请求进行业务处理,并将得到的业务处理结果发送给所述多队列网卡。
结合第三方面,在第一种可能的实现方式中,在接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求之前,还包括:
向所述多队列网卡发送业务请求获取消息,所述业务请求获取消息中携带 该监听线程绑定的网卡队列的队列标识,用于所述多队列网卡确定该监听线程与所述队列标识对应的网卡队列相绑定。
结合第三方面,在第二种可能的实现方式中,所述服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
监听线程接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求,包括:
监听线程接收所述服务器的多队列网卡发送的从与运行该监听线程的目标硬件核绑定的网卡队列中获取的来自客户端的业务请求。
结合第三方面的第二种可能的实现方式,在第三种可能的实现方式中,每个进程中创建的工作线程绑定一个硬件核。
结合第三方面的第三种可能的实现方式,在第四种可能的实现方式中,不同进程中创建的工作线程绑定的硬件核不同。
结合第三方面、第三方面的第一种可能的实现方式、第三方面的第二种可能的实现方式、第三方面的第三种可能的实现方式或者第三方面的第四种可能的实现方式,在第五种可能的实现方式中,还包括:
当该监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
当该监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
第四方面,提供一种线程创建装置,应用于具有多队列网卡的服务器,所 述多队列网卡的网卡队列中存储来自客户端的业务请求,包括:
数量获取单元,用于获取所述服务器的所述多队列网卡的网卡队列数;
进程创建单元,用于创建与所述网卡队列数相等数量的进程;
线程创建单元,用于在每个进程中创建一个监听线程和多个工作线程;
绑定单元,用于将创建的每个监听线程分别与不同的网卡队列绑定。
结合第四方面,在第一种可能的实现方式中,所述服务器具有多硬件核处理器;
所述绑定单元,具体用于将创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,将所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量。
结合第四方面的第一种可能的实现方式,在第二种可能的实现方式中,所述绑定单元,还用于将每个进程中创建的工作线程绑定一个硬件核。
结合第四方面的第二种可能的实现方式,在第三种可能的实现方式中,不同进程中创建的工作线程绑定的硬件核不同。
结合第四方面的第一种可能的实现方式、第四方面的第二种可能的实现方式或者第四方面的第三种可能的实现方式,在第四种可能的实现方式中,所述线程创建单元,还用于当所述服务器的多硬件核处理器的硬件核增加时,针对每个增加的硬件核,在一个进程中创建新的工作线程;
所述绑定单元,还用于将创建的新的工作线程与新增加的该硬件核绑定。
结合第四方面、第四方面的第一种可能的实现方式、第四方面的第二种可能的实现方式或者第四方面的第三种可能的实现方式,在第五种可能的实现方式中,所述进程创建单元,还用于当所述服务器的多队列网卡的网卡队列增加时,针对每个增加的网卡队列创建新进程;
所述线程创建单元,还用于在创建的新进程中创建监听线程和工作线程;
所述绑定单元,还用于将在新进程中创建的监听线程与新增加的该网卡队列绑定。
结合第四方面、第四方面的第一种可能的实现方式、第四方面的第二种可能的实现方式或者第四方面的第三种可能的实现方式,在第六种可能的实现方式中,所述线程创建单元,还用于当一个进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
还用于当一个进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
第五方面、提供一种业务请求处理装置,应用于服务器的多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,所述装置包括:
业务请求获取单元,用于从所述多队列网卡的网卡队列中获取来自客户端的业务请求;
第一发送单元,用于向与该网卡队列绑定的监听线程发送所述业务请求;
接收单元,用于接收与该监听线程属于同一进程的工作线程对所述业务请求进行业务处理后发送的业务处理结果;
第二发送单元,用于向所述客户端返回所述业务处理结果。
结合第五方面,在第一种可能的实现方式中,所述接收单元,还用于所述业务请求获取单元在从所述多队列网卡的网卡队列中获取来自客户端的业务请求之前,接收已创建的各监听线程分别发送的业务请求获取消息,所述业务 请求获取消息中携带监听线程绑定的网卡队列的队列标识;
所述装置,还包括:
绑定关系确定单元,用于确定发送所述业务请求获取消息的监听线程,与所述业务请求获取消息中携带的所述队列标识对应的网卡队列相绑定。
结合第五方面,在第二种可能的实现方式中,所述服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
所述第一发送单元,具体用于向与该网卡队列绑定的目标硬件核上运行的监听线程发送所述业务请求。
结合第五方面的第二种可能的实现方式,在第三种可能的实现方式中,每个进程中创建的工作线程绑定一个硬件核。
结合第五方面的第三种可能的实现方式,在第四种可能的实现方式中,不同进程中创建的工作线程绑定的硬件核不同。
第六方面,提供一种业务请求处理装置,应用于服务器上创建的监听线程,所述服务器具有多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,所述装置包括:
接收单元,用于接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求;
第一发送单元,用于向与该监听线程属于同一进程的处于空闲状态的工作线程发送所述业务请求,用于指示所述工作线程对所述业务请求进行业务处理,并将得到的业务处理结果发送给所述多队列网卡。
结合第六方面,在第一种可能的实现方式中,还包括:
第二发送单元,用于在所述接收单元接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求之前,向所述多队列网卡发送业务请求获取消息,所述业务请求获取消息中携带所述监听线程绑定的网卡队列的队列标识,用于所述多队列网卡确定所述监听线程与所述队列标识对应的网卡队列相绑定。
结合第六方面,在第二种可能的实现方式中,所述服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
所述接收单元,具体用于接收所述服务器的多队列网卡发送的从与运行该监听线程的目标硬件核绑定的网卡队列中获取的来自客户端的业务请求。
结合第六方面的第二种可能的实现方式,在第三种可能的实现方式中,每个进程中创建的工作线程绑定一个硬件核。
结合第六方面的第三种可能的实现方式,在第四种可能的实现方式中,不同进程中创建的工作线程绑定的硬件核不同。
结合第六方面、第六方面的第一种可能的实现方式、第六方面的第二种可能的实现方式、第六方面的第三种可能的实现方式或者第六方面的第四种可能的实现方式,在第五种可能的实现方式中,还包括:
线程创建单元,用于当该监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
用于当该监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线 程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
第七方面,提供一种服务器,包括:
多队列网卡,用于接收来自客户端的业务请求,并在自身的网卡队列中存储来自客户端的业务请求;
处理器,用于获取所述服务器的所述多队列网卡的网卡队列数;并创建与所述网卡队列数相等数量的进程;并在每个进程中创建一个监听线程和多个工作线程;以及将创建的每个监听线程分别与不同的网卡队列绑定。
结合第七方面,在第一种可能的实现方式中,处理器为多硬件核处理器;
处理器,具体用于将创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,将所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量。
结合第七方面的第一种可能的实现方式,在第二种可能的实现方式中,处理器,还用于将每个进程中创建的工作线程绑定一个硬件核。
结合第七方面的第二种可能的实现方式,在第三种可能的实现方式中,不同进程中创建的工作线程绑定的硬件核不同。
结合第七方面的第一种可能的实现方式、第七方面的第二种可能的实现方式或者第七方面的第三种可能的实现方式,在第四种可能的实现方式中,处理器,还用于当所述服务器的多硬件核处理器的硬件核增加时,针对每个增加的硬件核,在一个进程中创建新的工作线程;并将创建的新的工作线程与新增加的该硬件核绑定。
结合第七方面、第七方面的第一种可能的实现方式、第七方面的第二种可能的实现方式或者第七方面的第三种可能的实现方式,在第五种可能的实现方 式中,处理器,还用于当所述服务器的多队列网卡的网卡队列增加时,针对每个增加的网卡队列创建新进程;并在创建的新进程中创建一个监听线程和多个工作线程;以及将在新进程中创建的监听线程与新增加的该网卡队列绑定。
结合第七方面、第七方面的第一种可能的实现方式、第七方面的第二种可能的实现方式或者第七方面的第三种可能的实现方式,在第六种可能的实现方式中,处理器,还用于当一个进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
当一个进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
第八方面,提供一种服务器的多队列网卡,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,该多队列网卡,包括:
接口,用于接收来自客户端的业务请求,并存储到网卡队列中;
处理芯片,用于从多队列网卡的网卡队列中获取来自客户端的业务请求;并向与该网卡队列绑定的监听线程发送所述业务请求;并接收与该监听线程属于同一进程的工作线程对所述业务请求进行业务处理后发送的业务处理结果;以及向所述客户端返回所述业务处理结果;
存储器,用于存储网卡队列中的来自客户端的业务请求。
结合第八方面,在第一种可能的实现方式中,处理芯片,还用于在从多队列网卡的网卡队列中获取来自客户端的业务请求之前,接收已创建的各监听线程分别发送的业务请求获取消息,所述业务请求获取消息中携带监听线程绑定的网卡队列的队列标识;
确定发送所述业务请求获取消息的监听线程,与所述业务请求获取消息中 携带的所述队列标识对应的网卡队列相绑定。
结合第八方面,在第二种可能的实现方式中,所述服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
处理芯片,具体用于向与该网卡队列绑定的目标硬件核上运行的监听线程发送所述业务请求。
结合第八方面的第二种可能的实现方式,在第三种可能的实现方式中,每个进程中创建的工作线程绑定一个硬件核。
结合第八方面的第三种可能的实现方式,在第四种可能的实现方式中,不同进程中创建的工作线程绑定的硬件核不同。
本发明有益效果包括:
本发明实施例提供的方案,应用于具有多队列网卡的服务器,该多队列网卡的网卡队列中存储来自客户端的业务请求,服务器在启动后创建进程和线程时,创建与网卡队列数相等数量的进程,并在每个进程中创建一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,从而在对业务请求进行处理时,针对从一个网卡队列中获取的来自客户端的业务请求,将该业务请求发送给与该网卡队列绑定的监听线程,由该监听线程选择与自身属于同一进程的工作线程对该业务请求进行业务处理,相比现有技术,避免了多个监听进程在请求获取业务请求时对锁的竞争,可以将网络队列中的业务请求直接发送给绑定的监听线程即可,从而使得进程和线程创建更合理,并且因此提高了服务器对并发的业务请求的处理效率。
本申请的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本申请而了解。本申请的目的和其他优点可 通过在所写的说明书、权利要求书、以及附图中所特别指出的结构来实现和获得。
附图说明
附图用来提供对本发明的进一步理解,并且构成说明书的一部分,与本发明实施例一起用于解释本发明,并不构成对本发明的限制。在附图中:
图1为采用现有技术中的Worker方法创建的多进程和多线程的示意图;
图2为本发明实施例1中提供的线程创建方法的流程图之一;
图3为本发明实施例1中提供的线程创建方法的流程图之二;
图4为本发明实施例1中创建的进程和线程的示意图;
图5为本发明实施例1中绑定的进程和网卡队列的示意图;
图6为本发明实施例1中当硬件核增加时创建新线程的处理流程图;
图7为本发明实施例1中当多队列网卡的网卡队列增加时创建新进程和新线程的处理流程图;
图8为本发明实施例2提供的应用于服务器的多队列网卡的业务请求处理方法的流程图;
图9为本发明实施例2提供的应用于监听线程的业务请求处理方法的流程图;
图10为本发明实施例2提供的业务请求处理方法的流程图;
图11为本发明实施例3提供的线程创建装置的结构示意图;
图12为本发明实施例4提供的业务请求处理装置的结构示意图;
图13为本发明实施例5提供的业务请求处理装置的结构示意图;
图14为本发明实施例6提供的服务器的结构示意图;
图15为本发明实施例7提供的多队列网卡的结构示意图。
具体实施方式
为了给出使得线程创建更合理,且提高服务器对并发的业务请求的处理效率的实现方案,本发明实施例提供了一种线程创建方法、业务请求处理方法及相关设备,以下结合说明书附图对本发明的优选实施例进行说明,应当理解,此处所描述的优选实施例仅用于说明和解释本发明,并不用于限定本发明。并且在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。
实施例1:
本发明实施例1提供一种线程创建方法,应用于具有多队列网卡的服务器,多队列网卡的网卡队列中存储来自客户端的业务请求,如图2所示,包括:
步骤201、获取服务器的多队列网卡的网卡队列数。
步骤202、创建与网卡队列数相等数量的进程。
步骤203、在每个进程中创建一个监听线程和多个工作线程。
步骤204、将创建的每个监听线程分别与不同的网卡队列绑定。
在上述线程创建方法中,创建的进程数与网卡队列数相等,且进程中创建的监听线程与不同的网卡队列绑定,从而使得后续可以将每个网卡队列中的业务请求,分配给与该网卡队列绑定的监听线程处理,从而避免了多个监听线程竞争一个锁,使得进程和线程的创建更合理。
该服务器具有多硬件核处理器时,进一步的,在将创建的每个监听线程分别与不同的网卡队列绑定时,具体可以采用如下方式:
将创建的每个监听线程分别与多硬件核处理器中的不同的目标硬件核绑定,将多队列网卡中的每个网卡队列分别与目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,目标硬件核为多硬件核处理器中用于绑定监听线程和网卡队列的所有硬件核,网卡队列的数量等于目标硬件核的数量。
进一步的,还可以将每个进程中创建的工作线程绑定一个硬件核,且不同进程中创建的工作线程绑定的硬件核不同,从而相比现有技术中各个线程被随机调度到空闲的硬件核上的方案,减少了线程调度的开销,使得即便产生大量 的线程,也不会因线程在硬件核上的调度而导致对服务器性能造成明显下降。
并且,在将监听线程和工作线程与硬件核绑定之前,还可以获取服务器的多硬件核处理器的硬件核数,并基于该硬件核数进行绑定,使得在将每个进程中创建的工作线程绑定一个硬件核之后,不同进程中创建的监听线程和工作线程绑定的硬件核的数量相差不大于1,以便最大程度的充分利用每个硬件核的处理能力,提高服务器对并发业务请求的整体处理性能。
进一步的,还可以针对多硬件核处理器的硬件核增加的情况,多队列网卡的网卡队列增加的情况,相应的创建新的进程和线程,以及还可以针对一个进程中处于空闲状态的工作线程的数量,创建新的线程或撤销处于空闲状态的工作线程,以便使得处于空闲状态的工作线程处于一个合理的数量,在保证及时对来自客户端的业务请求进行处理的同时,节省系统维持工作进程所使用的系统资源。
下面结合附图,用具体实施例对本发明提供的上述线程创建方法进行详细描述,如图3所示,具体包括如下处理步骤:
步骤301、在服务器被启动后,获取服务器的多队列网卡的网卡队列数。
步骤302、进一步的,还可以获取服务器的多硬件核处理器的硬件核数。
步骤301和步骤302之间没有严格的先后顺序。
步骤303、创建与网卡队列数相等数量的进程。
例如,如图4所示,服务器的多队列网卡的网卡队列数为4,则依据最大并行原则,创建与网卡队列数相等数量的进程,即进程1-进程4。
步骤304、在每个进程中创建监听线程(listener)和工作线程(worker)。
本步骤中,如图4所示,可以在每个进程中创建一个监听线程和多个工作线程,其中,多个工作线程的数量,可以根据服务器的实际应用场景,例如,预期可能的吞吐量、并发业务请求数和响应时间要求等,以及服务器实际的物理硬件处理能力共同决定。
工作线程在创建后,初始状态为空闲状态,当其后续接收到业务请求后, 在对业务请求进行业务处理的过程中,其状态为工作状态。
步骤305、将创建的每个监听线程分别与不同的网卡队列绑定。
当每个进程中创建一个监听线程时,创建的监听线程的数量与网卡队列数相同,则可以将数量相等的多个监听线程与多个网卡队列一一对应绑定,如图5所示,进程1-进程4中分别创建的监听线程1-监听线程4,分别于网卡队列1-网卡队列4一一对应绑定。
具体的,该服务器具有多硬件核处理器时,可以从多硬件核处理器的硬件核中选择与网卡队列数数量相等的多个目标硬件核,并将创建的每个监听线程分别与不同的目标硬件核绑定,以及将多队列网卡中的每个网卡队列分别与不同的目标硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定。
步骤306、进一步的,还可以将每个进程中创建的工作线程绑定一个硬件核,且不同进程中创建的工作线程绑定的硬件核不同,以便监听线程和工作线程固定由自身绑定的硬件核运行,避免了由于多个硬件核随机调度监听线程和工作线程所消耗的系统资源,且提高了处理效率。
进一步的,为了提高多个硬件核的利用率,最大程度的平均多个硬件核处理的业务请求数量,还可以根据多硬件核处理器的硬件核数,使得不同进程中创建的监听线程和工作线程绑定的硬件核的数量相差不大于1。
如图4所示,服务器的多硬件核处理器的硬件核数为8,创建的进程的数量为4,则每个进程可以分配用于与监听线程和工作线程绑定的硬件核,进程1对应的硬件核包括硬件核1和硬件核2,进程2对应的硬件核包括硬件核3和硬件核4,进程3对应的硬件核包括硬件核5和硬件核6,进程4对应的硬件核包括硬件核7和硬件核8。
进程1中创建的监听线程和部分工作线程与硬件核1绑定,其余工作线程与硬件核2绑定,进程2-进程3中创建的监听线程和工作线程与硬件核的绑定关系,如图4所示。
本发明实施例中,多队列网卡端口分配需要物理硬件、操作系统以及上层应用全面的支持。物理硬件层面,多队列网卡能够并行接收来自以太网的网络报文。操作系统通过网卡驱动获得网络报文,将其打包并传递给负责网络分发的模块。在传统操作系统中该过程通常是由内核模块来完成,而在多内核操作系统中,该任务主要由运行在用户态的一个服务完成。该服务将网络包分发给物理硬件核上正在运行的监听线程,监听线程解析事务逻辑,根据状态再做相应的转发处理。
并发请求处理是多任务管理系统最为核心的功能。本发明实施例中,处理多任务的最小单元为线程。与通常的多任务处理方法不同的是,这些工作线程都固定绑定在相应的硬件核上,无需被调度。并且,工作线程可以根据当前状态处于工作状态或者空闲状态,而分别保存在工作队列和空闲队列中。在初始部署完成后,所有的工作线程都处于空闲队列中。当一个进程内负责监听业务请求的监听线程收到业务请求后,触发处理事件。此时,在空闲队列中取出一个空闲的工作线程,监听线程将来自客户端的业务请求交给该工作线程处理。此时,该工作线程被送入工作队列,处理该任务。处理结束后,自动从工作队列中取出,进入空闲队列,回到空闲状态。状态的变化可以由触发不同的事件完成。
通过上述图3所示的线程创建方法,将创建的与网卡队列数相同数量的多个监听线程分别与网卡队列一一对应绑定,用于后续接收绑定的网卡队列中的来自客户端的业务请求,并分发给与自身属于同一个进程的处于空闲状态的工作线程进行业务处理,从而使得进程和线程创建更合理,以提高服务器对并发的业务请求的处理效率。
并且,创建的每个监听线程和工作线程还可以绑定一个硬件核,并固定由绑定的硬件核运行,避免了由于多个硬件核随机调度监听线程和工作线程所消耗的系统资源,且提高了处理效率。
在使用服务器对业务请求进行处理的实际应用中,还可以根据实际需要对 服务器的处理能力进行扩展,例如,当需要提升服务器的计算能力时,可以扩展硬件核的数量,当需要提升网络吞吐量时,可以扩展多队列网卡的网卡队列数量。
本发明实施例1中,针对服务器处理能力的扩展,在进程和线程的创建上,还提出了如下相应的处理方案:
图6所示为当硬件核增加时创建新线程的处理流程,具体包括:
步骤601、当服务器的多硬件核处理器的硬件核增加时,针对每个增加的硬件核,在一个进程中创建新的工作线程。
步骤602、将创建的新的工作线程与新增加的该硬件核绑定。
图7所示为当多队列网卡的网卡队列增加时创建新进程和新线程的处理流程,具体包括:
步骤701、当服务器的多队列网卡的网卡队列增加时,针对每个增加的网卡队列创建新进程。
步骤702、在创建的新进程中创建一个监听线程和多个工作线程。
步骤703、将在新进程中创建的监听线程与新增加的该网卡队列绑定。
具体的,可以从多硬件核处理器的除目标硬件核之外的其它硬件核中,选择一个作为新的目标硬件核,将新进程中创建的监听线程与该新的目标硬件核绑定,并将新增加的该网卡队列与该新的目标硬件核绑定,从而实现将在新进程中创建的监听线程与新增加的该网卡队列绑定。
步骤704、进一步的,还可以将在新进程中创建的工作线程绑定一个硬件核,如果此时存在新增加的硬件核,可以与新增加的硬件核绑定,如果不存在新增加的硬件核,可以解除一个原有硬件核绑定的工作线程,并将该原有硬件核与在新进程中创建的工作线程进行绑定。
本发明实施例中,在服务器启动后,并采用上述图3所示方法创建进程和线程后,服务器即可以对来自客户端的业务请求进行业务处理,在处理过程中,工作线程的状态在工作状态与空闲状态之间切换,当前处于空闲状态的工作线 程的数量,可以表示服务器当前的负载情况,以及对将来并发的业务请求的处理能力。
为了更好地使用硬件资源,服务器可以具备一定动态扩展的能力。一方面,当业务请求负载过高时,如果当前的工作线程的数量无法达到并发量时,需要增加工作线程的数量,以便尽可能发挥硬件的计算能力。反之,如果服务器在某一时间段内的业务请求过少,如果始终维护着大量的工作线程,将浪费硬件的资源,例如能耗。
为了保证对将来并发的业务请求及时处理,可以采用如下第一种方式调整一个进程中的工作线程:
第一种方式:针对每个进程,监控该进程中创建的工作线程中处于空闲状态的工作线程的数量与第一预设阈值的大小关系,并当该进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程,以便为对将来并发的业务请求的及时处理做准备。
进一步的,还可以将创建的新的工作线程与一个硬件核进行绑定,该硬件核为该新的工作线程所属的进程对应的硬件核。
另一方面,由于维持创建的工作线程需要消耗系统资源,所以为了节省系统资源的消耗,还可以采用如下第二种方式调整一个进程中的工作线程:
第二种方式:针对每个进程,监控该进程中创建的工作线程中处于空闲状态的工作线程的数量与第二预设阈值的大小关系,并当一个进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
进一步的,当上述两种方式相结合时,在第二种方式中,撤销后处于空闲状态的工作线程的数量不小于第一预设数量阈值,其中,第一预设数量阈值小于第二预设数量阈值,具体数值可以根据实际应用场景和需要进行灵活设置,在此不再进行详细描述。
上述两种方式相结合,即可以在保证对将来并发的业务请求及时处理的同时,还能够有效节省维持创建的工作线程所消耗的系统资源。
实施例2:
针对本发明实施例1提供的上述线程创建方法,相应的,本发明实施例2提供一种业务请求处理方法,应用于服务器的多队列网卡,该多队列网卡的网卡队列中存储来自客户端的业务请求,如图8所示,包括:
步骤801、多队列网卡从自身的网卡队列中获取来自客户端的业务请求。
步骤802、向与该网卡队列绑定的监听线程发送该业务请求。
步骤803、接收与该监听线程属于同一进程的工作线程对该业务请求进行业务处理后发送的业务处理结果。
步骤804、向客户端返回业务处理结果。
相应的,本发明实施例2还提供了一种业务请求处理方法,应用于监听线程,如图9所示,包括:
步骤901、监听线程接收服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求。
步骤902、向与该监听线程属于同一进程的处于空闲状态的工作线程发送该业务请求,用于指示该工作线程对该业务请求进行业务处理,并将得到的业务处理结果发送给多队列网卡。
下面结合附图,用具体实施例对本发明提供的上述业务请求处理方法进行详细描述,如图10所示,具体包括如下处理步骤:
步骤1001、客户端向服务器发送业务请求。
本发明实施例提供的业务请求处理方法,可应用于各种具体业务场景中,例如,服务器可以为Web服务器,客户端发送的业务请求为Web请求。
步骤1002、服务器通过多队列网卡接收到客户端发送的业务请求后,将保存到网卡队列中,等待被分发给工作线程进行业务处理。
步骤1003、多队列网卡从网卡队列中获取业务请求,并向与该网卡队列绑 定的监听线程发送该业务请求。
本发明实施例2中,在多队列网卡一侧保存的网卡队列与监听线程的绑定关系,可以是在创建进程和线程后,预先在多队列网卡一侧进行配置的,也可以由已创建的各监听线程分别向多队列网卡发送业务请求获取消息,该业务请求获取消息中携带监听线程绑定的网卡队列的队列标识,多队列网卡基于接收的每个业务请求获取消息,确定发送该业务请求获取消息的监听线程,与该业务请求获取消息中携带的队列标识对应的网卡队列相绑定。
本步骤中,当通过与网卡队列和监听线程分别绑定的目标硬件核,实现该网卡队列和该监听线程的绑定时,具体可以向与该网卡队列绑定的目标硬件核上运行的监听线程发送该业务请求。
步骤1004、监听线程在接收到服务器的多队列网卡发送的业务请求后,确定一个与自身属于同一进程的且处于空闲状态的工作线程,作为后续将要处理该业务请求的工作线程。
本步骤中,监听线程可以从与自身属于同一进程的且当前处于空闲状态的全部工作线程中,选择一个工作线程,当不存在处于空闲状态的工作线程时,可以创建一个新的工作线程,并在创建完成后,将该新的工作线程作为后续将要处理该业务请求的工作线程。
当创建了新的工作线程时,还可以将该新的工作线程与一个硬件核进行绑定,且该硬件核为新的工作线程所属进程对应的硬件核。
步骤1005、监听线程向确定的该工作线程发送该业务请求。
步骤1006、该工作线程在接收到该业务请求后,对该业务请求进行业务处理,得到业务处理结果。
具体的处理方式可以基于不同的业务应用场景进行确定,例如,当业务请求为Web请求时,可以解析Web请求中携带的URL地址,并通过从磁盘读取文件等处理操作进行业务处理,在此不再进行详细描述。
当工作线程已与一个硬件核绑定时,工作线程由绑定的硬件核运行,并对 业务请求进行业务处理,避免了该工作线程在多个硬件核之间的随机调度,节省了调度工作线程所消耗的系统资源,并提高了处理效率。
步骤1007、该工作线程向多队列网卡返回对该业务请求处理后得到的业务处理结果。
步骤1008、多队列网卡将得到业务处理结果返回给对应的客户端,完成对该客户端的业务请求的响应。
采用本发明实施例2提供的上述业务请求处理方法,针对从一个网卡队列中获取的来自客户端的业务请求,可以将该业务请求发送给与该网卡队列绑定的监听线程,由该监听线程选择与自身属于同一进程的工作线程对该业务请求进行业务处理,相比现有技术,避免了多个监听进程在请求获取业务请求时对锁的竞争,可以将网络队列中的业务请求直接发送给绑定的监听线程即可,从而提高了服务器对并发的业务请求的处理效率。
并且,进一步的,每个工作线程可以由绑定的硬件核运行,避免了多个硬件核对工作线程的调度,节省了系统资源的消耗,进一步提高了对并发的业务请求的处理效率。
实施例3:
基于同一发明构思,根据本发明上述实施例提供的线程创建方法,相应地,本发明实施例3还提供了一种线程创建装置,应用于具有多队列网卡的服务器,所述多队列网卡的网卡队列中存储来自客户端的业务请求,其结构示意图如图11所示,具体包括:
数量获取单元1101,用于获取所述服务器的所述多队列网卡的网卡队列数;
进程创建单元1102,用于创建与所述网卡队列数相等数量的进程;
线程创建单元1103,用于在每个进程中创建一个监听线程和多个工作线程;
绑定单元1104,用于将创建的每个监听线程分别与不同的网卡队列绑定。
进一步的,所述服务器具有多硬件核处理器;
绑定单元1104,具体用于将创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,将所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量。
进一步的,绑定单元1104,还用于将每个进程中创建的工作线程绑定一个硬件核。
进一步的,不同进程中创建的工作线程绑定的硬件核不同。
进一步的,线程创建单元1103,还用于当所述服务器的多硬件核处理器的硬件核增加时,针对每个增加的硬件核,在一个进程中创建新的工作线程;
绑定单元1104,还用于将创建的新的工作线程与新增加的该硬件核绑定。
进一步的,进程创建单元1102,还用于当所述服务器的多队列网卡的网卡队列增加时,针对每个增加的网卡队列创建新进程;
线程创建单元1103,还用于在创建的新进程中创建监听线程和工作线程;
绑定单元1104,还用于将在新进程中创建的监听线程与新增加的该网卡队列绑定。
进一步的,线程创建单元1103,还用于当一个进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
还用于当一个进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
上述进程和线程的创建装置中各单元的功能可对应于图2、图3、图6和 图7所示流程中的相应处理步骤,在此不再赘述。
实施例4:
基于同一发明构思,根据本发明上述实施例提供的应用于多队列网卡的业务请求处理方法,相应地,本发明实施例4还提供了一种业务请求处理装置,应用于服务器的多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,其结构示意图如图12所示,具体包括:
业务请求获取单元1201,用于从所述多队列网卡的网卡队列中获取来自客户端的业务请求;
第一发送单元1202,用于向与该网卡队列绑定的监听线程发送所述业务请求;
接收单元1203,用于接收与该监听线程属于同一进程的工作线程对所述业务请求进行业务处理后发送的业务处理结果;
第二发送单元1204,用于向所述客户端返回所述业务处理结果。
进一步的,接收单元1203,还用于所述业务请求获取单元1201在从所述多队列网卡的网卡队列中获取来自客户端的业务请求之前,接收已创建的各监听线程分别发送的业务请求获取消息,所述业务请求获取消息中携带监听线程绑定的网卡队列的队列标识;
所述装置,还包括:
绑定关系确定单元1205,用于确定发送所述业务请求获取消息的监听线程,与所述业务请求获取消息中携带的所述队列标识对应的网卡队列相绑定。
进一步的,服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器 中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
第一发送单元1202,具体用于向与该网卡队列绑定的目标硬件核上运行的监听线程发送所述业务请求。
进一步的,每个进程中创建的工作线程绑定一个硬件核。
进一步的,不同进程中创建的工作线程绑定的硬件核不同。
上述图12所示的业务请求处理装置中的各单元的功能可对应于图8、图9和图10所示流程中的相应处理步骤,在此不再赘述。
实施例5:
基于同一发明构思,根据本发明上述实施例提供的应用于监听线程的业务请求处理法,相应地,本发明实施例5还提供了一种业务请求处理装置,应用于服务器上创建的监听线程,所述服务器具有多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,其结构示意图如图13所示,具体包括:
接收单元1301,用于接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求;
第一发送单元1302,用于向与该监听线程属于同一进程的处于空闲状态的工作线程发送所述业务请求,用于指示所述工作线程对所述业务请求进行业务处理,并将得到的业务处理结果发送给所述多队列网卡。
进一步的,还包括:
第二发送单元1303,用于在所述接收单元1301接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求之前,向所述多队列网卡发送业务请求获取消息,所述业务请求获取消息中携带所述监听线程绑定的网卡队列的队列标识,用于所述多队列网卡确定所述监 听线程与所述队列标识对应的网卡队列相绑定。
进一步的,所述服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
接收单元1301,具体用于接收所述服务器的多队列网卡发送的从与运行该监听线程的目标硬件核绑定的网卡队列中获取的来自客户端的业务请求。
进一步的,每个进程中创建的工作线程绑定一个硬件核。
进一步的,不同进程中创建的工作线程绑定的硬件核不同。
进一步的,还包括:
线程创建单元1304,用于当所述监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
用于当所述监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
上述图13所示的业务请求处理装置中的各单元的功能可对应于图8、图9和图10所示流程中的相应处理步骤,在此不再赘述。
实施例6:
基于同一发明构思,根据本发明上述实施例提供的线程创建方法,相应地,本发明实施例6还提供了一种服务器,其结构示意图如图14所示,具体包括:
多队列网卡1401,用于接收来自客户端的业务请求,并在自身的网卡队列中存储来自客户端的业务请求;
处理器1402,用于获取所述服务器的所述多队列网卡的网卡队列数;并创建与所述网卡队列数相等数量的进程;并在每个进程中创建一个监听线程和多个工作线程;以及将创建的每个监听线程分别与不同的网卡队列绑定。
进一步的,处理器为多硬件核处理器;
处理器1402,具体用于将创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,将所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量。
进一步的,处理器1402,还用于将每个进程中创建的工作线程绑定一个硬件核。
进一步的,不同进程中创建的工作线程绑定的硬件核不同。
进一步的,处理器1402,还用于当所述服务器的多硬件核处理器的硬件核增加时,针对每个增加的硬件核,在一个进程中创建新的工作线程;并将创建的新的工作线程与新增加的该硬件核绑定。
进一步的,处理器1402,还用于当所述服务器的多队列网卡的网卡队列增加时,针对每个增加的网卡队列创建新进程;并在创建的新进程中创建一个监听线程和多个工作线程;以及将在新进程中创建的监听线程与新增加的该网卡队列绑定。
进一步的,处理器1402,还用于当一个进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
当一个进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量 阈值。
实施例7:
基于同一发明构思,根据本发明上述实施例提供的应用于多队列网卡的业务请求处理方法,相应地,本发明实施例7还提供了一种服务器的多队列网卡,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,其结构示意图如图15所示,具体包括:
接口1501,用于接收来自客户端的业务请求,并存储到网卡队列中;
处理芯片1502,用于从多队列网卡的网卡队列中获取来自客户端的业务请求;并向与该网卡队列绑定的监听线程发送所述业务请求;并接收与该监听线程属于同一进程的工作线程对所述业务请求进行业务处理后发送的业务处理结果;以及向所述客户端返回所述业务处理结果;
存储器1503,用于存储网卡队列中的来自客户端的业务请求。
进一步的,处理芯片1502,还用于在从多队列网卡的网卡队列中获取来自客户端的业务请求之前,接收已创建的各监听线程分别发送的业务请求获取消息,所述业务请求获取消息中携带监听线程绑定的网卡队列的队列标识;
确定发送所述业务请求获取消息的监听线程,与所述业务请求获取消息中携带的所述队列标识对应的网卡队列相绑定。
进一步的,所述服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
处理芯片1502,具体用于向与该网卡队列绑定的目标硬件核上运行的监听线程发送所述业务请求。
进一步的,每个进程中创建的工作线程绑定一个硬件核。
进一步的,不同进程中创建的工作线程绑定的硬件核不同。
综上所述,本发明实施例提供的方案,包括:获取服务器的多队列网卡的网卡队列数;并创建与网卡队列数相等数量的进程;并在每个进程中创建一个监听线程和多个工作线程;以及将创建的每个监听线程分别与不同的网卡队列绑定。采用本发明实施例提供的方案,使得进程和线程创建更合理,且提高了服务器对并发的业务请求的处理效率。
并且,通过监听线程,利用多队列网卡与系统硬件计算单元(硬件核)绑定的特性,将需要监听业务请求的监听线程依次部署在相应的硬件核上,可以达到能够同时监听多个来自网络客户端的业务请求。由网卡驱动并行地转发业务请求到各个监听线程,改善了传统服务器系统中串行转发业务请求所带来的性能问题。同时,可以使得同一时刻内有更多的工作线程对业务请求进行业务处理。
并且,本发明实施例提供的方案具有可扩展性(Scalability)。这里提到的可扩展性指的是,在更新硬件资源,提高处理器计算能力以及网络处理能力的同时,如增加新的硬件核和新的网卡队列时,通过相应的创建新的进程和/或线程,整个系统的性能可以有效地得到提高。
本发明实施例提供的方案,利用了多内核操作系统线性扩展的优势,针对服务器的模型进行了进程线程部署。这种新的结构,在计算单元数量很大时,继续增加硬件资源,依然可以有效地改善服务器的性能。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产 品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (36)

  1. 一种线程创建方法,应用于具有多队列网卡的服务器,所述多队列网卡的网卡队列中存储来自客户端的业务请求,其特征在于,包括:
    获取所述服务器的所述多队列网卡的网卡队列数;
    创建与所述网卡队列数相等数量的进程;
    在每个进程中创建一个监听线程和多个工作线程;
    将创建的每个监听线程分别与不同的网卡队列绑定。
  2. 如权利要求1所述的方法,其特征在于,所述服务器具有多硬件核处理器;
    将创建的每个监听线程分别与不同的网卡队列绑定,包括:
    将创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,将所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量。
  3. 如权利要求2所述的方法,其特征在于,还包括:
    将每个进程中创建的工作线程绑定一个硬件核。
  4. 如权利要求3所述的方法,其特征在于,不同进程中创建的工作线程绑定的硬件核不同。
  5. 如权利要求2-4任一所述的方法,其特征在于,还包括:
    当所述服务器的多硬件核处理器的硬件核增加时,针对每个增加的硬件核,在一个进程中创建新的工作线程;
    将创建的新的工作线程与新增加的该硬件核绑定。
  6. 如权利要求1-4任一所述的方法,其特征在于,还包括:
    当所述服务器的多队列网卡的网卡队列增加时,针对每个增加的网卡队列创建新进程;
    在创建的新进程中创建一个监听线程和多个工作线程;
    将在新进程中创建的监听线程与新增加的该网卡队列绑定。
  7. 如权利要求1-4任一所述的方法,其特征在于,还包括:
    当一个进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
    当一个进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
  8. 一种业务请求处理方法,应用于服务器的多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,其特征在于,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,所述方法包括:
    所述多队列网卡从自身的网卡队列中获取来自客户端的业务请求;
    向与该网卡队列绑定的监听线程发送所述业务请求;
    接收与该监听线程属于同一进程的工作线程对所述业务请求进行业务处理后发送的业务处理结果;
    向所述客户端返回所述业务处理结果。
  9. 如权利要求8所述的方法,其特征在于,在从自身的网卡队列中获取来自客户端的业务请求之前,还包括:
    接收已创建的各监听线程分别发送的业务请求获取消息,所述业务请求获取消息中携带监听线程绑定的网卡队列的队列标识;
    确定发送所述业务请求获取消息的监听线程,与所述业务请求获取消息中携带的所述队列标识对应的网卡队列相绑定。
  10. 如权利要求8所述的方法,其特征在于,所述服务器具有多硬件核处 理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
    向与该网卡队列绑定的监听线程发送所述业务请求,包括:
    向与该网卡队列绑定的目标硬件核上运行的监听线程发送所述业务请求。
  11. 如权利要求10所述的方法,其特征在于,每个进程中创建的工作线程绑定一个硬件核。
  12. 如权利要求11所述的方法,其特征在于,不同进程中创建的工作线程绑定的硬件核不同。
  13. 一种业务请求处理方法,应用于服务器上创建的监听线程,所述服务器具有多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,其特征在于,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,所述方法包括:
    监听线程接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求;
    向与该监听线程属于同一进程的处于空闲状态的工作线程发送所述业务请求,用于指示该工作线程对所述业务请求进行业务处理,并将得到的业务处理结果发送给所述多队列网卡。
  14. 如权利要求13所述的方法,其特征在于,在接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求之前,还包括:
    向所述多队列网卡发送业务请求获取消息,所述业务请求获取消息中携带该监听线程绑定的网卡队列的队列标识,用于所述多队列网卡确定该监听线程 与所述队列标识对应的网卡队列相绑定。
  15. 如权利要求13所述的方法,其特征在于,所述服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
    监听线程接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求,包括:
    监听线程接收所述服务器的多队列网卡发送的从与运行该监听线程的目标硬件核绑定的网卡队列中获取的来自客户端的业务请求。
  16. 如权利要求15所述的方法,其特征在于,每个进程中创建的工作线程绑定一个硬件核。
  17. 如权利要求16所述的方法,其特征在于,不同进程中创建的工作线程绑定的硬件核不同。
  18. 如权利要求13-17任一所述的方法,其特征在于,还包括:
    当该监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
    当该监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
  19. 一种线程创建装置,应用于具有多队列网卡的服务器,所述多队列网卡的网卡队列中存储来自客户端的业务请求,其特征在于,包括:
    数量获取单元,用于获取所述服务器的所述多队列网卡的网卡队列数;
    进程创建单元,用于创建与所述网卡队列数相等数量的进程;
    线程创建单元,用于在每个进程中创建一个监听线程和多个工作线程;
    绑定单元,用于将创建的每个监听线程分别与不同的网卡队列绑定。
  20. 如权利要求19所述的装置,其特征在于,所述服务器具有多硬件核处理器;
    所述绑定单元,具体用于将创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,将所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量。
  21. 如权利要求20所述的装置,其特征在于,所述绑定单元,还用于将每个进程中创建的工作线程绑定一个硬件核。
  22. 如权利要求21所述的装置,其特征在于,不同进程中创建的工作线程绑定的硬件核不同。
  23. 如权利要求20-22任一所述的装置,其特征在于,所述线程创建单元,还用于当所述服务器的多硬件核处理器的硬件核增加时,针对每个增加的硬件核,在一个进程中创建新的工作线程;
    所述绑定单元,还用于将创建的新的工作线程与新增加的该硬件核绑定。
  24. 如权利要求19-22任一所述的装置,其特征在于,所述进程创建单元,还用于当所述服务器的多队列网卡的网卡队列增加时,针对每个增加的网卡队列创建新进程;
    所述线程创建单元,还用于在创建的新进程中创建监听线程和工作线程;
    所述绑定单元,还用于将在新进程中创建的监听线程与新增加的该网卡队列绑定。
  25. 如权利要求19-22任一所述的装置,其特征在于,所述线程创建单元,还用于当一个进程中创建的工作线程中处于空闲状态的工作线程的数量小于 第一预设数量阈值时,在该进程中创建新的工作线程;和/或
    还用于当一个进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
  26. 一种业务请求处理装置,应用于服务器的多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,其特征在于,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,所述装置包括:
    业务请求获取单元,用于从所述多队列网卡的网卡队列中获取来自客户端的业务请求;
    第一发送单元,用于向与该网卡队列绑定的监听线程发送所述业务请求;
    接收单元,用于接收与该监听线程属于同一进程的工作线程对所述业务请求进行业务处理后发送的业务处理结果;
    第二发送单元,用于向所述客户端返回所述业务处理结果。
  27. 如权利要求26所述的装置,其特征在于,所述接收单元,还用于所述业务请求获取单元在从所述多队列网卡的网卡队列中获取来自客户端的业务请求之前,接收已创建的各监听线程分别发送的业务请求获取消息,所述业务请求获取消息中携带监听线程绑定的网卡队列的队列标识;
    所述装置,还包括:
    绑定关系确定单元,用于确定发送所述业务请求获取消息的监听线程,与所述业务请求获取消息中携带的所述队列标识对应的网卡队列相绑定。
  28. 如权利要求26所述的装置,其特征在于,所述服务器具有多硬件核处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的 硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
    所述第一发送单元,具体用于向与该网卡队列绑定的目标硬件核上运行的监听线程发送所述业务请求。
  29. 如权利要求28所述的装置,其特征在于,每个进程中创建的工作线程绑定一个硬件核。
  30. 如权利要求29所述的装置,其特征在于,不同进程中创建的工作线程绑定的硬件核不同。
  31. 一种业务请求处理装置,应用于服务器上创建的监听线程,所述服务器具有多队列网卡,所述多队列网卡的网卡队列中存储来自客户端的业务请求,其特征在于,所述服务器上创建有与所述多队列网卡的网卡队列数相等数量的进程,且每个进程中创建有一个监听线程和多个工作线程,且创建的每个监听线程分别与不同的网卡队列绑定,所述装置包括:
    接收单元,用于接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求;
    第一发送单元,用于向与该监听线程属于同一进程的处于空闲状态的工作线程发送所述业务请求,用于指示所述工作线程对所述业务请求进行业务处理,并将得到的业务处理结果发送给所述多队列网卡。
  32. 如权利要求31所述的装置,其特征在于,还包括:
    第二发送单元,用于在所述接收单元接收所述服务器的多队列网卡发送的从与该监听线程绑定的网卡队列中获取的来自客户端的业务请求之前,向所述多队列网卡发送业务请求获取消息,所述业务请求获取消息中携带所述监听线程绑定的网卡队列的队列标识,用于所述多队列网卡确定所述监听线程与所述队列标识对应的网卡队列相绑定。
  33. 如权利要求31所述的装置,其特征在于,所述服务器具有多硬件核 处理器,创建的每个监听线程分别与所述多硬件核处理器中的不同的目标硬件核绑定,且所述多队列网卡中的每个网卡队列分别与所述目标硬件核中不同的硬件核绑定,从而实现创建的每个监听线程分别与不同的网卡队列绑定;其中,所述目标硬件核为所述多硬件核处理器中用于绑定所述监听线程和所述网卡队列的所有硬件核,所述网卡队列的数量等于所述目标硬件核的数量;
    所述接收单元,具体用于接收所述服务器的多队列网卡发送的从与运行该监听线程的目标硬件核绑定的网卡队列中获取的来自客户端的业务请求。
  34. 如权利要求33所述的装置,其特征在于,每个进程中创建的工作线程绑定一个硬件核。
  35. 如权利要求34所述的装置,其特征在于,不同进程中创建的工作线程绑定的硬件核不同。
  36. 如权利要求31-35任一所述的装置,其特征在于,还包括:
    线程创建单元,用于当该监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量小于第一预设数量阈值时,在该进程中创建新的工作线程;和/或
    用于当该监听线程所属进程中创建的工作线程中处于空闲状态的工作线程的数量大于第二预设数量阈值时,在该进程中撤销处于空闲状态的工作线程,且撤销后该进程中创建的工作线程中处于空闲状态的工作线程的数量不大于第二预设数量阈值。
PCT/CN2014/094208 2013-12-26 2014-12-18 线程创建方法、业务请求处理方法及相关设备 WO2015096656A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP14873894.1A EP3073374B1 (en) 2013-12-26 2014-12-18 Thread creation method, service request processing method and related device
US15/191,996 US20160306680A1 (en) 2013-12-26 2016-06-24 Thread creation method, service request processing method, and related device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310733930.3A CN104750543B (zh) 2013-12-26 2013-12-26 线程创建方法、业务请求处理方法及相关设备
CN201310733930.3 2013-12-26

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/191,996 Continuation US20160306680A1 (en) 2013-12-26 2016-06-24 Thread creation method, service request processing method, and related device

Publications (1)

Publication Number Publication Date
WO2015096656A1 true WO2015096656A1 (zh) 2015-07-02

Family

ID=53477531

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/094208 WO2015096656A1 (zh) 2013-12-26 2014-12-18 线程创建方法、业务请求处理方法及相关设备

Country Status (4)

Country Link
US (1) US20160306680A1 (zh)
EP (1) EP3073374B1 (zh)
CN (1) CN104750543B (zh)
WO (1) WO2015096656A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110333916A (zh) * 2019-06-18 2019-10-15 平安银行股份有限公司 请求消息处理方法、装置、计算机系统及可读存储介质
CN112702338A (zh) * 2020-12-22 2021-04-23 杭州迪普科技股份有限公司 Ike报文获取方法及装置
CN112801559A (zh) * 2021-04-09 2021-05-14 恒生电子股份有限公司 业务请求的处理方法、装置、设备和存储介质

Families Citing this family (36)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10452450B2 (en) 2015-03-20 2019-10-22 International Business Machines Corporation Optimizing allocation of multi-tasking servers
CN105631708B (zh) * 2015-12-25 2020-10-16 腾讯科技(深圳)有限公司 一种信息处理方法及装置
CN111274015A (zh) * 2016-08-31 2020-06-12 华为技术有限公司 一种配置方法、装置和数据处理服务器
CN107818056B (zh) * 2016-09-14 2021-09-07 华为技术有限公司 一种队列管理方法及装置
US20180088960A1 (en) * 2016-09-23 2018-03-29 International Business Machines Corporation Providing highly available and scalable access to a restricted access service through a restful interface
CN106412088B (zh) * 2016-10-25 2019-10-18 深圳市万普拉斯科技有限公司 一种数据同步方法及终端
CN106789152A (zh) * 2016-11-17 2017-05-31 东软集团股份有限公司 基于多队列网卡的处理器扩展方法及装置
CN106708628A (zh) * 2016-12-29 2017-05-24 北京奇虎科技有限公司 基于工作线程压力优化的连接建立方法及装置
CN107317759A (zh) * 2017-06-13 2017-11-03 国家计算机网络与信息安全管理中心 一种网卡的线程级动态均衡调度方法
CN107315385B (zh) * 2017-06-26 2019-08-06 杭州电子科技大学 嵌入式plc引擎实现方法和引擎
CN107450854B (zh) * 2017-08-07 2020-09-18 苏州浪潮智能科技有限公司 一种期望速率下最大线程数的确定方法及系统
US10719350B2 (en) * 2017-10-10 2020-07-21 Sap Se Worker thread manager
CN107682198A (zh) * 2017-10-20 2018-02-09 盛科网络(苏州)有限公司 一种网络通信设备
CN107945354A (zh) * 2017-11-20 2018-04-20 浪潮金融信息技术有限公司 排队叫号方法及系统、计算机存储介质和终端
CN108881063B (zh) * 2017-12-29 2019-06-28 视联动力信息技术股份有限公司 一种数据发送方法和装置
CN108427603A (zh) * 2018-01-10 2018-08-21 链家网(北京)科技有限公司 一种任务分派方法方法及装置
CN108763046B (zh) * 2018-06-01 2024-04-05 中国平安人寿保险股份有限公司 线程运行监控方法、装置、计算机设备和存储介质
CN108958944A (zh) * 2018-07-26 2018-12-07 郑州云海信息技术有限公司 一种多核处理系统及其任务分配方法
CN111124655A (zh) * 2018-10-31 2020-05-08 武汉斗鱼网络科技有限公司 一种网络请求调度方法、终端装置及存储介质
CN109684064A (zh) * 2018-12-26 2019-04-26 亚信科技(中国)有限公司 一种任务调度方法及任务调度设备
CN110134531A (zh) * 2019-05-06 2019-08-16 广州华多网络科技有限公司 虚拟资产流转数据的处理方法、装置和计算机设备
CN110505164B (zh) * 2019-07-25 2022-05-31 联想(北京)有限公司 虚拟设备的处理方法及电子设备
CN110908784B (zh) * 2019-11-12 2022-09-20 苏州智加科技有限公司 图像标注方法、装置、设备及存储介质
CN111104183B (zh) * 2019-12-17 2023-09-12 北京小米移动软件有限公司 应用程序运行方法、装置、电子设备及存储介质
CN111338787B (zh) * 2020-02-04 2023-09-01 浙江大华技术股份有限公司 一种数据处理方法及装置、存储介质、电子装置
CN111400002B (zh) * 2020-03-09 2022-09-27 聚好看科技股份有限公司 应用进程与处理器核绑定方法及终端
CN111541646A (zh) * 2020-03-24 2020-08-14 成都国泰网信科技有限公司 一种增强密码机安全服务接入能力的方法
CN112217883B (zh) * 2020-09-25 2023-01-10 苏州浪潮智能科技有限公司 一种基于nfs协议的多通道构建方法、装置和系统
US20220188144A1 (en) * 2020-12-11 2022-06-16 Oracle International Corporation Intra-Process Caching and Reuse of Threads
CN112667318A (zh) * 2020-12-31 2021-04-16 京信网络系统股份有限公司 逻辑核的绑定方法、装置、设备及存储介质
CN112988416B (zh) * 2021-03-02 2023-06-30 杭州迪普科技股份有限公司 报文处理方法、装置、设备及计算机可读存储介质
US20210326177A1 (en) * 2021-06-26 2021-10-21 Intel Corporation Queue scaling based, at least, in part, on processing load
CN114138471B (zh) * 2021-11-18 2024-04-19 苏州浪潮智能科技有限公司 一种软件业务绑定cpu核心的方法及相关装置
CN114257561B (zh) * 2021-12-17 2023-02-07 东土科技(宜昌)有限公司 一种串口网口的数据透传方法及装置、设备、存储介质
CN115296958B (zh) * 2022-06-28 2024-03-22 青岛海尔科技有限公司 设备控制任务的分发方法、装置、存储介质及电子装置
CN115499346B (zh) * 2022-09-15 2024-04-26 巨擎网络科技(济南)有限公司 一种多网卡的测速方法、装置、设备及介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101631139A (zh) * 2009-05-19 2010-01-20 华耀环宇科技(北京)有限公司 基于多核平台的负载均衡软件架构及方法
CN102497322A (zh) * 2011-12-19 2012-06-13 曙光信息产业(北京)有限公司 一种基于分流网卡和多核cpu实现的高速包过滤设备和方法
CN102769575A (zh) * 2012-08-08 2012-11-07 南京中兴特种软件有限责任公司 一种用于智能网卡的流量负载均衡方法

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6477586B1 (en) * 1998-06-29 2002-11-05 International Business Machines Corporation Remote procedure calls in distributed systems
US6625639B1 (en) * 1999-10-20 2003-09-23 International Business Machines Corporation Apparatus and method for processing a task in a clustered computing environment
US7051330B1 (en) * 2000-11-21 2006-05-23 Microsoft Corporation Generic application server and method of operation therefor
US7076545B2 (en) * 2002-07-31 2006-07-11 Sun Microsystems, Inc. Load balancing the servicing of received packets
US7631106B2 (en) * 2002-08-15 2009-12-08 Mellanox Technologies Ltd. Prefetching of receive queue descriptors
US7418719B2 (en) * 2004-08-31 2008-08-26 Microsoft Corporation Method and system to support a unified process model for handling messages sent in different protocols
US8032900B2 (en) * 2006-08-02 2011-10-04 Microsoft Corporation Conducting client-server inter-process communication
US8185906B2 (en) * 2007-05-23 2012-05-22 Sap Ag Method and apparatus for dynamically adjusting thread pool
JP5681465B2 (ja) * 2010-12-02 2015-03-11 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation 情報処理システム、情報処理装置、準備方法、プログラムおよび記録媒体
US8832690B1 (en) * 2011-06-21 2014-09-09 Google Inc. Multi-threaded virtual machine processing on a web page
CN102591715B (zh) * 2012-01-05 2014-02-12 北京航空航天大学 一种使用多队列技术的虚拟机网络性能优化的实现方法
CN102916905A (zh) * 2012-10-18 2013-02-06 曙光信息产业(北京)有限公司 一种基于hash算法的万兆网卡多路分流方法及其系统
US9280388B2 (en) * 2013-01-22 2016-03-08 Oracle International Corporation Method and apparatus for efficient scheduling of multithreaded programs
US10027605B2 (en) * 2013-08-26 2018-07-17 Vmware, Inc. Traffic and load aware dynamic queue management

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101631139A (zh) * 2009-05-19 2010-01-20 华耀环宇科技(北京)有限公司 基于多核平台的负载均衡软件架构及方法
CN102497322A (zh) * 2011-12-19 2012-06-13 曙光信息产业(北京)有限公司 一种基于分流网卡和多核cpu实现的高速包过滤设备和方法
CN102769575A (zh) * 2012-08-08 2012-11-07 南京中兴特种软件有限责任公司 一种用于智能网卡的流量负载均衡方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3073374A4 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110333916A (zh) * 2019-06-18 2019-10-15 平安银行股份有限公司 请求消息处理方法、装置、计算机系统及可读存储介质
CN110333916B (zh) * 2019-06-18 2024-03-19 平安银行股份有限公司 请求消息处理方法、装置、计算机系统及可读存储介质
CN112702338A (zh) * 2020-12-22 2021-04-23 杭州迪普科技股份有限公司 Ike报文获取方法及装置
CN112702338B (zh) * 2020-12-22 2022-07-01 杭州迪普科技股份有限公司 Ike报文获取方法及装置
CN112801559A (zh) * 2021-04-09 2021-05-14 恒生电子股份有限公司 业务请求的处理方法、装置、设备和存储介质

Also Published As

Publication number Publication date
CN104750543B (zh) 2018-06-15
US20160306680A1 (en) 2016-10-20
EP3073374A4 (en) 2016-12-07
EP3073374A1 (en) 2016-09-28
EP3073374B1 (en) 2019-02-06
CN104750543A (zh) 2015-07-01

Similar Documents

Publication Publication Date Title
WO2015096656A1 (zh) 线程创建方法、业务请求处理方法及相关设备
Qin et al. Arachne:{Core-Aware} Thread Management
US8949847B2 (en) Apparatus and method for managing resources in cluster computing environment
CN105045658B (zh) 一种利用多核嵌入式dsp实现动态任务调度分发的方法
US20150052254A1 (en) Virtual Machine Live Migration Method, Virtual Machine Deployment Method, Server, and Cluster System
Sengupta et al. Scheduling multi-tenant cloud workloads on accelerator-based systems
CN109564528B (zh) 分布式计算中计算资源分配的系统和方法
CN104102548B (zh) 任务资源调度处理方法和系统
US9104488B2 (en) Support server for redirecting task results to a wake-up server
CN103150213A (zh) 负载平衡方法和装置
US8352950B2 (en) Algorithm to share physical processors to maximize processor cache usage and topologies
CN110990154B (zh) 一种大数据应用优化方法、装置及存储介质
Takouna et al. Communication-aware and energy-efficient scheduling for parallel applications in virtualized data centers
WO2023071576A1 (zh) 容器集群构建方法及系统
CN108170417B (zh) 一种在mesos集群中集成高性能的作业调度框架的方法和装置
Diab et al. Dynamic sharing of GPUs in cloud systems
Zhao et al. Efficient sharing and fine-grained scheduling of virtualized GPU resources
EP3084603B1 (en) System and method for supporting adaptive busy wait in a computing environment
CN112799811B (zh) 一种边缘网关的高并发线程池任务调度方法
Xu et al. vPFS: Bandwidth virtualization of parallel storage systems
CN107493574B (zh) 无线控制器设备、并行认证处理方法、系统、组网装置
JP6283376B2 (ja) クラスタにおけるワークシェアリング多重化をサポートするためのシステムおよび方法
Gu et al. Elastic model aggregation with parameter service
Peng et al. BQueue: A coarse-grained bucket QoS scheduler
Chen et al. A performance study of virtual machine migration vs. thread migration for grid systems

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: 14873894

Country of ref document: EP

Kind code of ref document: A1

REEP Request for entry into the european phase

Ref document number: 2014873894

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2014873894

Country of ref document: EP

NENP Non-entry into the national phase

Ref country code: DE