CN113467924A - Resource allocation method, device, server and computer readable storage medium - Google Patents

Resource allocation method, device, server and computer readable storage medium Download PDF

Info

Publication number
CN113467924A
CN113467924A CN202010247311.3A CN202010247311A CN113467924A CN 113467924 A CN113467924 A CN 113467924A CN 202010247311 A CN202010247311 A CN 202010247311A CN 113467924 A CN113467924 A CN 113467924A
Authority
CN
China
Prior art keywords
network
resource
network request
server
resources
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.)
Pending
Application number
CN202010247311.3A
Other languages
Chinese (zh)
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.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co 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 Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202010247311.3A priority Critical patent/CN113467924A/en
Publication of CN113467924A publication Critical patent/CN113467924A/en
Pending legal-status Critical Current

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/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • 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/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Abstract

The embodiment of the invention provides a resource allocation method, a resource allocation device, a server and a computer readable storage medium, which are applied to the server and relate to the field of cloud computing, wherein the method comprises the following steps: determining real-time network traffic of the server, wherein the real-time network traffic comprises data volume of a network request received by a network card of the server; allocating resources for processing the network request according to the data volume of the network request received by the network card of the server and a preset resource volume flow relation, wherein the resource volume flow relation is as follows: the network flow is determined according to the network flow counted in advance and the resource size of the resource used by the network flow. The scheme provided by the embodiment of the invention is applied to resource allocation, and can be suitable for the requirements of different concurrency conditions of network requests on resources.

Description

Resource allocation method, device, server and computer readable storage medium
Technical Field
The present invention relates to the field of cloud computing, and in particular, to a resource allocation method, device, server, and computer-readable storage medium.
Background
The server can provide various services to the user, and when a network request for the service requested by the user is received, the server can provide the user with the various services requested by the user. In order to grasp the service request condition of each user, the auditing service provided by the server can analyze the received network request, obtain various information related to the network request of the user, and further count the obtained information.
In order to smoothly obtain various information related to a network request of a user, a server generally allocates a fixed resource in advance for processing the network request of the user.
For example, in practical applications, a user may request a database service, and in order to grasp a condition that each user requests a database, after the server receives a network request, the database audit service provided by the server may analyze the received network request by using the fixed resource to obtain information such as a requested operation type, and further count the number of network requests of each operation type.
However, since fixed resources are pre-allocated, when the number of concurrent network requests of a user is large, the fixed resources may not be enough to process the concurrent network requests; when the number of concurrent network requests of the user is small, more resources of the fixed resources may be in an unused state, thereby causing resource waste. Therefore, when allocating resources for processing network requests of users by adopting the above-mentioned method of fixedly allocating resources, it is difficult to adapt to the demands of different concurrency situations of network requests on resources.
Disclosure of Invention
Embodiments of the present invention provide a resource allocation method, device, server, and computer-readable storage medium, so as to adapt to requirements of different concurrency conditions of a network request on resources. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a resource allocation method, which is applied to a server, and the method includes:
determining real-time network traffic of the server, wherein the real-time network traffic comprises data volume of a network request received by a network card of the server;
allocating resources for processing the network request according to the data volume of the network request received by the network card of the server and a preset resource volume flow relation, wherein the resource volume flow relation is as follows: the network flow is determined according to the network flow counted in advance and the resource size of the resource used by the network flow.
In an embodiment of the present invention, the allocating resources for processing a network request according to a data volume of the network request received by the network card of the server and a preset resource volume flow relationship includes:
determining a relation with the preset resource quantity flow according to the data quantity of the network request received by the network card of the server so as to determine a first resource size of resources required for processing the data quantity of the network request received by the network card of the server;
analyzing the network request received by the network card of the server to obtain the network request type of the network request;
adjusting the first resource size according to the request type of the network request to obtain a second resource size;
and allocating the resources for processing the network request received by the network card of the server based on the second resource size.
In an embodiment of the present invention, the determining, according to the data size of the network request received by the network card of the server, a relationship with the preset resource size flow to determine a first resource size of a resource required for processing the data size of the network request received by the network card of the server includes:
determining a resource quantity flow relation corresponding to the data quantity of the network request according to the data quantity of the network request received by the network card of the server and the preset resource quantity flow relation;
and determining a first resource size of the resource required for processing the data volume of the network request based on the resource volume flow relation corresponding to the data volume of the network request.
In an embodiment of the present invention, the adjusting the first resource size according to the request type of the network request to obtain the second resource size includes:
and when the network request type is an intensive interface access request type, reducing the size of the memory resource in the determined first resource size to obtain a second resource size.
In an embodiment of the present invention, the adjusting the first resource size according to the request type of the network request to obtain the second resource size includes:
and when the network request type is an intensive computing resource access request type, reducing the size of the computing resource in the first resource size to obtain a second resource size.
In an embodiment of the present invention, the analyzing the network request received by the network card of the server to obtain the network request type of the network request includes:
analyzing the bytes with the preset number in the first data packet of the network request received by the network card of the server to obtain the network request type of the network request.
In an embodiment of the present invention, the method further includes:
when the resource size of the resource required by the data volume of the network request received by the network card of the server is larger than the allocated resource size, storing other data of the network request except the data which can be processed by the resource into a hard disk of the server;
and processing other data of the network request stored in the hard disk of the server when the allocated resources are in an idle state.
In an embodiment of the present invention, the resources include: memory resources and thread resources.
In a second aspect, an embodiment of the present invention provides a resource allocation apparatus, which is applied to a server, and the apparatus includes:
the flow determining module is used for determining real-time network flow of the server, wherein the real-time network flow comprises data volume of a network request received by a network card of the server;
the resource allocation module is used for allocating resources for processing the network request according to the data volume of the network request received by the network card of the server and a preset resource volume flow relationship, wherein the resource volume flow relationship is as follows: the network flow is determined according to the network flow counted in advance and the resource size of the resource used by the network flow.
In an embodiment of the present invention, the resource allocation module includes:
the first resource determining submodule is used for determining a relation with the preset resource quantity flow according to the data quantity of the network request received by the network card of the server so as to determine a first resource size of the resource required for processing the data quantity of the network request received by the network card of the server;
the network request type analyzing submodule is used for analyzing the network request received by the network card of the server to obtain the network request type of the network request;
the resource adjusting submodule is used for adjusting the size of the first resource according to the request type of the network request to obtain the size of a second resource;
and the second resource determining submodule is used for allocating the resources for processing the network request received by the network card of the server based on the second resource size.
In an embodiment of the invention, the first resource determining sub-module is further configured to:
determining a resource quantity flow relation corresponding to the data quantity of the network request according to the data quantity of the network request received by the network card of the server and the preset resource quantity flow relation;
and determining a first resource size of the resource required for processing the data volume of the network request based on the resource volume flow relation corresponding to the data volume of the network request.
In an embodiment of the present invention, the resource adjusting sub-module is further configured to:
and when the network request type is an intensive interface access request type, reducing the size of the memory resource in the determined first resource size to obtain a second resource size.
In an embodiment of the present invention, the resource adjusting sub-module is further configured to:
and when the network request type is an intensive computing resource access request type, reducing the size of the computing resource in the first resource size to obtain a second resource size.
In an embodiment of the present invention, the network request type parsing sub-module is further configured to:
analyzing the bytes with the preset number in the first data packet of the network request received by the network card of the server to obtain the network request type of the network request.
In an embodiment of the present invention, the apparatus further includes:
the data storage module is used for storing other data of the network request except the data which can be processed by the resources into a hard disk of the server when the resource size of the resources required by the data volume of the network request received by the network card of the server is larger than the allocated resource size;
and the request processing module is used for processing other data of the network request stored in the hard disk of the server when the allocated resources are in an idle state.
In an embodiment of the present invention, the resources include: memory resources and thread resources.
In a third aspect, an embodiment of the present invention provides a server, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;
a memory for storing a computer program;
a processor configured to implement the method steps of the first aspect when executing the program stored in the memory.
In a fourth aspect, the present invention provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method steps described in the first aspect.
As can be seen from the above, when the scheme provided by this embodiment is applied to resource allocation, since the real-time network traffic can represent the data volume of the network request received by the network card in unit time when the number of concurrent network requests is different, and the preset resource volume traffic relationship reflects the relationship between the network traffic counted in advance and the resource size of the resource used by the network traffic. Therefore, according to the data volume of the network request received by the network card of the server and the preset resource volume flow relation, the resources are allocated according to different data volumes of the network request so as to process the network request, so that the resources are dynamically allocated to process the network requests with different request concurrency quantities, and compared with the prior art, the method and the device can be suitable for the condition that the network requests with different concurrency quantities need the resources.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart illustrating a first resource allocation method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a second resource allocation method according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating a third resource allocation method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a first resource allocation apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a second resource allocation apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a third resource allocation apparatus according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a server according to an embodiment of the present invention;
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a schematic flowchart of a first resource allocation method according to an embodiment of the present invention, where the method includes S101 to S102.
S101: real-time network traffic of the server is determined.
The scenario of the application of the scheme provided by the embodiment of the invention can be as follows: when the server provides service according to the received network request, the server allocates certain resources to the auditing service, and the auditing service processes the network request received by the server by adopting the allocated resources to obtain the information of the network request.
For example: the auditing service may be a database auditing service for counting the number of network requests of each network request type. The database audit service can count the network request times of different network request types received in the network card in a bypass detection mode.
In one embodiment of the present invention, the audit service and the database for providing service data may be deployed in the same resource pool.
The same resource pool may include storage resources, computing resources, and the like. Specifically, when the server allocates resources, the resources in the resource pool may be allocated to the audit service and the database according to different proportions.
The real-time network traffic includes the data volume of the network request received by the network card of the server.
The network request is used to request a service. For example: the network request may be for requesting a display image service, a display video service, or the like.
After a user sends a network request to a server at a client used by the user, a network card in the server receives the network request and caches the received network request.
The real-time network traffic may be used to characterize the data size of the network request received by the network card in unit time. When the real-time network flow is large, the data volume of the network request received by the intranet card in unit time is large, and when the real-time network flow is small, the data volume of the network request received by the intranet card in unit time is small. Therefore, the real-time network traffic can be obtained by counting according to the data volume of the network request received by the network card.
Specifically, when the real-time network traffic is obtained, the data size of the network request obtained by the network card in a preset time period may be counted, the data size of the network request received in unit time may be calculated, and the calculated value may be determined as the real-time network traffic. For example: the data volume of the network request obtained by the network card within 3 seconds is 9G, the data volume of the network request received every second is calculated to be 9G/3 s-3G/s, and the calculated result is taken as the real-time network flow.
S102: and allocating resources for processing the network request according to the data volume of the network request received by the network card of the server and a preset resource volume flow relation.
The resource flow relation is as follows: the network traffic is determined according to the network traffic counted in advance and the resource amount (or resource size) of the resource used by the network traffic. The pre-counted network traffic includes a pre-collected data amount of the network request, and the pre-counted network traffic may be obtained by counting according to the pre-collected data amount of the network request.
In an embodiment of the present invention, the resources may include memory resources and thread resources.
Specifically, the thread resources are used for calculating data, and the amount of the thread resources may include a preset number of threads, for example: 5 threads, 10 threads, etc.
The memory resources are used for storing data. The amount of memory resources may include a predetermined size of memory, such as: the size of the memory resource can be 1G memory, 2G memory, and the like.
Specifically, when the resource amount and flow relationship is obtained, the network requests may be collected in advance in a test environment, and then the network flow counted in advance may be calculated according to the data amount of the network requests collected in advance.
For example: the data volume of the network request collected in advance is 1G, the time for receiving the network request is 1s, the data volume of the network request obtained in unit time is 1G/s, and the calculated value is taken as the network flow of the network request counted in advance and is 1G/s. And obtaining the resource size of the resource used by the network flow as the amount of the memory resource is 1G, and the amount of the thread resource is 5 thread numbers. Therefore, the relation between the network traffic 1G/s counted in advance and the resource size of the resource used by the network traffic 1G/s, namely the resource traffic relation can be determined. The resource amount flow relationship obtained above can be characterized in a tabular form, as shown in table 1 below.
TABLE 1
Figure BDA0002434290310000081
According to the method, the preset resource quantity and flow relation can be determined.
After the resource flow relationship is obtained, the resource size of the resource for processing the network request can be directly determined according to the data volume of the network request received by the network card of the server, and the resource for processing the network request is allocated according to the determined resource size.
For example: assuming that the obtained resource size of the resource for processing the obtained network request comprises: the relationship between the amount of memory resources and the amount of thread resources, and the preset resource amount and flow is shown in table 2.
TABLE 2
Figure BDA0002434290310000082
As can be seen from table 2, when the pre-counted network traffic is 1G/s, the resource size of the resource used by the network traffic is: the amount of the memory resources is 1G, and the amount of the thread resources is 5 threads; when the pre-counted network traffic is 2G/s, the resource size of the resource used by the network traffic is: the amount of the memory resources is 2G, and the amount of the thread resources is 10 threads; when the pre-counted network traffic is 3G/s, the resource size of the resource used by the network traffic is: the amount of memory resources is 3G, and the amount of thread resources is 15 threads.
Assuming that the data volume of the network request received by the network card of the server in 1s is 2G, the real-time network traffic is 2G/s, and according to the table 2, the resource size of the resource for processing the network request may be determined as follows: the amount of the memory resources is 2G, the amount of the thread resources is 10 threads, and the resources for processing the network request are distributed according to the determined amount of the memory resources and the determined amount of the thread resources.
As can be seen from the above, when the scheme provided by this embodiment is applied to resource allocation, since the real-time network traffic can represent the data volume of the network request received by the network card in unit time when the number of concurrent network requests is different, and the preset resource volume traffic relationship reflects the relationship between the network traffic counted in advance and the resource size of the resource used by the network traffic. Therefore, according to the data volume of the network requests received by the network card of the server and the preset resource volume flow relation, the network requests for processing different request concurrency quantities can be dynamically allocated, and compared with the prior art, the method and the device for processing the network requests can be suitable for the condition that the different concurrency quantities of the network requests meet the requirements of resources.
Referring to fig. 2, fig. 2 is a flowchart illustrating a second resource allocation method according to an embodiment of the present invention, where in the step S102, resources for processing a network request are allocated according to a data amount of the network request received by a network card of a server and a preset resource amount flow relationship, the method may include steps S102a1-S102a 4.
S102a 1: determining a preset resource quantity flow relation according to the data quantity of the network request received by the network card of the server so as to determine a first resource size of resources required for processing the data quantity of the network request received by the network card of the server.
S102a 2: and analyzing the network request received by the network card of the server to obtain the network request type of the network request.
The network request types may include: a dense interface access request type and a dense compute resource access request type.
Specifically, the interface may include an IO interface and the like, and the intensive IO interface access request type may also be referred to as IO intensive; the computing resources may include CPUs, GPUs, and the like, and the intensive CPU access request type may also be referred to as CPU intensive.
Specifically, during parsing, the data packets in the network request received by the network card may be spliced, and the spliced data packets are parsed to obtain the network request type of the network request.
In an embodiment of the present invention, in the above S102a2, the network request received by the network card of the server may be analyzed in the following manner, so as to obtain the network request type of the network request.
Analyzing the bytes with the preset number in the first data packet of the network request received by the network card to obtain the network request type of the network request.
Specifically, the preset number may be 1024, 2048, and the like.
The first 1024 bytes of the first data packet of the network request include information characterizing the type of the network request. Therefore, the packet splicing process can be abandoned, and only at least the first 1024 bytes of the first packet are analyzed, so as to obtain the network request type of the network request.
In this way, only the preset number of bytes in the first data packet of the network request are analyzed, and the resource for analyzing the network request can be saved.
S102a 3: and adjusting the first resource size according to the request type of the network request to obtain a second resource size.
Since the resource size of the resource for processing the network requests of the respective network request types may not be the same although the data amount of the network requests of the different network request types is the same when the network request types of the network requests are different. Therefore, in order to be applicable to the situation of resources required by network requests of different network request types, the size of the determined first resource may be adjusted according to the network request type of the network request and a preset resource amount traffic relation corresponding to the network request type.
S102a 4: and allocating resources for processing the network request received by the network card of the server based on the second resource size.
The resource quantity and flow relationship corresponding to the preset network request type is as follows: and determining the relation according to the network flow of the network request of a certain network request type counted in advance and the resource size of the resource used by the network flow of the network request type. For example, assuming that the network request type is network request type R, the resource traffic relationship corresponding to network request type R may be as shown in table 3 below.
TABLE 3
Figure BDA0002434290310000101
Figure BDA0002434290310000111
As can be seen from table 3, when the network traffic of the network request type R counted in advance is 1G/s, the resource size of the resource used by the network traffic is: the amount of the memory resources is 0.5G, and the amount of the thread resources is 7 threads; when the network traffic of the network request type R counted in advance is 2G/s, the resource size of the resource used by the network traffic is: the amount of memory resources is 0.7G, and the amount of thread resources is 9 threads.
As can be seen from table 3 compared to table 2, although the network traffic counted in advance is the same, the resource sizes of the resources required for the network traffic are different.
Assuming that the data volume of the network request type R received by the network card of the server in 1s is 2G, the real-time network traffic is 2G/s, and according to the table 3, the resources for processing the network request of the network request type R may be allocated as follows: the amount of memory resources is 0.7G, and the amount of thread resources is 9 threads.
Therefore, the method can be suitable for the condition of the resources required by the network requests of different network request types according to the network request type of the network request and the preset resource quantity and flow relation corresponding to the network request type, thereby improving the effective utilization rate of the resources.
In an embodiment of the present invention, the determining of the traffic relationship with the preset resource amount according to the data amount of the network request received by the network card of the server in S102a1 may be implemented as follows, so as to determine the first resource size of the resource required for processing the data amount of the network request received by the network card of the server.
Determining the resource size of the resource required for processing the network request according to the network request type of the network request and the resource quantity and flow relation corresponding to the preset network request type; resources for processing the network request are allocated according to the determined resource size.
Specifically, according to the real-time network traffic of the network request type and the resource traffic relationship corresponding to the preset network request type, the resource size of the resource for processing the obtained network request can be directly determined, and the resource for processing the network request is allocated according to the determined resource size.
Therefore, the resources for processing the network request can be accurately allocated according to the real-time network traffic of the network request type and the preset resource traffic relation corresponding to the network request type.
In another embodiment of the present invention, the determining of the relationship between the data volume of the network request received by the network card of the server and the preset resource volume flow rate in S102a1 according to the following steps B1-B2 may be further implemented to determine the first resource size of the resource required for processing the data volume of the network request received by the network card of the server.
Step B1: and determining a resource quantity flow relation corresponding to the data quantity of the network request according to the data quantity of the network request received by the network card of the server and a preset resource quantity flow relation.
For example, the preset resource amount flow relationship is a corresponding relationship between network traffic (e.g., a data amount of a network request) and a resource size of a resource required for processing the network traffic, and based on this, the resource amount flow relationship corresponding to the network traffic can be determined by counting the data amount of the network request received by the network card of the server.
Step B2: and determining a first resource size of resources required for processing the data volume of the network request based on the resource volume flow relation corresponding to the data volume of the network request.
For example, after determining the corresponding resource amount traffic relationship, the size of the resource corresponding to the data amount for processing the network request, that is, the first resource size, may be preliminarily determined.
When the network request type is an intensive interface access request type, and the server provides a service according to the network request of the network request type, a large amount of storage resources are needed to obtain data, so that the server needs to allocate more storage resources for obtaining service data. In order to ensure that the server can provide services smoothly, the size of the memory resource or the computing resource in the determined first resource size can be adjusted, so that the resource required by processing the network request can be met, and the resource waste is avoided.
Illustratively, S102a3 may be implemented as: and when the network request type is an intensive interface access request type, reducing the size of the memory resource in the determined first resource size to obtain a second resource size.
In other embodiments, step S102a3 may also be implemented as: when the network request type is an intensive computing resource access request type, the size of the computing resource in the first resource size is reduced to obtain a second resource size.
Since the server needs a large amount of storage resources to obtain data when providing service to a network request of an intensive interface access request type, the server needs to allocate more storage resources for obtaining service data. Therefore, the memory resource allocated to the network request is reduced, and the server can be ensured to provide services smoothly.
In addition, since the server needs a large amount of computing resources to process data when servicing a network request of an intensive computing resource access request type, the server needs to allocate a large amount of computing resources for processing data. Therefore, the computing resources allocated to the network request are reduced, and the server can be ensured to provide services smoothly.
Because the network requests of different network request types have different requirements on the resource size, after the resource size of the resource required by the network request is determined according to the network request type of the network request and the resource quantity flow relation corresponding to the preset network request type, the determined resource size is further adjusted according to the network request type. In this way, resources for handling network requests of different network request types can be dynamically allocated.
In an embodiment of the present invention, as shown in fig. 3, fig. 3 is a flowchart illustrating a third resource allocation method according to the embodiment of the present invention, and after the step S102, the method may further include the following steps S103 to S104.
Step S103: and when the resource size of the resource required by the data volume of the network request received by the network card of the server is larger than the allocated resource size, storing other data except the data which can be processed by the resource of the network request into a hard disk of the server.
The other data requested by the network except the data processed by the resource are: when the network request is processed according to the allocated resources, the network request contains data which is not processed by the resources.
The above-mentioned allocated resource size may represent a maximum resource size of resources for processing a network request. When the determined resource size is larger than the allocated resource size, the server cannot allocate the resource according to the determined resource size, and therefore the resource for processing the network request is allocated according to the allocated resource size.
In order to avoid data loss, other data except for the data processed by the resource in the network request can be stored in the hard disk of the server.
Step S104: when the allocated resources are in an idle state, processing other data requested by the network and stored in the hard disk of the server.
In this way, when the determined resource size is larger than the allocated resource size, the data which is not subjected to resource processing in the network request is stored in the hard disk, so that data loss can be avoided, and when the allocated resource is in an idle state, the network request of the hard disk data stored in the server is processed, so that the received network requests can be guaranteed to be processed.
Corresponding to the resource allocation method, the embodiment of the invention also provides a resource allocation device.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a first resource allocation apparatus according to an embodiment of the present invention, which is applied to a server, and the apparatus includes 401 and 402.
A traffic determining module 401, configured to determine real-time network traffic of the server, where the real-time network traffic includes a data volume of a network request received by a network card of the server;
a resource allocation module 402, configured to allocate resources for processing a network request according to a data amount of the network request received by a network card of the server and a preset resource amount flow relationship, where the resource amount flow relationship is: the network flow is determined according to the network flow counted in advance and the resource size of the resource used by the network flow.
As can be seen from the above, when the scheme provided by this embodiment is applied to resource allocation, since the real-time network traffic can represent the data volume of the network request received by the network card in unit time when the number of concurrent network requests is different, and the preset resource volume traffic relationship reflects the relationship between the network traffic counted in advance and the resource size of the resource used by the network traffic. Therefore, according to the data volume of the network requests received by the network card of the server and the preset resource volume flow relation, the network requests for processing different request concurrency quantities can be dynamically allocated, and compared with the prior art, the method and the device for processing the network requests can be suitable for the condition that the different concurrency quantities of the network requests meet the requirements of resources.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a second resource allocation apparatus according to an embodiment of the present invention, and the resource allocation module 402 may further include 402A to 402D.
The first resource determining submodule 402A is configured to determine, according to a data volume of a network request received by a network card of a server, a relationship with a preset resource volume flow rate, so as to determine a first resource size of a resource required for processing the data volume of the network request received by the network card of the server;
a network request type analyzing submodule 402B, configured to analyze a network request received by a network card of the server, and obtain a network request type of the network request;
a resource adjusting submodule 402C, configured to adjust the size of the first resource according to the request type of the network request, so as to obtain a size of a second resource;
a second resource determining submodule 402D, configured to allocate, based on the second resource size, the resource for processing the network request received by the network card of the server.
Therefore, the method can be suitable for the condition of the resources required by the network requests of different network request types according to the network request type of the network request and the preset resource quantity and flow relation corresponding to the network request type, thereby improving the effective utilization rate of the resources.
In an embodiment of the present invention, in the first resource determining sub-module 402A, the first resource determining sub-module may further be configured to:
determining a resource quantity flow relation corresponding to the data quantity of the network request according to the data quantity of the network request received by the network card of the server and the preset resource quantity flow relation;
and determining a first resource size of the resource required for processing the data volume of the network request based on the resource volume flow relation corresponding to the data volume of the network request.
Therefore, the resources for processing the network request can be accurately allocated according to the real-time network traffic of the network request type and the preset resource traffic relation corresponding to the network request type.
In an embodiment of the present invention, in the resource adjusting sub-module 402C, the resource adjusting sub-module may further be configured to:
and when the network request type is an intensive interface access request type, reducing the size of the memory resource in the determined first resource size to obtain a second resource size.
In this way, when the server provides a service to a network request of an intensive interface access request type, a large amount of storage resources are required to obtain data, and therefore the server needs to allocate a large amount of storage resources for obtaining service data. Therefore, the memory resource allocated to the network request is reduced, and the server can be ensured to provide services smoothly.
Alternatively, in the resource adjusting sub-module 402C, the resource adjusting sub-module may further be configured to:
and further configured to reduce the size of the computing resource in the first resource size to obtain a second resource size when the network request type is an intensive computing resource access request type.
As described above, when a server provides a service to a network request of an intensive computing resource access request type, a large amount of computing resources are required to process data, and therefore the server needs to allocate a large amount of computing resources to process data. Therefore, the computing resources allocated to the network request are reduced, and the server can be ensured to provide services smoothly.
Because the network requests of different network request types have different requirements on the resource size, after the resource size of the resource required by the network request is determined according to the network request type of the network request and the resource quantity flow relation corresponding to the preset network request type, the determined resource size is further adjusted according to the network request type. In this way, resources for handling network requests of different network request types can be dynamically allocated.
In an embodiment of the present invention, the network request type parsing sub-module 402B is further configured to:
analyzing the bytes with the preset number in the first data packet of the network request received by the network card of the server to obtain the network request type of the network request.
In this way, only the preset number of bytes in the first data packet of the network request are analyzed, and the resource for analyzing the network request can be saved.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a third resource allocation apparatus according to an embodiment of the present invention, where the apparatus may further include:
a data storage module 403, configured to, when the resource size of the resource required by the data amount of the network request received by the network card of the server is larger than the allocated resource size, store other data of the network request, except the data that can be processed by the resource, in a hard disk of the server;
a request processing module 404, configured to process other data of the network request stored in the hard disk of the server when the allocated resource is in an idle state.
In this way, when the determined resource size is larger than the preset resource amount, the data which is not subjected to resource processing in the network request is stored in the hard disk, so that data loss can be avoided, and when the allocated resource is in an idle state, the network request of the hard disk data stored in the server is processed, so that the received network requests can be processed.
In an embodiment of the present invention, the resources include: memory resources and thread resources.
Corresponding to the resource allocation method, the embodiment of the invention also provides a server.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a server according to an embodiment of the present invention, including a processor 701, a communication interface 702, a memory 703 and a communication bus 704, where the processor 701, the communication interface 702, and the memory 703 complete mutual communication through the communication bus 704,
a memory 703 for storing a computer program;
the processor 701 is configured to implement the resource allocation method provided in the embodiment of the present invention when executing the program stored in the memory 703.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the server and other devices.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
In another embodiment provided by the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program, when executed by a processor, implements the resource allocation method provided by the embodiment of the present invention.
In another embodiment, the present invention further provides a computer program product containing instructions, which when executed on a computer, causes the computer to implement the resource allocation method provided by the embodiment of the present invention.
As can be seen from the above, when the scheme provided by this embodiment is applied to resource allocation, since the real-time network traffic can represent the data volume of the network request received by the network card in unit time when the number of concurrent network requests is different, and the preset resource volume traffic relationship reflects the relationship between the network traffic counted in advance and the resource size of the resource used by the network traffic. Therefore, according to the data volume of the network requests received by the network card of the server and the preset resource volume flow relation, the network requests for processing different request concurrency quantities can be dynamically allocated, and compared with the prior art, the method and the device for processing the network requests can be suitable for the condition that the different concurrency quantities of the network requests meet the requirements of resources.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the embodiments of the apparatus, the server, and the computer-readable storage medium, since they are substantially similar to the embodiments of the method, the description is simple, and in relation to the embodiments, reference may be made to the partial description of the embodiments of the method.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (12)

1. A resource allocation method is applied to a server, and the method comprises the following steps:
determining real-time network traffic of the server, wherein the real-time network traffic comprises data volume of a network request received by a network card of the server;
allocating resources for processing the network request according to the data volume of the network request received by the network card of the server and a preset resource volume flow relation, wherein the resource volume flow relation is as follows: the network flow is determined according to the network flow counted in advance and the resource size of the resource used by the network flow.
2. The method according to claim 1, wherein the allocating resources for processing the network request according to the data volume of the network request received by the network card of the server and a preset resource volume flow relationship comprises:
determining a relation with the preset resource quantity flow according to the data quantity of the network request received by the network card of the server so as to determine a first resource size of resources required for processing the data quantity of the network request received by the network card of the server;
analyzing the network request received by the network card of the server to obtain the network request type of the network request;
adjusting the first resource size according to the request type of the network request to obtain a second resource size;
and allocating the resources for processing the network request received by the network card of the server based on the second resource size.
3. The method according to claim 2, wherein the determining a flow relation with the preset resource amount according to the data amount of the network request received by the network card of the server to determine a first resource size of resources required for processing the data amount of the network request received by the network card of the server comprises:
determining a resource quantity flow relation corresponding to the data quantity of the network request according to the data quantity of the network request received by the network card of the server and the preset resource quantity flow relation;
and determining a first resource size of the resource required for processing the data volume of the network request based on the resource volume flow relation corresponding to the data volume of the network request.
4. The method of claim 2, wherein the adjusting the first resource size according to the request type of the network request to obtain a second resource size comprises:
and when the network request type is an intensive interface access request type, reducing the size of the memory resource in the determined first resource size to obtain a second resource size.
5. The method of claim 2, wherein the adjusting the first resource size according to the request type of the network request to obtain a second resource size comprises:
and when the network request type is an intensive computing resource access request type, reducing the size of the computing resource in the first resource size to obtain a second resource size.
6. The method of claim 2, wherein the parsing the network request received by the network card of the server to obtain the network request type of the network request comprises:
analyzing the bytes with the preset number in the first data packet of the network request received by the network card of the server to obtain the network request type of the network request.
7. The method of claim 1, further comprising:
when the resource size of the resource required by the data volume of the network request received by the network card of the server is larger than the allocated resource size, storing other data of the network request except the data which can be processed by the resource into a hard disk of the server;
and processing other data of the network request stored in the hard disk of the server when the allocated resources are in an idle state.
8. The method according to any of claims 1-7, wherein the resources comprise: memory resources and/or thread resources.
9. A resource allocation apparatus, applied to a server, the apparatus comprising:
the flow determining module is used for determining real-time network flow of the server, wherein the real-time network flow comprises data volume of a network request received by a network card of the server;
the resource allocation module is used for allocating resources for processing the network request according to the data volume of the network request received by the network card of the server and a preset resource volume flow relationship, wherein the resource volume flow relationship is as follows: the network flow is determined according to the network flow counted in advance and the resource size of the resource used by the network flow.
10. The apparatus of claim 9, wherein the resources comprise: memory resources and thread resources.
11. A server is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing the communication between the processor and the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 8 when executing a program stored in the memory.
12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-8.
CN202010247311.3A 2020-03-31 2020-03-31 Resource allocation method, device, server and computer readable storage medium Pending CN113467924A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010247311.3A CN113467924A (en) 2020-03-31 2020-03-31 Resource allocation method, device, server and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010247311.3A CN113467924A (en) 2020-03-31 2020-03-31 Resource allocation method, device, server and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN113467924A true CN113467924A (en) 2021-10-01

Family

ID=77865753

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010247311.3A Pending CN113467924A (en) 2020-03-31 2020-03-31 Resource allocation method, device, server and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN113467924A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113992593A (en) * 2021-10-20 2022-01-28 京东科技信息技术有限公司 Service resource calling method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113992593A (en) * 2021-10-20 2022-01-28 京东科技信息技术有限公司 Service resource calling method and device, electronic equipment and storage medium
CN113992593B (en) * 2021-10-20 2024-03-01 京东科技信息技术有限公司 Service resource calling method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111262795B (en) Service interface-based current limiting method and device, electronic equipment and storage medium
WO2019120217A1 (en) Token obtaining method and apparatus, server, user terminal, and medium
KR101923706B1 (en) Stochastic throttling
WO2021057607A1 (en) Method and apparatus for node speed limiting, electronic device, and storage medium
CN113535363A (en) Task calling method and device, electronic equipment and storage medium
CN110224943B (en) Flow service current limiting method based on URL, electronic equipment and computer storage medium
CN107070709B (en) NFV (network function virtualization) implementation method based on bottom NUMA (non uniform memory Access) perception
CN111338967A (en) Shunting test method and device, electronic equipment and storage medium
CN111597040A (en) Resource allocation method, device, storage medium and electronic equipment
CN113765814A (en) Network access current limiting method and device
CN114661476A (en) Task processing method, device, equipment and storage medium
CN113467924A (en) Resource allocation method, device, server and computer readable storage medium
CN114422439A (en) Interface current limiting method and device, computer equipment and storage medium
CN104008016A (en) Information processing apparatus, resource control method, and program
CN112653736B (en) Parallel source returning method and device and electronic equipment
US7822918B2 (en) Preallocated disk queuing
CN112130997B (en) Resource allocation method and device
CN116192752A (en) Service flow control method, device, electronic equipment and storage medium
US10366358B1 (en) Backlogged computing work exchange
CN108845860B (en) Method and device for managing quota and electronic equipment
CN113079062B (en) Resource adjusting method and device, computer equipment and storage medium
CN112131257B (en) Data query method and device
CN110851483B (en) Method, apparatus, electronic device, and medium for screening objects
CN113760989A (en) Method, device and equipment for processing unbounded stream data and storage medium
CN112527482A (en) Task management method and system based on mobile edge cloud platform

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination