Network request processing method and device, equipment and storage medium
By extracting and classifying network requests in the Internet of Things control platform, and using hash function and hash bucket mechanism, the problem of inefficient network request processing in the Internet of Things is solved, and efficient network request processing is achieved.
Patent Information
- Application Number
- CN202411817558.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the Internet of Things, the control platform needs to process a large number of different types of network requests, resulting in inefficient processing, especially in high concurrency conditions that may cause network request congestion.
By receiving network requests from each terminal device, the feature information for each network request is determined and a feature identifier is generated. Network requests are classified and processed according to feature identifiers, and hash function and hash bucket mechanism are used to process network requests from high to low according to priority.
It realizes the classification processing of multiple network requests, centrally handles similar requests, avoids frequent switching of processing logic, shortens processing time, and improves processing efficiency.
Smart Images

Figure CN119652926A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of Internet of Things, and in particular to a method, apparatus, device and storage medium for processing a network request. Background Art
[0002] With the continuous development of IoT technology, users can now send network requests for IoT devices to the control platform through terminal devices, so as to control the IoT devices to change operating parameters through the control platform.
[0003] There are many IoT devices in the Internet of Things. These IoT devices are different in terms of users, device types, and device functions, and these differences increase the complexity of network requests. After receiving network requests sent by different terminal devices, the control platform often processes each network request one by one according to the order in which the network requests are received. However, this method of processing network requests one by one is relatively inefficient. Specifically, there are a large number of IoT devices and many functions of IoT devices, which means that the control platform needs to process a large number of network requests. However, processing network requests one by one means that only one network request can be processed at a time, and different types of network requests are mixed, which will lead to a decrease in the processing efficiency of network requests. Especially in the face of high-concurrency network requests, the control platform is limited by system resources, and even due to the low processing efficiency of network requests, network request congestion may occur. Furthermore, different types of network requests may need to query different databases and use different processing logics to process network requests. The control platform needs to frequently switch databases and processing logics in the process of processing network requests one by one, which not only reduces the processing efficiency of network requests, but also increases the processing overhead of the control platform. Summary of the invention
[0004] The present application provides a method, apparatus, device and storage medium for processing a network request to solve the problem of low processing efficiency of network requests caused by processing network requests one by one.
[0005] In view of the above technical problems, the technical solution of this application is solved by the following embodiments:
[0006] An embodiment of the present application provides a method for processing a network request, comprising: receiving multiple network requests from various terminal devices; determining, for each of the network requests, multiple feature information corresponding to the network request, and generating a feature identifier corresponding to the network request based on the multiple feature information corresponding to the network request; and classifying and processing each of the network requests based on the feature identifiers respectively corresponding to the multiple network requests.
[0007] Wherein, the determining of the multiple feature information corresponding to the network request includes at least one of the following methods: extracting multiple feature types and feature values corresponding to each feature type from the network request; identifying the feature type and feature value matching the field information in the first field of the network request in a preset first comparison table, and determining the feature type and feature value matching the field information in the first field as the feature information corresponding to the network request; querying the identification information corresponding to the field information in the second field of the network request; identifying the feature type and feature value matching the identification information in a preset second comparison table, and determining the feature type and feature value matching the identification information as the feature information corresponding to the network request; in the network request, extracting the field information in the third field, and determining the field type of the third field and the field information in the third field as the feature information corresponding to the network request; wherein the field type is used as the feature type, and the field information in the third field is used as the feature value.
[0008] Each of the feature information includes: a feature type and a feature value; generating a feature identifier corresponding to the network request according to the multiple feature information corresponding to the network request includes: initializing the feature identifier; wherein the feature identifier includes multiple data bits, each of which corresponds to a feature type; for each of the feature information, according to the feature type in the feature information, adding the feature value in the feature information to the corresponding data bit in the feature identifier to form the feature identifier corresponding to the network request.
[0009] Among them, the classification and processing of each of the network requests according to the characteristic identifiers respectively corresponding to the multiple network requests includes: for each of the network requests, using a preset hash function, determining the hash value of the characteristic identifier corresponding to the network request, and performing format conversion processing on the hash value to obtain a discrete value corresponding to the network request; determining the hash bucket to which the discrete value corresponding to the network request belongs among the preset multiple hash buckets; wherein each of the hash buckets corresponds to a numerical range and to a priority; and according to the priorities respectively corresponding to the multiple hash buckets, processing the network requests included in each of the hash buckets in order from high to low priority.
[0010] Among them, the processing of the network requests included in each hash bucket includes: for each hash bucket, identifying the network requests with the same control information among the network requests included in the hash bucket; recording the source devices corresponding to the network requests with the same control information; generating an aggregate request based on the network requests with the same control information; processing the aggregate request and returning the processing result corresponding to the aggregate request to the source devices corresponding to the network requests with the same control information.
[0011] The processing of the network request included in each hash bucket includes: for each hash bucket, processing each network request included in the hash bucket in a first-in-first-out order.
[0012] Among them, the processing of the network requests included in each hash bucket in order from high to low priority according to the priorities respectively corresponding to the multiple hash buckets includes: after detecting the start of a discrete processing time period, querying each hash bucket including the network requests in real time, and, among each hash bucket including the network requests, only processing the network requests included in the hash bucket with the highest priority; after the end of the discrete processing time period, starting from the hash bucket with the highest priority, after all the network requests included in the hash buckets with high priority are processed, starting to process the network requests included in the hash buckets with the next priority, until all the network requests included in the hash buckets with the lowest priority are processed.
[0013] The embodiment of the present application also provides a network request processing device, including: a receiving module, used to receive multiple network requests from various terminal devices; a determination and generation module, used to determine, for each of the network requests, multiple feature information corresponding to the network request, and generate a feature identifier corresponding to the network request based on the multiple feature information corresponding to the network request; a classification processing module, used to classify and process each of the network requests according to the feature identifiers respectively corresponding to the multiple network requests.
[0014] An embodiment of the present application also provides a network request processing device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; at least one memory connected to the at least one bus, wherein the processor is configured to: execute a network request processing program stored in the memory to implement any of the above-mentioned network request processing methods.
[0015] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed to implement any of the above-mentioned methods for processing network requests.
[0016] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application can receive multiple network requests from various terminal devices; for each of the network requests, multiple feature information corresponding to the network request is determined, and, based on the multiple feature information corresponding to the network request, a feature identifier corresponding to the network request is generated; and each of the network requests is classified and processed according to the feature identifiers corresponding to the multiple network requests. The embodiment of the present application classifies and processes multiple network requests, and centrally processes the same type of network requests, which can avoid frequent switching of processing logic, shorten the processing time of network requests, and improve the processing efficiency of network requests. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0020] Figure 1 is a flowchart of a method for processing a network request according to an embodiment of the present application;
[0021] Figure 2 A flowchart of steps for generating a feature identifier according to an embodiment of the present application;
[0022] Figure 3 A flowchart of the steps for processing a network request according to an embodiment of the present application;
[0023] Figure 4 A flowchart of the steps of network request merging processing according to an embodiment of the present application;
[0024] Figure 5is a structural diagram of a network request processing device according to an embodiment of the present application;
[0025] Figure 6 The present invention is a structural diagram of a network request processing device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0027] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0028] The embodiment of the present application provides a method for processing a network request. The execution subject of the present application is a control platform or a cloud server. The control platform can be a control device in a local area network. The control device is connected to a cloud server in the Internet. For example: the control platform is a central processor in a smart home system.
[0029] Figure 1 The present invention is a flowchart of a method for processing a network request according to an embodiment of the present application.
[0030] Step S110, receiving multiple network requests from various terminal devices.
[0031] A terminal device refers to a terminal device that runs a preset application. The application can be bound to a preset IoT device for information query and device control of the IoT device. Furthermore, the types of terminal devices include, but are not limited to, IoT devices and user terminals. The types of IoT devices include, but are not limited to, lighting equipment, security equipment, smart air conditioners, smart refrigerators, smart TVs, and smart kitchens and bathrooms. The types of user terminals include, but are not limited to, user mobile phones, tablet computers, and smart remote controls. For example: if the terminal device is a smart air conditioner, an air conditioner control application is installed in the smart air conditioner, and the air conditioner control application is bound to the smart air conditioner to control the operation of the smart air conditioner. Another example: if the terminal device is a user's mobile phone, an air conditioner remote control application is installed in the user's mobile phone, and the air conditioner remote control application is bound to the smart air conditioner to control the operation of the smart air conditioner.
[0032] The network request is used to request information query or device control for the IoT device. The source of the network request is the IoT device or the user terminal, and the destination of the network request is the cloud server. Furthermore, when the source of the network request is the IoT device, the destination of the network request is the cloud server, so that the device information of the IoT device can be queried on the cloud server; when the source of the network request is the user terminal, the destination of the network request is the cloud server, so that the device information of the IoT device can be queried on the cloud server, or, a control instruction for controlling the IoT device is generated by the cloud server and sent to the IoT device. Among them, if the execution subject of the embodiment of the present application is a control platform, the control platform acts as an intermediate device between the source and destination of the network request.
[0033] In the embodiment of the present application, since the control platform or cloud server serving as the execution entity is connected to multiple terminal devices, it can receive network requests sent by multiple terminal devices.
[0034] Step S120: for each of the network requests, determine a plurality of feature information corresponding to the network request, and generate a feature identifier corresponding to the network request according to the plurality of feature information corresponding to the network request.
[0035] Feature information refers to the features corresponding to the network request. For example, feature information includes the device type and its feature value, user type and its feature value, timestamp, etc. corresponding to the network request.
[0036] The feature identifier refers to a string obtained by arranging multiple feature information corresponding to a network request according to a preset arrangement rule. Furthermore, the feature identifier corresponding to the network request can be used to reflect the priority of the network request. Since multiple network requests need to be classified, the arrangement rules used by multiple network requests are the same.
[0037] Step S130: classify and process each of the network requests according to the feature identifiers respectively corresponding to the multiple network requests.
[0038] In an embodiment of the present application, network requests with the same characteristic identifier may be aggregated to obtain multiple network request sets, and each network request in each network request set may be processed one by one.
[0039] For example: the feature identifier is a character string obtained by sequentially arranging the feature values corresponding to the device type and the feature values corresponding to the user type. After aggregating the network requests according to the character string, the network requests in the same network request set can correspond to the same device type and the same user type, thereby centrally processing the network requests with the same device type and the same user type.
[0040] In an embodiment of the present application, multiple network requests can be prioritized according to the feature identifiers corresponding to the multiple network requests, and each network request can be processed according to the priority corresponding to each network request. Furthermore, since the feature information can be used to reflect whether the network request needs to be processed with priority, the feature identifier generated by the feature information can also reflect whether the network request needs to be processed with priority, and then the multiple network requests can be prioritized according to the feature identifiers corresponding to the multiple network requests. The specific method of priority classification will be described later, so it will not be repeated here.
[0041] In an embodiment of the present application, multiple network requests are received from various terminal devices; for each of the network requests, multiple feature information corresponding to the network request is determined, and a feature identifier corresponding to the network request is generated according to the multiple feature information corresponding to the network request; and each of the network requests is classified and processed according to the feature identifiers respectively corresponding to the multiple network requests. The embodiment of the present application classifies and processes multiple network requests, and centrally processes the same type of network requests, which can avoid frequent switching of processing logic, shorten the processing time of network requests, and improve the processing efficiency of network requests.
[0042] In order to make the embodiments of the present application easier to understand, the method for processing network requests in the embodiments of the present application will be further described below.
[0043] In the Internet of Things, there are many types of IoT devices. For example, in a smart home environment, the types of IoT devices include but are not limited to lighting equipment, security equipment, smart air conditioners, smart refrigerators, smart TVs, and smart kitchens and bathrooms. Different IoT devices differ in manufacturers, users, configuration data, device functions, and control methods. This results in differences in the databases that need to be queried when processing network requests, and differences in the processing logic that needs to be used. After receiving network requests issued for different IoT devices, if network requests are processed one by one, different databases will be frequently queried, and different processing logics will be frequently switched, resulting in low efficiency in processing network requests. Moreover, when using IoT devices, different users, different device types of IoT devices, and different needs of users for IoT devices make the urgency of network requests issued for IoT devices different. If network requests are processed one by one, network requests that need to be processed urgently may be submerged in high-concurrency network requests. For example, network requests for security devices are more urgent than other network requests. If network requests for security devices are issued after other network requests are issued, and the issuance time is during a high-concurrency period, network requests for security devices will not be processed in time. To address these issues, the embodiments of the present application classify and process network requests.
[0044] In an embodiment of the present application, before classifying a network request, it is necessary to determine multiple feature information corresponding to the network request. Each feature information includes: a feature type and a feature value. For the same feature type, different feature values represent different priorities. Further, determining multiple feature information corresponding to the network request includes at least one of the following methods:
[0045] Method 1: Extract multiple feature types and feature values corresponding to each feature type in the network request. Through pre-negotiation, each terminal device can pre-store multiple feature types corresponding to the IoT device and feature values corresponding to each feature type. In this way, when the terminal device sends a network request, it can directly carry the feature type and feature values corresponding to each feature type in the network request.
[0046] Method 2: In a preset first comparison table, identify the feature type and feature value that match the field information in the first field of the network request, and determine the feature type and feature value that match the field information in the first field as the feature information corresponding to the network request.
[0047] The first comparison table is used to record the feature type and feature value corresponding to the device. Among them, the feature type in the first comparison table is the device information of the Internet of Things device. The device information of the Internet of Things device includes but is not limited to: device location, device type and device function. The feature value in the first comparison table includes the value corresponding to the device location, the value corresponding to the device type, or the value corresponding to the parameter of the device function. For example: different feature values are set for different device types (feature types). For example: the feature type is the brightness adjustment function of the smart light, the feature value corresponding to high brightness is 1, and the feature value corresponding to low brightness is 2. Furthermore, the size of the feature value can be determined according to demand.
[0048] The first field is used to record the device information and control target of the IoT device. The first field is a field type. The number of the first field is at least one.
[0049] The first field of the network request carries the device information and / or control target of the IoT device. The control target may be the target function and target parameter to be controlled. For example, if the network request carries the control target "adjust the brightness of the smart light in the living room to high brightness", when matching the first comparison table, "living room" is the device location, "smart light" is the device type, the target function is "brightness adjustment", and the target parameter is "high brightness", so that a unique feature type and feature value can be matched.
[0050] Method three: query the identification information corresponding to the field information in the second field of the network request; in the preset second comparison table, identify the feature type and feature value that match the identification information, and determine the feature type and feature value that match the identification information as the feature information corresponding to the network request.
[0051] The second field is used to record user information and device information of the IoT device. The user information includes but is not limited to: user type. The device information of the IoT device includes but is not limited to: device type of the IoT device. Furthermore, the second field is a field type. The number of the second field is at least one. The second field and the first field are exactly the same field, or completely different fields, or partially overlapping fields. For example: there are two overlapping fields between the three fields of the first field and the four fields of the second field.
[0052] The identification information is used to identify the type level. Among them, the user type level (also known as: user identification) can be queried using the user information. For example: the user type level is a paying user or a guest user, and the paying user is higher than the guest user. The device type level (also known as: device identification) can be queried using the device information. Another example: the device type level is the priority of the device type, such as: the level of security equipment is higher than the level of smart TVs. Furthermore, the user type level corresponding to the user information and the device type level corresponding to the device information can be queried in the database. Furthermore, the user type level and the device type level can be determined according to demand.
[0053] The second comparison table is used to record the feature type and feature value corresponding to the identifier. The feature types in the second comparison table include but are not limited to: user type level and device type level. The feature value in the second comparison table is the value of the user type level or the value of the device type level.
[0054] Method 4: In the network request, extract the field information in the third field, and determine the field type of the third field and the field information in the third field as characteristic information corresponding to the network request; wherein the field type is used as the characteristic type, and the field information in the third field is used as the characteristic value.
[0055] The third field is used to record auxiliary information for determining the classification of the network request. Further, the third field is used to record auxiliary information that is expected to affect the priority of the network request. The number of the third field is at least one. The third field may be an additional field in the network request. The number and meaning of the third field may be determined according to the requirements. For example, the types of the third field include but are not limited to: the urgency code field of the network request, the user requirement code field, and the generation timestamp field of the network request. Among them, the third field is the field type. The urgency code field is used to record the urgency code, which is used to indicate the urgency of the network request. For example, the urgency is divided into three levels: high, medium and low. In order from high to low, the urgency codes are 3, 2 and 1 in sequence. The user requirement code field is used to record the user requirement code, which is used to indicate the user's preference for the control target in the network request. For example, the important requirement code is 3, the general requirement code is 2, and the secondary requirement code is 1.
[0056] In the embodiment of the present application, after determining the multiple feature information corresponding to the network request, it is necessary to generate a feature identifier corresponding to the network request according to the multiple feature information corresponding to the network request.
[0057] Figure 2 The present invention is a flowchart of the steps of generating a feature identifier according to an embodiment of the present application.
[0058] Step S210, initializing a feature identifier; wherein the feature identifier includes a plurality of data bits, each of which corresponds to a feature type.
[0059] In the feature identifier after initialization, each data bit is an initial value. The initial value is a preset value. For example, the initial value is 0.
[0060] In the embodiment of the present application, the number of data bits included in the feature identifier and the feature type corresponding to each data bit can be designed based on the device functions of each IoT device, the device type of each IoT device, the user type involved and the auxiliary information.
[0061] For example: the feature identifier includes 16 data bits, the first bit is used to place the feature value corresponding to the device type, the second bit is used to place the urgency code, the third bit is used to place the user demand code, and the 4th to 16th bits are used to place the generation timestamp of the network request.
[0062] Step S220: for each piece of the feature information, according to the feature type in the feature information, add the feature value in the feature information to the corresponding data bit in the feature identifier to form a feature identifier corresponding to the network request.
[0063] After determining multiple feature information corresponding to the network request, in the initialized feature identifier, according to the feature type and feature value in each feature information, the feature value is added to the data bit corresponding to the feature type, and for the data bit without the feature value added, the initial value of the data bit is maintained, and finally the feature identifier corresponding to the network request is formed.
[0064] Furthermore, the feature values in each feature information of the network request are added to the initialized feature identifier in a fixed feature type order, and a string can be concatenated as the feature identifier corresponding to the network request. Using feature identifiers to classify network requests can improve classification efficiency, avoid using complex judgment steps to classify network requests, and avoid errors in the judgment process due to complex judgment steps.
[0065] In an embodiment of the present application, after generating a feature identifier corresponding to a network request, the network request can be diverted to a corresponding category according to the feature identifier corresponding to the network request so as to classify and process the network request.
[0066] Furthermore, for each of the network requests, a preset hash function is used to determine the hash value of the feature identifier corresponding to the network request, and the hash value is converted to obtain a discrete value corresponding to the network request; in the preset multiple hash buckets, the hash bucket to which the discrete value corresponding to the network request belongs is determined; wherein each of the hash buckets corresponds to a numerical range; and the network requests included in each of the hash buckets are processed centrally. Since similar network requests have similar feature identifiers, the calculated hash values are also similar, and similar network requests can be divided into one hash bucket. When the network requests in the hash bucket are centrally processed, each similar network request can be centrally processed.
[0067] Furthermore, the network request may be diverted to a corresponding priority category according to a feature identifier corresponding to the network request, so that the network request may be processed according to the priority category.
[0068] Figure 3 The figure is a flow chart of the processing steps of a network request according to an embodiment of the present application.
[0069] Step S310: for each of the network requests, a preset hash function is used to determine a hash value of a feature identifier corresponding to the network request, and the hash value is format-converted to obtain a discrete value corresponding to the network request.
[0070] Types of hash functions include, but are not limited to, MD5 algorithm and SHA-1 algorithm.
[0071] The format conversion process is used to convert the hash value into a discrete value within a preset discrete value range.
[0072] A discrete value is a value obtained by converting a hash value.
[0073] In an embodiment of the present application, the format conversion process includes: the hash value can be converted into a decimal value to obtain a decimal value, and then the decimal value is modulo 10 to obtain a discrete value.
[0074] Step S320 , determining, among a plurality of preset hash buckets, a hash bucket to which the discrete value corresponding to the network request belongs; wherein each of the hash buckets corresponds to a value range and a priority.
[0075] The hash bucket is used to map network requests. Furthermore, the hash bucket can be in the form of a queue to map each network request corresponding to the hash bucket.
[0076] Each hash bucket corresponds to a numerical range, and network requests with discrete values in this data range enter the hash bucket. The numerical range can be a range including two different end values, or it can be just one numerical value. The specific numerical range can be determined according to demand. For example: if the numerical range of the hash bucket is 3, then the network request with a discrete value of 3 enters the hash bucket. Furthermore, each network request entering the same hash bucket can be stored using a first-in-first-out queue.
[0077] Each hash bucket corresponds to a priority. Different hash buckets correspond to different priorities. Furthermore, there is no corresponding relationship between the end value of the numerical range corresponding to the hash bucket and the priority of the hash bucket.
[0078] In an embodiment of the present application, the network requests that will appear and the discrete values that will appear in the network requests can be determined in advance based on the device functions of each IoT device, the device types of each IoT device, the types of users that will be involved, the auxiliary information, and the number of data bits included in the designed feature identifier and the feature type corresponding to each data bit; multiple hash buckets are set according to the discrete values that will appear, and a data range is set for each hash bucket; the hash bucket that the network request will enter is determined according to the priority of the network request that will appear and the discrete values that will appear in the network request, and a priority is set for the hash bucket according to the hash bucket that the network request will enter, so that the priority of the hash bucket corresponds to the priority of the network request.
[0079] Step S330: Process the network request included in each of the hash buckets according to the priorities corresponding to the multiple hash buckets respectively and in descending order of priority.
[0080] In the embodiment of the present application, for each hash bucket, each of the network requests included in the hash bucket is processed in a first-in-first-out order.
[0081] In an embodiment of the present application, after the start of a discrete processing time period is detected, each hash bucket including the network request is queried in real time, and, among the hash buckets including the network request, only the network request included in the hash bucket with the highest priority is processed; after the discrete processing time period ends, starting from the hash bucket with the highest priority, after all the network requests included in the hash bucket with high priority are processed, the network requests included in the hash bucket with the next priority are processed, until all the network requests included in the hash bucket with the lowest priority are processed.
[0082] Discrete processing time periods refer to time periods in which network requests need to be classified and processed. Discrete processing time periods can be preset time periods, for example, time periods in which high concurrent network requests are likely to occur. Discrete processing time periods can also be determined by real-time detection of the amount of network requests received. When it is determined that the amount of network requests received is greater than a preset amount of received threshold, the discrete processing time period is determined to have arrived, and ends after a preset length of time has passed. The amount of received threshold can be used to measure whether the current network request has high concurrency. The amount of received threshold can be an empirical value or a value obtained through experiments.
[0083] In the discrete processing time period, high-priority network requests are processed first. In this way, it is necessary to determine in real time which hash buckets have unprocessed network requests. For hash buckets with unprocessed network requests, the network requests in the hash bucket with the highest priority are processed first. During the processing, if the network request has not been added to the hash bucket with a higher priority, it is necessary to complete the processing of the network requests in the hash bucket with the highest priority before starting to process the network requests in the hash bucket with the next priority. If the hash bucket with a higher priority contains a request to join the network, the processing of the network requests in the current hash bucket is suspended, and the request to join the network in the hash bucket with a higher priority is processed first. In this way, high-priority network requests can be processed first to avoid the problem that high-priority requests cannot be processed in time.
[0084] After the discrete processing time period ends and all the network requests included in the hash bucket with the lowest priority are processed, each received network request can be processed based on the hash bucket, or each received network request can be processed one by one. If the hash bucket-based method is used to process each received network request, all network requests in each hash bucket can be processed one by one in order from high to low priority, that is: after all network requests in one hash bucket are processed, all network requests in the next hash bucket are processed; or, one network request can be taken from each hash bucket in order from high to low priority for processing, and the network requests in each hash bucket can be processed in a cycle.
[0085] For example, in order of priority from high to low, there are hash bucket 1, hash bucket 2, hash bucket 3, and hash bucket 4. In the discrete processing time period, if there are currently only unprocessed network requests in hash bucket 3 and hash bucket 4, then the network requests in hash bucket 3 are processed first. During the processing, if a network request is added to hash bucket 2, the network request being processed is processed, the processing of the next network request in hash bucket 3 is suspended, and the network request in hash bucket 2 is processed first. During the processing, if an unprocessed network request appears in hash bucket 1, the network request being processed is processed, the processing of the next network request in hash bucket 2 is suspended, and the network request in hash bucket 1 is processed instead. At this time, if the discrete processing time period ends, the network requests in hash bucket 1 are processed first, and the network requests in hash bucket 2 are processed; the network requests in hash bucket 2 are processed, and the network requests in hash bucket 3 are processed; the network requests in hash bucket 3 are processed, and the network requests in hash bucket 4 are processed. After the network requests in hash bucket 4 are processed, each received network request is processed one by one.
[0086] The embodiment of the present application classifies network requests by obtaining a hash value of a feature identifier and determining a hash bucket corresponding to the network request based on the hash value, thereby further simplifying the complexity of the feature identifier, shortening the classification time, and improving the classification rate.
[0087] In the embodiment of the present application, there may be a situation where network requests from different user terminals are used to control the same IoT device and have the same control target. In view of this situation, the embodiment of the present application can adopt a combined processing method to process these network requests.
[0088] Figure 4 The present invention is a flowchart of the steps of merging and processing network requests according to an embodiment of the present application.
[0089] Step S410: for each of the hash buckets, identifying the network requests with the same control information among the network requests included in the hash bucket.
[0090] The same control information means: the IoT devices to be controlled are the same and the control targets (target functions and target parameters) for the IoT devices are the same; or, the IoT devices to be queried are the same and the query information is the same. For example: network requests from different user terminals are all used to request that the temperature of the central air conditioner in the hall be adjusted to 25°C. Another example: network requests from different user terminals are all used to query the alarm information of the same security device.
[0091] Step S420, recording the source devices corresponding to each of the network requests having the same control information.
[0092] The source device (also known as the source end) refers to the device that generates and sends network requests.
[0093] Step S430: Generate an aggregate request according to the network requests with the same control information.
[0094] An aggregate request is a network request that is merged from various network requests with the same control information. The aggregate request includes at least: device information and control targets of the IoT devices to be controlled, or device information and query information of the IoT devices to be queried.
[0095] Step S440: Process the aggregation request and return the processing result corresponding to the aggregation request to the source devices corresponding to each of the network requests having the same control information.
[0096] In the case where the execution subject is a cloud server, if the aggregate request is used to control an IoT device, a control instruction is generated according to the aggregate request, the control instruction is sent to the IoT device, and the response message returned by the IoT device is returned to each source device as a processing result. If the aggregate request is used to query the information of an IoT device, the information of the IoT device is queried according to the aggregate request, and the query result is returned to each source device as a processing result.
[0097] When the execution subject is a control platform, an aggregation request is sent to a cloud server, a processing result returned by the cloud server is received, and the processing result is returned to each source-end device.
[0098] The embodiment of the present application combines various network requests with the same control information into an aggregate request and only processes the aggregate request. In this way, the number of times network requests are processed can be reduced, the processing time of network requests can be shortened, and the processing efficiency of network requests can be improved.
[0099] A more specific example will be provided below to describe the method for processing network requests in an embodiment of the present application.
[0100] This example takes a smart home system as an example. The smart home system includes a variety of IoT devices, including but not limited to: smart light bulbs, smart door locks, smart cameras, and smart air conditioners.
[0101] When calculating the hash value, you can first determine multiple feature types of the network request and the feature values corresponding to each feature type, then concatenate the feature values into a feature identifier according to the preset feature type arrangement order, and then calculate the hash value of the feature identifier.
[0102] For example, for a request to adjust the brightness of a smart light, the device type code (1), urgency code (1), user requirement code (2) and timestamp (1695432100000) of the smart light are concatenated into a string (i.e., feature identifier) "1121695432100000"; the MD5 algorithm is used to calculate the hash value of the string, assuming that the obtained hash value is "abcdef1234567890".
[0103] For another example, in response to a smart door lock fault alarm request, the device type code (2), urgency code (3), user requirement code (3) and timestamp (1695432100000) of the smart door lock are concatenated into a string (i.e., feature identifier) "2331695432100000", and the hash value of the string is calculated using the MD5 algorithm. Assume that the obtained hash value is "fedcba0987654321".
[0104] When dividing the hash buckets, for example, the total value range can be divided into 10 hash buckets, each of which corresponds to a small value range in the total value range. After the network requests the corresponding hash value, the hash value is converted to a decimal number, and then modulo 10 to obtain a discrete value, and the hash bucket to which the discrete value belongs is determined.
[0105] For example, the hash value "abcdef1234567890" corresponding to the smart light bulb brightness adjustment request is converted to decimal and modulo 10 to obtain a discrete value of 5. Then the smart light bulb brightness adjustment request can be assigned to hash bucket 5.
[0106] For another example, the hash value "fedcba0987654321" corresponding to the smart door lock fault alarm request is converted into decimal and modulo 10 to obtain a discrete value of 2. Then the smart door lock fault alarm request can be assigned to hash bucket 2.
[0107] In this way, different network requests are assigned to different hash buckets, and the central processor in the smart home system can process the requests in each hash bucket in a certain order, and batch process the network requests in the same hash bucket, thereby improving the efficiency of network request processing. For example, if there are multiple smart bulb brightness adjustment requests within a certain time period, these smart bulb brightness adjustment requests are all assigned to hash bucket 5, and the central processor can centrally process these smart bulb brightness adjustment requests, reduce repeated operations, and optimize resource allocation.
[0108] The embodiment of the present application can map similar network requests to the same hash bucket through a hash function, and then batch process the network requests in the same hash bucket, reduce repeated calculations and resource consumption, and improve the efficiency of network request processing. The embodiment of the present application can also reasonably allocate system resources according to the characteristics and priorities of the network requests, ensure that high-priority network requests are processed in a timely manner, and improve the stability and reliability of the system. The embodiment of the present application makes the management of network requests clearer and more orderly by dividing the hash buckets, and can easily monitor, count and analyze, which is convenient for system maintenance and optimization.
[0109] The present application also provides a network request processing device. Figure 5 , which is a structural diagram of a network request processing device according to an embodiment of the present application.
[0110] The network request processing device includes:
[0111] The receiving module 510 is used to receive multiple network requests from various terminal devices.
[0112] The determination and generation module 520 is used to determine, for each of the network requests, a plurality of feature information corresponding to the network request, and generate a feature identifier corresponding to the network request according to the plurality of feature information corresponding to the network request.
[0113] The classification processing module 530 is used to classify and process each of the network requests according to the feature identifiers respectively corresponding to the multiple network requests.
[0114] The functions of the device described in the embodiment of the present application have been described in the above method embodiment. Therefore, for any details not provided in the description of this embodiment, please refer to the relevant descriptions in the above embodiment and will not be repeated here.
[0115] The present application also provides a network request processing device, such as Figure 6 , which is a structural diagram of a network request processing device according to an embodiment of the present application.
[0116] The network request processing device includes: a processor 610, a communication interface 620, a memory 630 and a communication bus 640. The processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640.
[0117] The memory 630 is used to store computer programs.
[0118] In one embodiment of the present application, the processor 610, when executing the program stored in the memory 630, implements the method for processing network requests provided by any of the aforementioned method embodiments, including: receiving multiple network requests from various terminal devices; for each of the network requests, determining multiple feature information corresponding to the network request, and generating a feature identifier corresponding to the network request based on the multiple feature information corresponding to the network request; and classifying and processing each of the network requests based on the feature identifiers respectively corresponding to the multiple network requests.
[0119] Wherein, the determining of the multiple feature information corresponding to the network request includes at least one of the following methods: extracting multiple feature types and feature values corresponding to each feature type from the network request; identifying the feature type and feature value matching the field information in the first field of the network request in a preset first comparison table, and determining the feature type and feature value matching the field information in the first field as the feature information corresponding to the network request; querying the identification information corresponding to the field information in the second field of the network request; identifying the feature type and feature value matching the identification information in a preset second comparison table, and determining the feature type and feature value matching the identification information as the feature information corresponding to the network request; in the network request, extracting the field information in the third field, and determining the field type of the third field and the field information in the third field as the feature information corresponding to the network request; wherein the field type is used as the feature type, and the field information in the third field is used as the feature value.
[0120] Each of the feature information includes: a feature type and a feature value; generating a feature identifier corresponding to the network request according to the multiple feature information corresponding to the network request includes: initializing the feature identifier; wherein the feature identifier includes multiple data bits, each of which corresponds to a feature type; for each of the feature information, according to the feature type in the feature information, adding the feature value in the feature information to the corresponding data bit in the feature identifier to form the feature identifier corresponding to the network request.
[0121] Among them, the classification and processing of each of the network requests according to the characteristic identifiers respectively corresponding to the multiple network requests includes: for each of the network requests, using a preset hash function, determining the hash value of the characteristic identifier corresponding to the network request, and performing format conversion processing on the hash value to obtain a discrete value corresponding to the network request; determining the hash bucket to which the discrete value corresponding to the network request belongs among the preset multiple hash buckets; wherein each of the hash buckets corresponds to a numerical range and to a priority; and according to the priorities respectively corresponding to the multiple hash buckets, processing the network requests included in each of the hash buckets in order from high to low priority.
[0122] Among them, the processing of the network requests included in each hash bucket includes: for each hash bucket, identifying the network requests with the same control information among the network requests included in the hash bucket; recording the source devices corresponding to the network requests with the same control information; generating an aggregate request based on the network requests with the same control information; processing the aggregate request and returning the processing result corresponding to the aggregate request to the source devices corresponding to the network requests with the same control information.
[0123] The processing of the network request included in each hash bucket includes: for each hash bucket, processing each network request included in the hash bucket in a first-in-first-out order.
[0124] Among them, the processing of the network requests included in each hash bucket in order from high to low priority according to the priorities respectively corresponding to the multiple hash buckets includes: after detecting the start of a discrete processing time period, querying each hash bucket including the network requests in real time, and, among each hash bucket including the network requests, only processing the network requests included in the hash bucket with the highest priority; after the end of the discrete processing time period, starting from the hash bucket with the highest priority, after all the network requests included in the hash buckets with high priority are processed, starting to process the network requests included in the hash buckets with the next priority, until all the network requests included in the hash buckets with the lowest priority are processed.
[0125] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for processing a network request provided in any of the aforementioned method embodiments are implemented. Since the method for processing a network request has been described in detail above, for any details not detailed in the description of this embodiment, please refer to the relevant description in the aforementioned embodiment, and no further description will be given here.
[0126] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0127] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0128] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0129] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A method for processing a network request, characterized in that: include: Receive multiple network requests from various terminal devices; For each of the network requests, determine a plurality of feature information corresponding to the network request, and generate a feature identifier corresponding to the network request according to the plurality of feature information corresponding to the network request; Each of the network requests is classified and processed according to feature identifiers respectively corresponding to the multiple network requests.
2. The method according to claim 1, characterized in that The determining of the plurality of feature information corresponding to the network request includes at least one of the following methods: Extracting multiple feature types and feature values corresponding to each feature type from the network request; In a preset first comparison table, identifying a feature type and a feature value that match the field information in the first field of the network request, and determining the feature type and the feature value that match the field information in the first field as the feature information corresponding to the network request; Querying identification information corresponding to the field information in the second field of the network request; identifying a feature type and a feature value matching the identification information in a preset second comparison table, and determining the feature type and the feature value matching the identification information as the feature information corresponding to the network request; In the network request, field information in the third field is extracted, and the field type of the third field and the field information in the third field are determined as characteristic information corresponding to the network request; wherein the field type is used as the characteristic type, and the field information in the third field is used as the characteristic value.
3. The method according to claim 1, characterized in that Each of the feature information includes: a feature type and a feature value; The step of generating a feature identifier corresponding to the network request according to the plurality of feature information corresponding to the network request includes: Initialize a feature identifier; wherein the feature identifier includes a plurality of data bits, each of which corresponds to a feature type; For each piece of the feature information, according to the feature type in the feature information, the feature value in the feature information is added to the corresponding data bit in the feature identifier to form a feature identifier corresponding to the network request.
4. The method according to claim 1, characterized in that The classifying and processing each of the network requests according to the feature identifiers respectively corresponding to the plurality of network requests comprises: For each of the network requests, a preset hash function is used to determine a hash value of a feature identifier corresponding to the network request, and the hash value is converted to obtain a discrete value corresponding to the network request; Determine, among a plurality of preset hash buckets, a hash bucket to which the discrete value corresponding to the network request belongs; wherein each of the hash buckets corresponds to a value range and a priority; According to the priorities respectively corresponding to the plurality of hash buckets, the network request included in each of the hash buckets is processed in order of priority from high to low.
5. The method according to claim 4, characterized in that The processing of the network request included in each of the hash buckets includes: For each of the hash buckets, identifying the network requests with the same control information among the network requests included in the hash bucket; Record the source devices corresponding to the network requests with the same control information; generating an aggregate request according to the network requests having the same control information; The aggregation request is processed and a processing result corresponding to the aggregation request is returned to the source devices corresponding to each of the network requests having the same control information.
6. The method according to claim 4, characterized in that The processing of the network request included in each of the hash buckets includes: For each of the hash buckets, the network requests included in the hash bucket are processed in a first-in-first-out order.
7. The method according to claim 4, characterized in that The processing of the network request included in each hash bucket according to the priorities respectively corresponding to the plurality of hash buckets in descending order of priority includes: After detecting that a discrete processing time period has started, querying each of the hash buckets including the network request in real time, and, among the hash buckets including the network request, only processing the network request included in the hash bucket with the highest priority; After the discrete processing time period ends, starting from the hash bucket with the highest priority, after all the network requests included in the hash bucket with the high priority are processed, the network requests included in the hash bucket with the next priority are processed until all the network requests included in the hash bucket with the lowest priority are processed.
8. A network request processing device, characterized in that: include: A receiving module, used for receiving multiple network requests from various terminal devices; A determination and generation module, configured to determine, for each of the network requests, a plurality of feature information corresponding to the network request, and generate a feature identifier corresponding to the network request according to the plurality of feature information corresponding to the network request; The classification processing module is used to classify and process each of the network requests according to the feature identifiers respectively corresponding to the multiple network requests.
9. A network request processing device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to: execute a network request processing program stored in the memory to implement the network request processing method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed to implement the method for processing a network request according to any one of claims 1 to 7.
Citation Information
Patent Citations
Network request processing method and device, computer equipment and storage medium
CN110113384A
Service processing method and network service system
CN112351083A
Information processing method and device, device, equipment and storage medium
CN115729882A
Network request processing method and device, equipment and storage medium
CN116996581A
Method and device for merging network requests by using request fingerprints
CN117176807A