CN105791254B - Network request processing method and device and terminal - Google Patents

Network request processing method and device and terminal Download PDF

Info

Publication number
CN105791254B
CN105791254B CN201410834995.1A CN201410834995A CN105791254B CN 105791254 B CN105791254 B CN 105791254B CN 201410834995 A CN201410834995 A CN 201410834995A CN 105791254 B CN105791254 B CN 105791254B
Authority
CN
China
Prior art keywords
concurrent
threads
configuration
requests
thread pool
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201410834995.1A
Other languages
Chinese (zh)
Other versions
CN105791254A (en
Inventor
黄珠唐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Singapore Holdings Pte Ltd
Original Assignee
Alibaba Group Holding Ltd
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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201410834995.1A priority Critical patent/CN105791254B/en
Publication of CN105791254A publication Critical patent/CN105791254A/en
Application granted granted Critical
Publication of CN105791254B publication Critical patent/CN105791254B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The application discloses a network request processing method, a network request processing device and a terminal, wherein the method comprises the following steps: generating a concurrent thread pool according to the acquired configuration strategy, wherein the configuration strategy is acquired according to the configuration parameters of the terminal; and distributing threads in the concurrent thread pool for the concurrent network requests according to the number of the received concurrent requests of the concurrent network requests. According to the embodiment of the application, the dynamically adjusted configuration strategy can be obtained according to different terminal configuration parameters, so that a thread adaptive to the terminal performance can be generated according to the configuration strategy, the resources of the terminal are reasonably utilized, and the optimal access speed of the terminal to a network is ensured.

Description

Network request processing method and device and terminal
Technical Field
The present application relates to the field of network communication technologies, and in particular, to a method, an apparatus, and a terminal for processing a network request.
Background
With the development of intelligent terminals and the popularization of network environments, a user can access a network through an application client installed on the terminal, and may receive multiple network requests for opening applications at the same time in the access process, which is also called network request concurrency, and when the concurrency number is large, the processing speed of the terminal is reduced, so that a fixed concurrency number is preset in the prior art.
However, since the performances of different terminals are different, it is difficult to adapt the fixed concurrency number to the performances of the terminals, for example, the concurrency number of network requests that the terminal performance can handle is greater than the fixed concurrency number, which may cause resource waste of the terminal and affect the access speed of the terminal to the network.
Disclosure of Invention
The application provides a network request processing method, a network request processing device and a terminal, and aims to solve the problems that in the prior art, the network access speed of the terminal is influenced due to the fact that the fixed network request concurrency number is set, and the terminal performance is difficult to adapt.
According to a first aspect of embodiments of the present application, a method for processing a network request is provided, where the method includes:
generating a concurrent thread pool according to the acquired configuration strategy, wherein the configuration strategy is acquired according to the configuration parameters of the terminal;
judging whether the number of the received concurrent requests is larger than the number of the concurrent threads in the concurrent thread pool or not;
and when the quantity of the concurrent requests is greater than the quantity of the concurrent threads, distributing the threads in the concurrent thread pool for the concurrent network requests according to the service priority of each network request in the concurrent network requests.
According to a second aspect of embodiments of the present application, there is provided a network request processing apparatus, the apparatus including:
the obtaining unit is used for obtaining a configuration strategy according to the configuration parameters of the terminal;
the generating unit is used for generating a concurrent thread pool according to the configuration strategy;
a receiving unit, configured to receive concurrent network requests;
the judging unit is used for judging whether the number of the received concurrent requests is larger than the number of the concurrent threads in the concurrent thread pool or not;
and the allocating unit is used for allocating the threads in the concurrent thread pool to the concurrent network requests according to the service priority of each network request in the concurrent network requests when the number of the concurrent requests is greater than the number of the concurrent threads.
According to a third aspect of embodiments of the present application, there is provided a terminal, including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to:
generating a concurrent thread pool according to the acquired configuration strategy, wherein the configuration strategy is acquired according to the configuration parameters of the terminal;
judging whether the number of the received concurrent requests is larger than the number of the concurrent threads in the concurrent thread pool or not;
and when the quantity of the concurrent requests is greater than the quantity of the concurrent threads, distributing the threads in the concurrent thread pool for the concurrent network requests according to the service priority of each network request in the concurrent network requests.
In the embodiment of the application, after the terminal obtains the configuration policy according to the configuration parameters, the terminal can generate the concurrent thread pool according to the configuration policy, and when the concurrent network requests are received, the terminal allocates threads in the concurrent thread pool for the concurrent network requests according to the number of the concurrent requests. By applying the embodiment of the application, the dynamically adjusted configuration strategy can be obtained according to different terminal configuration parameters, so that a thread adaptive to the terminal performance can be generated according to the configuration strategy, the resources of the terminal are reasonably utilized, and the optimal access speed of the terminal to the network is ensured.
Drawings
FIG. 1 is a flow chart of one embodiment of a network request processing method of the present application;
FIG. 2 is a schematic diagram of an application scenario in which an embodiment of network request processing is applied;
FIG. 3 is a flow chart of another embodiment of a network request processing method of the present application;
fig. 4 is a hardware configuration diagram of a terminal where a network request processing device is located according to the present application;
fig. 5 is a block diagram of an embodiment of a network request processing apparatus according to the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
Referring to fig. 1, it is a flowchart of an embodiment of a network request processing method according to the present application, where the embodiment can be applied to a terminal side, and includes the following steps:
step 101: and generating a concurrency thread pool according to the acquired configuration strategy, wherein the configuration strategy is acquired according to the configuration parameters of the terminal.
The terminal in the present application includes various client devices having a network access function, such as a smart phone, a tablet computer, a PDA (Personal Digital Assistant), and the like. The configuration parameters of the terminal may specifically include a parameter type and a parameter value, where the parameter type may include: network type, Central Processing Unit (CPU) core number, terminal model, country or region where the terminal is located, and the like; the parameter value refers to specific content of a certain parameter type, and taking the parameter type as a network type as an example, the parameter value may include a WIFI (Wireless-Fidelity, Wireless Fidelity) network, a 4G (fourth generation mobile communication) network, a 3G (third generation mobile communication) network, a 2G (second generation mobile communication) network, and the like.
The terminal can obtain the configuration strategy through interaction with the server in any one of the following modes:
in the first mode, the server issues the final configuration policy to the terminal.
The terminal sends the parameter value of the configuration parameter to the server, and receives a configuration strategy generated by the server for the terminal according to the parameter value of the configuration parameter, wherein the configuration strategy comprises the number of concurrent threads adapted to the parameter value of the configuration parameter. For example, in the configuration sub-policy in which the parameter type is a network type, a concurrency thread number a may be configured for a parameter value WIFI network, a concurrency thread number b may be configured for a parameter value 4G network, a concurrency thread number c may be configured for a parameter value 3G network, and a concurrency thread number d may be configured for a parameter value 2G network, it should be noted that the above example may be used as a general configuration sub-policy for a network type, and for a concurrency thread number corresponding to a specific parameter value, it may also be adjusted according to a special parameter value, for example, for a concurrency thread number d configured for a parameter value 2G network, when the region in which the terminal is located is a region K with a better network environment, if the terminal still uses the 2G network, the number of the concurrent threads corresponding to the 2G network can be adjusted to d ', and the d' is larger than d; after the server receives the parameter values of the terminal, the corresponding configuration sub-strategies are searched according to the parameter types of the parameter values, the number of the concurrent threads corresponding to the terminal under different configuration sub-strategies is obtained, and then the minimum number of the concurrent threads is selected from the concurrent threads as the configuration strategy finally generated for the terminal.
In the second mode, the server issues the configuration sub-strategy to the terminal, and the terminal generates the final configuration strategy.
The terminal sends a configuration request to the server, the configuration request comprises parameter types of configuration parameters, the server can configure corresponding configuration sub-strategies for each parameter type in advance, each configuration sub-strategy comprises the quantity of concurrent threads corresponding to different parameter values of each parameter type, when the server receives the parameter types of the terminal, the server returns the configuration sub-strategy corresponding to each parameter type to the terminal, the terminal generates the configuration strategy according to the parameter values of the configuration parameters and the configuration sub-strategies, the configuration policy includes the number of concurrent threads adapted to the parameter values of the configuration parameters, for example, the terminal may search the corresponding configuration sub-policy according to the parameter type of each parameter value to obtain the number of concurrent threads corresponding to the terminal under different configuration sub-policies, and then selecting the minimum number of concurrent threads from the configuration policy as the configuration policy finally generated by the terminal.
In the embodiment of the application, the terminal can obtain the configuration strategy when the terminal is started every time, and also can obtain the configuration strategy when the parameter value of the configuration parameter is monitored to change, so that the number of concurrent threads can be dynamically adjusted according to the actual performance of the terminal.
In the embodiment of the present application, when the terminal generates the concurrent thread pool according to the configuration policy, any one of the following manners may be adopted:
in a first manner, before receiving a concurrent network request, a terminal may obtain a number of concurrent threads adapted to a parameter value of a configuration parameter of the terminal, which is included in a configuration policy, and then generate a concurrent thread pool according to the number of concurrent threads, where the concurrent thread pool includes threads consistent with the number of concurrent threads.
In the second mode, the terminal can also obtain the quantity of the concurrent threads adapted to the configuration parameters according to the configuration strategy when receiving the concurrent network request, and then judge whether the quantity of the concurrent requests is less than the quantity of the concurrent threads; and when the judgment result is not less than the preset threshold, generating a concurrent thread pool according to the number of concurrent threads, wherein the concurrent thread pool comprises threads with the same number as the concurrent threads, and when the judgment result is less than the preset threshold, generating the concurrent thread pool according to the number of concurrent requests, wherein the concurrent thread pool comprises threads with the same number as the concurrent requests.
In a third mode, the terminal can also obtain the number of concurrent threads adapted to the configuration parameters according to the configuration policy when receiving the concurrent network request, and generate a concurrent thread pool according to the number of concurrent threads, wherein the concurrent thread pool contains threads with a preset thread number, the preset thread number is smaller than the concurrent thread number, and a difference value between the number of concurrent threads and the preset thread number is defined as the number of remaining threads; when the quantity of the concurrent requests is larger than the preset thread quantity, calculating the difference value between the quantity of the concurrent requests and the preset thread quantity as the difference thread quantity; and judging whether the number of the difference threads is smaller than the number of the residual threads, if so, increasing threads with the number consistent with the number of the difference threads in the concurrent thread pool, and if not, increasing the threads with the number consistent with the number of the residual threads in the concurrent thread pool.
Step 102: and distributing threads in the concurrent thread pool for the concurrent network requests according to the number of the received concurrent requests of the concurrent network requests.
Usually, after a terminal user starts a certain APP (Application) installed on a terminal, the APP can make a plurality of network requests concurrently in a network access process, at this time, the terminal judges whether the number of concurrent requests of the concurrent network requests is greater than the number of concurrent threads in a concurrent thread pool, when the number of concurrent requests is not greater than the number of concurrent threads, threads in the concurrent thread pool are sufficiently allocated to the concurrent network requests, and therefore, only one thread in the concurrent thread pool is allocated to each network request in the concurrent network requests; when the number of the concurrent requests is greater than the number of the concurrent threads, the threads in the concurrent thread pool are not sufficiently allocated to the concurrent network requests, so that the threads in the concurrent thread pool can be allocated to the concurrent network requests according to the service priority of each network request in the concurrent network requests, that is, the threads are preferentially allocated to the network requests with high service priority.
It can be seen from the above embodiments that the terminal can obtain a dynamically adjusted configuration policy according to different configuration parameters, and therefore, a thread adapted to the terminal performance can be generated according to the configuration policy, so that resources of the terminal are reasonably utilized, and an optimal access speed of the terminal to a network is ensured.
Referring to fig. 2, it is a schematic diagram of an application scenario in which the network request processing embodiment of the present application is applied:
in fig. 2, a terminal and a server are shown, the terminal being schematically a smart phone held by a user, the terminal being capable of interacting with the server through various networks.
The server is configured with strategy data set aiming at different configuration parameters of the terminal, the strategy data comprises the number of concurrent threads corresponding to different parameter values, the strategy data can be manually configured by a manager, and the strategy data can be dynamically adjusted according to needs to ensure that the strategy data can be adapted to the performance of various terminals, so that the terminal can dynamically adjust the number of concurrent requests of concurrent network requests according to the strategy data; and after obtaining the configuration policy according to the policy data on the server, the terminal may generate a concurrent thread pool according to the number of concurrent threads included in the configuration policy, and when receiving a concurrent network request, allocate the threads in the concurrent thread pool to the concurrent network request.
Referring to fig. 3, it is a flowchart of another embodiment of the network request processing method according to the present application, and this embodiment describes, in combination with the application scenario shown in fig. 2, a processing procedure of a terminal for a network request through interaction between the terminal and a server, and includes the following steps:
step 301: and the terminal sends the parameter values of the configuration parameters to the server.
The terminal in the present application includes various client devices with network access functions, such as a smart phone, a tablet computer, a PDA, and the like. The configuration parameters of the terminal may specifically include a parameter type and a parameter value, where the parameter type may include: network type, CPU core number, terminal machine type, country or region of terminal, etc.; the parameter value refers to specific content of a certain parameter type, and taking the parameter type as the number of CPU cores as an example, the parameter value may include three cores, two cores, and a single core.
In this embodiment, the terminal may send the parameter value of the current self-configuration parameter to the server when the terminal is powered on, or send the parameter value of the self-configuration parameter to the server when a certain parameter value changes.
Step 302: and the server generates a configuration strategy for the terminal according to the parameter value of the configuration parameter, wherein the configuration strategy comprises the number of concurrent threads adapted to the parameter value of the configuration parameter.
With reference to fig. 2, assuming that the configuration data on the server includes N configuration sub-policies (N is a natural number greater than 1) configured in advance for different parameter types, after receiving parameter values of M configuration parameters sent by the terminal (M is smaller than N), respectively searching corresponding configuration sub-policies according to the M parameter values to obtain the number of M concurrent threads, at this time, the server may use, according to a predefined rule, the final number of concurrent threads of the terminal determined according to the number of M concurrent threads as the configuration policy of the terminal, that is, the configuration policy includes the number of concurrent threads adapted to the parameter values of the configuration parameters of the terminal, for example, the server may select the smallest number of concurrent threads from the number of M concurrent threads as the final number of concurrent threads of the terminal.
In an application example, it is assumed that the server is configured with a network type configuration sub-policy as shown in table 1 below and a CPU core number configuration sub-policy as shown in table 2 below:
TABLE 1
Network type WIFI 4G 3G 2G
Number of concurrent threads 4 3 2 1
TABLE 2
Number of CPU cores Three-core Dual core Single core
Number of concurrent threads 3 2 1
When the server receives that the parameter value sent by the terminal includes that the network type is 'WIFI network' and the CPU core number is 'dual core', the sub-strategy can be configured according to the network type shown in a parameter value 'WIFI network' lookup table 1 to obtain the corresponding concurrent thread number of 4, meanwhile, the sub-strategy is configured according to the CPU core number shown in a parameter value 'dual core' lookup table 2 to obtain the corresponding concurrent thread number of 2, and then the server selects the smaller concurrent thread number 2 from the concurrent thread number of 4 and the concurrent thread number of 2 as the concurrent thread number of the terminal.
Step 303: and the terminal generates a concurrent thread pool according to the configuration strategy.
Step 304: the terminal receives the concurrent network request.
Step 305: the terminal judges whether the quantity of the concurrent requests of the concurrent network requests is larger than the quantity of the concurrent threads in the concurrent thread pool, if not, the step 306 is executed; if yes, go to step 307.
Step 306: and the terminal allocates a thread in a concurrent thread pool for each network request in the concurrent network requests and ends the current process.
When the number of the concurrent requests is not more than the number of the concurrent threads, the threads in the concurrent thread pool are sufficiently allocated to the concurrent network requests, so that the terminal can allocate one thread in the concurrent thread pool for each network request in the concurrent network requests.
Step 307: and the terminal allocates threads in the concurrent thread pool for the concurrent network requests according to the service priority of each network request in the concurrent network requests, and ends the current flow.
When the number of the concurrent requests is greater than the number of the concurrent threads, the threads in the concurrent thread pool are not sufficiently allocated to the concurrent network requests, so that the threads in the concurrent thread pool can be allocated to the concurrent network requests according to the service priority of each network request in the concurrent network requests, that is, the threads are preferentially allocated to the network requests with high service priority.
With reference to fig. 2, if the terminal generates a concurrent thread pool including three threads according to a configuration policy issued by the server, and when the received concurrent network requests include four network requests, the network requests may be inserted into the request queue according to the order of the service priorities of the four network requests from high to low, and assuming that the order of the service priorities from high to low is network request 1, network request 2, network request 3, and network request 4, the terminal may allocate the three threads to network request 1, network request 2, and network request 3, respectively.
It can be seen from the above embodiments that the terminal can obtain a dynamically adjusted configuration policy according to different configuration parameters, and therefore, a thread adapted to the terminal performance can be generated according to the configuration policy, so that resources of the terminal are reasonably utilized, and an optimal access speed of the terminal to a network is ensured.
Corresponding to the embodiment of the network request processing method, the application also provides embodiments of a network request processing device and a terminal.
The embodiment of the network request processing device can be applied to a terminal, and the embodiment of the device can be realized by software, or by hardware or a combination of the software and the hardware. Taking software implementation as an example, as a device in a logical sense, the CPU of the terminal where the device is located can read the corresponding computer program instructions in the nonvolatile memory into the memory for operation. From a hardware aspect, as shown in fig. 4, a hardware structure diagram of a terminal where the network request processing device is located in the present application is shown, in addition to the CPU, the memory, the network interface, and the nonvolatile memory shown in fig. 4, the terminal where the device is located may also include other hardware, which is not shown in fig. 4.
Referring to fig. 5, a block diagram of an embodiment of a network request processing apparatus according to the present application is shown:
the device includes: an obtaining unit 510, a generating unit 520, a receiving monocular 530, and an assigning unit 540.
The obtaining unit 510 is configured to obtain a configuration policy according to a configuration parameter of a terminal;
the generating unit 520 is configured to generate a concurrent thread pool according to the configuration policy;
the receiving unit 530 is configured to receive a concurrent network request;
the allocating unit 540 is configured to allocate threads in the concurrent thread pool to the concurrent network requests according to the number of concurrent requests of the concurrent network requests.
In an alternative implementation, the obtaining unit 510 may include (not shown in fig. 5):
the first sending subunit is configured to send a parameter value of the configuration parameter to a server;
a first receiving subunit, configured to receive a configuration policy generated by the server for the terminal according to the parameter value of the configuration parameter, where the configuration policy includes a number of concurrent threads adapted to the parameter value of the configuration parameter.
In another alternative implementation, the obtaining unit 510 may also include (not shown in fig. 5):
a second sending subunit, configured to send a configuration request to a server, where the configuration request includes a parameter type of the configuration parameter;
a second receiving subunit, configured to receive a configuration sub-policy corresponding to each parameter type returned by the server, where each configuration sub-policy includes a number of concurrent threads corresponding to different parameter values of each parameter type;
and the strategy generation subunit is configured to generate the configuration strategy according to the parameter value of the configuration parameter and the configuration sub-strategy, where the configuration strategy includes the number of concurrent threads adapted to the parameter value of the configuration parameter.
In another alternative implementation, the generating unit 520 may include (not shown in fig. 5):
a first thread number obtaining subunit, configured to obtain, before the receiving unit receives the concurrent network request, a number of concurrent threads adapted to the configuration parameter according to the configuration policy;
and the first thread pool generation subunit is used for generating a concurrent thread pool according to the number of the concurrent threads, wherein the concurrent thread pool comprises threads with the same number as the concurrent threads.
In another optional implementation, the generating unit 520 may also include (not shown in fig. 5):
a second thread number obtaining subunit, configured to obtain, when the receiving unit receives the concurrent network request, a number of concurrent threads adapted to the configuration parameter according to the configuration policy;
a first quantity judgment subunit, configured to judge whether the quantity of the concurrent requests is less than the quantity of the concurrent threads;
a second thread pool generation subunit, configured to generate a concurrent thread pool according to the number of concurrent threads when the determination result is that the number of concurrent threads is not less than the predetermined number, where the concurrent thread pool includes threads whose number is consistent with the number of concurrent threads; and when the judgment result is less than the preset threshold, generating a concurrent thread pool according to the number of the concurrent requests, wherein the concurrent thread pool comprises threads with the same number as the concurrent requests.
In another optional implementation, the generating unit 520 may also include (not shown in fig. 5):
a third thread number obtaining subunit, configured to obtain, when the receiving unit receives the concurrent network request, the number of concurrent threads adapted to the configuration parameter according to the configuration policy;
a third thread pool generation subunit, configured to generate a concurrent thread pool according to the number of concurrent threads, where the concurrent thread pool includes threads of a preset thread number, the preset thread number is smaller than the concurrent thread number, and a difference between the number of concurrent threads and the preset thread number is a remaining thread number;
a quantity calculating subunit, configured to calculate, when the number of concurrent requests is greater than the preset thread number, a difference value between the number of concurrent requests and the preset thread number as a difference thread number;
a second quantity judgment subunit, configured to judge whether the number of difference threads is less than the number of remaining threads;
and the third thread pool generating subunit is further configured to, when the judgment result is smaller than the threshold, increase to generate threads in the concurrent thread pool, the number of which is consistent with the number of the difference threads, and when the judgment result is not smaller than the threshold, increase to generate threads in the concurrent thread pool, the number of which is consistent with the number of the remaining threads.
In another alternative implementation, the allocation unit 540 may include (not shown in fig. 5):
a quantity judging subunit, configured to judge whether the quantity of the concurrent requests is greater than the quantity of the concurrent threads in the concurrent thread pool;
a first thread allocation subunit, configured to allocate a thread in the concurrent thread pool to each network request in the concurrent network requests when the number of concurrent requests is not greater than the number of concurrent threads;
and the second thread allocation subunit is configured to, when the number of the concurrent requests is greater than the number of the concurrent threads, allocate threads in the concurrent thread pool to the concurrent network requests according to a service priority of each network request in the concurrent network requests.
The second thread allocation subunit may be specifically configured to establish a request queue for the concurrent network requests, insert the network requests into the request queue according to the service priority of each network request, and allocate the threads in the concurrent thread pool to the network requests in the request queue, which are arranged in order from high to low according to the service priority.
In another alternative implementation, the parameter types of the configuration parameters may include at least one of the following parameter types: network type, CPU core number, terminal model, country or region of terminal.
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the application. One of ordinary skill in the art can understand and implement it without inventive effort.
It can be seen from the above embodiments that a dynamically adjusted configuration policy can be obtained according to different configuration parameters of the terminal, and therefore, a thread adapted to the performance of the terminal can be generated according to the configuration policy, so that resources of the terminal are reasonably utilized, and an optimal access speed of the terminal to a network is ensured.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (18)

1. A network request processing method, the method comprising:
generating a concurrent thread pool according to the acquired configuration strategy, wherein the configuration strategy is generated by a server based on the configuration parameters of the terminal or generated according to a configuration sub-strategy which is returned by the server and corresponds to the parameter types of the configuration parameters, and the configuration sub-strategy comprises the number of concurrent threads corresponding to different parameter values of each parameter type;
and distributing threads in the concurrent thread pool for the concurrent network requests according to the number of the received concurrent requests of the concurrent network requests.
2. The method of claim 1, wherein the server generates the configuration policy based on the configuration parameters of the terminal, and wherein the method comprises:
sending parameter values of the configuration parameters to a server;
and receiving a configuration strategy generated by the server for the terminal according to the parameter value of the configuration parameter, wherein the configuration strategy comprises the number of concurrent threads adapted to the parameter value of the configuration parameter.
3. The method of claim 1, wherein generating the configuration policy according to the configuration sub-policy corresponding to the parameter type of the configuration parameter returned by the server comprises:
sending a configuration request to a server, wherein the configuration request comprises the parameter type of the configuration parameter;
receiving a configuration sub-policy corresponding to each parameter type returned by the server;
and generating the configuration strategy according to the parameter values of the configuration parameters and the configuration sub-strategy, wherein the configuration strategy comprises the number of concurrent threads adapted to the parameter values of the configuration parameters.
4. The method according to any one of claims 1 to 3, wherein the generating a concurrent thread pool according to the obtained configuration policy comprises:
before the concurrent network request is received, acquiring the quantity of concurrent threads adapted to the configuration parameters according to the configuration strategy;
and generating a concurrent thread pool according to the number of the concurrent threads, wherein the concurrent thread pool comprises threads with the same number as the concurrent threads.
5. The method according to any one of claims 1 to 3, wherein the generating a concurrent thread pool according to the obtained configuration policy comprises:
when the concurrent network request is received, acquiring the quantity of concurrent threads adapted to the configuration parameters according to the configuration strategy;
judging whether the quantity of the concurrent requests is less than the quantity of the concurrent threads;
when the judgment result is not less than the preset threshold value, generating a concurrent thread pool according to the number of the concurrent threads, wherein the concurrent thread pool comprises threads with the same number as the concurrent threads; and when the judgment result is less than the preset threshold, generating a concurrent thread pool according to the number of the concurrent requests, wherein the concurrent thread pool comprises threads with the same number as the concurrent requests.
6. The method according to any one of claims 1 to 3, wherein the generating a concurrent thread pool according to the obtained configuration policy comprises:
when the concurrent network request is received, acquiring the quantity of concurrent threads adapted to the configuration parameters according to the configuration strategy;
generating a concurrent thread pool according to the number of concurrent threads, wherein the concurrent thread pool comprises threads with preset thread number, the preset thread number is smaller than the concurrent thread number, and the difference value between the concurrent thread number and the preset thread number is the number of residual threads;
when the quantity of the concurrent requests is larger than the preset thread quantity, calculating the difference value between the quantity of the concurrent requests and the preset thread quantity as the difference thread quantity;
judging whether the number of the difference threads is less than the number of the residual threads;
and when the judgment result is not less than the threshold value, increasing threads with the same number as the residual threads in the concurrent thread pool.
7. The method according to claim 1, wherein the allocating threads in the concurrent thread pool for the concurrent network requests according to the number of the received concurrent network requests comprises:
judging whether the quantity of the concurrent requests is larger than the quantity of the concurrent threads in the concurrent thread pool;
when the number of the concurrent requests is not larger than the number of the concurrent threads, allocating a thread in the concurrent thread pool to each network request in the concurrent network requests;
and when the quantity of the concurrent requests is greater than the quantity of the concurrent threads, distributing the threads in the concurrent thread pool for the concurrent network requests according to the service priority of each network request in the concurrent network requests.
8. The method of claim 7, wherein said assigning threads in the concurrent thread pool to the concurrent network requests according to a traffic priority of each of the concurrent network requests comprises:
establishing a request queue for the concurrent network requests;
inserting the network requests into the request queue according to the service priority of each network request;
and respectively distributing the threads in the concurrent thread pool to the network requests which are arranged in the request queue from high to low according to the service priority.
9. The method of claim 1, wherein the parameter types of the configuration parameters comprise at least one of the following parameter types: network type, central processing unit CPU core number, terminal machine type, country or region of terminal.
10. A network request processing apparatus, the apparatus comprising:
the obtaining unit is used for obtaining a configuration policy according to the configuration parameters of the terminal, wherein the configuration policy is generated by the server based on the configuration parameters of the terminal or generated according to a configuration sub-policy which is returned by the server and corresponds to the parameter types of the configuration parameters, and the configuration sub-policy contains the number of concurrent threads corresponding to different parameter values of each parameter type;
the generating unit is used for generating a concurrent thread pool according to the configuration strategy;
a receiving unit, configured to receive concurrent network requests;
and the distribution unit is used for distributing the threads in the concurrent thread pool for the concurrent network requests according to the concurrent request quantity of the concurrent network requests.
11. The apparatus of claim 10, wherein the obtaining unit comprises:
the first sending subunit is configured to send a parameter value of the configuration parameter to a server;
a first receiving subunit, configured to receive a configuration policy generated by the server for the terminal according to the parameter value of the configuration parameter, where the configuration policy includes a number of concurrent threads adapted to the parameter value of the configuration parameter.
12. The apparatus of claim 10, wherein the obtaining unit comprises:
a second sending subunit, configured to send a configuration request to a server, where the configuration request includes a parameter type of the configuration parameter;
the second receiving subunit is configured to receive the configuration sub-policy corresponding to each parameter type returned by the server;
and the strategy generation subunit is configured to generate the configuration strategy according to the parameter value of the configuration parameter and the configuration sub-strategy, where the configuration strategy includes the number of concurrent threads adapted to the parameter value of the configuration parameter.
13. The apparatus of claim 10, wherein the generating unit comprises:
a first thread number obtaining subunit, configured to obtain, before the receiving unit receives the concurrent network request, a number of concurrent threads adapted to the configuration parameter according to the configuration policy;
and the first thread pool generation subunit is used for generating a concurrent thread pool according to the number of the concurrent threads, wherein the concurrent thread pool comprises threads with the same number as the concurrent threads.
14. The apparatus of claim 10, wherein the generating unit comprises:
a second thread number obtaining subunit, configured to obtain, when the receiving unit receives the concurrent network request, a number of concurrent threads adapted to the configuration parameter according to the configuration policy;
a first quantity judgment subunit, configured to judge whether the quantity of the concurrent requests is less than the quantity of the concurrent threads;
a second thread pool generation subunit, configured to generate a concurrent thread pool according to the number of concurrent threads when the determination result is that the number of concurrent threads is not less than the predetermined number, where the concurrent thread pool includes threads whose number is consistent with the number of concurrent threads; and when the judgment result is less than the preset threshold, generating a concurrent thread pool according to the number of the concurrent requests, wherein the concurrent thread pool comprises threads with the same number as the concurrent requests.
15. The apparatus of claim 10, wherein the generating unit comprises:
a third thread number obtaining subunit, configured to obtain, when the receiving unit receives the concurrent network request, the number of concurrent threads adapted to the configuration parameter according to the configuration policy;
a third thread pool generation subunit, configured to generate a concurrent thread pool according to the number of concurrent threads, where the concurrent thread pool includes threads of a preset thread number, the preset thread number is smaller than the concurrent thread number, and a difference between the number of concurrent threads and the preset thread number is a remaining thread number;
a quantity calculating subunit, configured to calculate, when the number of concurrent requests is greater than the preset thread number, a difference value between the number of concurrent requests and the preset thread number as a difference thread number;
a second quantity judgment subunit, configured to judge whether the number of difference threads is less than the number of remaining threads;
and the third thread pool generating subunit is further configured to, when the judgment result is smaller than the threshold, increase to generate threads in the concurrent thread pool, the number of which is consistent with the number of the difference threads, and when the judgment result is not smaller than the threshold, increase to generate threads in the concurrent thread pool, the number of which is consistent with the number of the remaining threads.
16. The apparatus of claim 10, wherein the allocation unit comprises:
a quantity judging subunit, configured to judge whether the quantity of the concurrent requests is greater than the quantity of the concurrent threads in the concurrent thread pool;
a first thread allocation subunit, configured to allocate a thread in the concurrent thread pool to each network request in the concurrent network requests when the number of concurrent requests is not greater than the number of concurrent threads;
and the second thread allocation subunit is configured to, when the number of the concurrent requests is greater than the number of the concurrent threads, allocate threads in the concurrent thread pool to the concurrent network requests according to a service priority of each network request in the concurrent network requests.
17. The apparatus according to claim 16, wherein the second thread allocation subunit is specifically configured to establish a request queue for the concurrent network requests, insert the network requests into the request queue according to the service priority of each network request, and allocate the threads in the concurrent thread pool to the network requests in the request queue that are arranged in order from high to low according to the service priority.
18. A terminal, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to:
generating a concurrent thread pool according to the acquired configuration strategy, wherein the configuration strategy is acquired according to the configuration parameters of the terminal; the configuration strategy is generated by a server based on the configuration parameters of the terminal or generated according to a configuration sub-strategy which is returned by the server and corresponds to the parameter types of the configuration parameters of the terminal, wherein the configuration sub-strategy comprises the quantity of concurrent threads corresponding to different parameter values of each parameter type;
and distributing threads in the concurrent thread pool for the concurrent network requests according to the number of the received concurrent requests of the concurrent network requests.
CN201410834995.1A 2014-12-26 2014-12-26 Network request processing method and device and terminal Active CN105791254B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410834995.1A CN105791254B (en) 2014-12-26 2014-12-26 Network request processing method and device and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410834995.1A CN105791254B (en) 2014-12-26 2014-12-26 Network request processing method and device and terminal

Publications (2)

Publication Number Publication Date
CN105791254A CN105791254A (en) 2016-07-20
CN105791254B true CN105791254B (en) 2020-01-03

Family

ID=56389052

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410834995.1A Active CN105791254B (en) 2014-12-26 2014-12-26 Network request processing method and device and terminal

Country Status (1)

Country Link
CN (1) CN105791254B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106304410A (en) * 2016-09-14 2017-01-04 广东欧珀移动通信有限公司 A kind of data migration method and mobile terminal
CN106998349A (en) * 2016-10-18 2017-08-01 深圳大宇无限科技有限公司 Multithreading method for down loading and device
CN107959924A (en) * 2017-11-17 2018-04-24 西安蜂语信息科技有限公司 Intercom method for parameter configuration and device
CN108111499B (en) * 2017-12-15 2021-07-16 腾讯科技(深圳)有限公司 Business processing performance optimization method and device, electronic equipment and storage medium
CN110297743B (en) * 2018-03-21 2023-03-21 财付通支付科技有限公司 Load testing method and device and storage medium
CN113163453B (en) * 2021-04-22 2022-10-21 Tcl通讯(宁波)有限公司 Wifi transmission speed control method, system, storage medium and mobile terminal
CN114489867B (en) * 2022-04-19 2022-09-06 浙江大华技术股份有限公司 Algorithm module scheduling method, algorithm module scheduling device and readable storage medium
CN115033393B (en) * 2022-08-11 2023-01-17 苏州浪潮智能科技有限公司 Priority queuing processing method, device, server and medium for batch request issuing

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8185906B2 (en) * 2007-05-23 2012-05-22 Sap Ag Method and apparatus for dynamically adjusting thread pool
CN101777008A (en) * 2009-12-31 2010-07-14 中兴通讯股份有限公司 Method and device for realizing mobile terminal system thread pool
CN102591721A (en) * 2011-12-30 2012-07-18 北京新媒传信科技有限公司 Method and system for distributing thread execution task
CN103455356B (en) * 2013-09-05 2017-02-08 中国计量学院 Concurrence loading and rendering method of 3D (three-dimensional) models on multi-core mobile device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"基于分段的线程池尺寸自适应调整算法";孙旭东;《计算机工程》;20110131;第1页 *

Also Published As

Publication number Publication date
CN105791254A (en) 2016-07-20

Similar Documents

Publication Publication Date Title
CN105791254B (en) Network request processing method and device and terminal
CN107995215B (en) Control method and device of intelligent household equipment and cloud platform server
CN108667748B (en) Method, device, equipment and storage medium for controlling bandwidth
US20210219222A1 (en) Network slice selection method and apparatus
US10924966B2 (en) Management method, management unit, and system
US10652360B2 (en) Access scheduling method and apparatus for terminal, and computer storage medium
CN110351375B (en) Data processing method and device, computer device and readable storage medium
CN104954468A (en) Resource allocation method and resource allocation device
CN106445473B (en) container deployment method and device
KR20200017589A (en) Cloud server for offloading task of mobile node and therefor method in wireless communication system
CN108933829A (en) A kind of load-balancing method and device
US20170155596A1 (en) Method And Electronic Device For Bandwidth Allocation
CN110661654B (en) Network bandwidth resource allocation method, device, equipment and readable storage medium
CN104793982A (en) Method and device for establishing virtual machine
US11706630B2 (en) Spectrum management device, system and method, and computer-readable storage medium
CN114155026A (en) Resource allocation method, device, server and storage medium
CN113361913A (en) Communication service arranging method, device, computer equipment and storage medium
CN106254566A (en) A kind of data download processing method and device
CN109039694B (en) Global network resource allocation method and device for service
CN111459676A (en) Node resource management method, device and storage medium
US20230379268A1 (en) Resource scheduling method and system, electronic device, computer readable storage medium
CN110489356B (en) Information processing method, information processing device, electronic equipment and storage medium
CN111510491A (en) Resource access method, cache server, storage medium and electronic device
CN105490956A (en) Network request processing method and network request processing device
CN110545336A (en) IP address replacing method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20240202

Address after: # 01-21, Lai Zan Da Building 1, 51 Belarusian Road, Singapore

Patentee after: Alibaba Singapore Holdings Ltd.

Country or region after: Singapore

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: ALIBABA GROUP HOLDING Ltd.

Country or region before: United Kingdom

TR01 Transfer of patent right