Upload and download speed limiting method and device, electronic equipment and storage medium
By classifying upload and download requests and calculating the proportion of user resources, the rate limit is dynamically adjusted, solving the problem that the rate limit method in the existing technology cannot be flexibly adjusted, improving the stability of data transmission and server security, and is suitable for data transmission in digital healthcare and smart cities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-26
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, upload and download speed limiting methods cannot be dynamically adjusted according to user behavior, resulting in poor data transmission stability. This is especially true when medical servers are transmitting large amounts of electronic medical records, increasing the risk of server downtime.
By classifying upload and download requests, identifying users based on IP address and login token, calculating the resource share of each user, and dynamically adjusting the upload and download speed limits for each user according to preset data write and read speeds, the speed limit rules are updated in real time.
It improves the stability of data transmission, reduces the risk of server downtime, and enables flexible rate limiting management, making it suitable for large-scale data transmission scenarios in digital healthcare systems and smart cities.
Smart Images

Figure CN116708187B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence and digital medical technology, and in particular to an upload and download speed limiting method and device, electronic equipment and a storage medium. BACKGROUND
[0002] With the development of cloud computing and big data, the amount of data that needs to be processed or transmitted in various fields of production and life is also increasing, and the stability of data transmission has also received more and more attention. For example, various data interaction systems that need to upload and download a large number of files, images, etc., such as financial systems, government systems, and ticket systems, will encounter problems of data transmission stability. For example, when a medical server receives or reads medical data, if a user transmits a large number of electronic case files to the medical server or downloads a large number of electronic case files from the medical server in a period of time, it may cause the central processing unit usage of the medical server to increase rapidly, the read and write speed of the disk to increase rapidly, and thus increase the risk of medical server downtime.
[0003] Currently, upload and download speed limits are usually set for each user or each upload and download request to avoid server downtime caused by rapid server read and write speed. However, this approach is not flexible enough and cannot dynamically change according to user upload and download behavior, resulting in poor data transmission stability. SUMMARY
[0004] In view of the above, it is necessary to provide an upload and download speed limiting method and related equipment to solve the technical problem of how to improve the stability of upload and download speed limiting, wherein the related equipment includes an upload and download speed limiting device, electronic equipment and a storage medium.
[0005] The present application provides an upload and download speed limiting method, which comprises:
[0006] Classify the upload requests and download requests received in real time within a preset update period respectively, obtain the categories corresponding to each upload request and download request, and query the users corresponding to the upload requests of each category and the download requests of each category;
[0007] For each user, calculate the upload resource proportion of the user in the preset update period according to the upload data recorded in the upload request of the user, and calculate the download resource proportion of the user in the preset update period according to the download data recorded in the download request of the user;
[0008] According to the preset data write speed and the upload resource proportion, calculate the upload speed limit of each user in the preset update period;
[0009] According to the preset data reading speed and the download resource proportion, a download speed limit of each user in the preset update period is calculated;
[0010] Every other preset update period, the upload data amount corresponding to each upload request and the download data amount corresponding to each download request are queried in real time, and the upload speed limit of each upload request and the download speed limit of each download request are updated in real time according to the upload data amount, the download data amount, the upload speed limit of each user and the download speed limit of each user.
[0011] In some embodiments, the real-time received upload request and download request are classified respectively to obtain the category corresponding to each upload request and each download request, specifically including:
[0012] The IP address and login token of the upload request and the download request are parsed;
[0013] The upload requests with the same IP address and login token are classified into the same category, and the download requests with the same IP address and login token are classified into the same category;
[0014] For each category of upload request, the user name recorded in the login token is queried as the name of the category;
[0015] For each category of download request, the user name recorded in the login token is queried as the name of the category.
[0016] In some embodiments, the upload resource proportion of the user is calculated according to the upload data amount recorded in the upload request of the user, and the download resource proportion of the user is calculated according to the download data amount recorded in the download request of the user, specifically including:
[0017] For each user, the upload data amount recorded in each upload request corresponding to the user is queried, and the sum of all the upload data amounts is taken as the total upload data amount of the user;
[0018] For each user, the download data amount recorded in each download request corresponding to the user is queried, and the sum of all the download data amounts is taken as the total download data amount of the user;
[0019] The preset communication bandwidth is queried, the preset communication bandwidth includes upload bandwidth and download bandwidth, the ratio of the total upload data amount to the upload bandwidth is taken as the upload resource proportion of the user, and the ratio of the total download data amount to the download bandwidth is taken as the download resource proportion of the user.
[0020] In some embodiments, the calculating of the upload speed limit of each user according to the preset data writing speed and the upload resource proportion comprises:
[0021] taking the smaller value between the preset data writing speed and the upload bandwidth as a reference upload speed;
[0022] for each user, taking the product of the reference upload speed and the upload resource proportion as the corresponding upload speed limit of the user.
[0023] In some embodiments, the calculating of the download speed limit of each user according to the preset data reading speed and the download resource proportion comprises:
[0024] taking the smaller value between the preset data reading speed and the download bandwidth as a reference download speed;
[0025] for each user, taking the product of the reference download speed and the download resource proportion as the corresponding download speed limit of the user.
[0026] In some embodiments, the updating of the upload speed limit of each upload request and the download speed limit of each download request in real time according to the upload data volume, the download data volume, the upload speed limit and the download speed limit of each user comprises:
[0027] for each user, calculating the sum of the upload data volume of all upload requests of the user as a total upload data volume, calculating the first ratio of the upload data volume of each upload request of the user to the total upload data volume respectively, and calculating the product of each first ratio and the upload speed limit of the user as the upload speed limit of each upload request;
[0028] for each user, calculating the sum of the download data volume of all download requests of the user as a total download data volume, calculating the second ratio of the download data volume of each download request of the user to the total download data volume respectively, and calculating the product of each second ratio and the download speed limit of the user as the download speed limit of each download request.
[0029] In some embodiments, the method further comprises:
[0030] inquiring the total upload data volume and the total download data volume of each user every other preset sleep period;
[0031] for each user, when the total upload data volume is greater than or equal to the upload bandwidth, postponing the processing of all upload requests of the user for a preset sleep period;
[0032] When the total download data volume is greater than or equal to the download bandwidth, all download requests of the user are postponed for a preset sleep period for processing.
[0033] The embodiment of the present application further provides an upload and download speed limiting device, which comprises:
[0034] A classification unit is configured to classify the upload requests and the download requests received in real time in a preset update period respectively, to obtain the categories corresponding to each of the upload requests and the download requests, and to query the users corresponding to the upload requests of each category and the download requests of each category.
[0035] A first calculation unit is configured to calculate, for each user, the upload resource proportion of the user in the preset update period according to the upload data volume recorded in the upload requests of the user, and to calculate the download resource proportion of the user in the preset update period according to the download data volume recorded in the download requests of the user.
[0036] A second calculation unit is configured to calculate the upload speed limit of each user in the preset update period according to a preset data writing speed and the upload resource proportion.
[0037] A third calculation unit is configured to calculate the download speed limit of each user in the preset update period according to a preset data reading speed and the download resource proportion.
[0038] A real-time update unit is configured to query the upload data volume corresponding to each of the upload requests and the download data volume corresponding to each of the download requests in real time every other preset update period, and to update the upload speed limit of each of the upload requests and the download speed limit of each of the download requests in real time according to the upload data volume, the download data volume, the upload speed limit of each user and the download speed limit of each user.
[0039] The embodiment of the present application further provides an electronic device, which comprises:
[0040] A memory configured to store computer readable instructions; and
[0041] A processor configured to execute the computer readable instructions stored in the memory to implement the upload and download speed limiting method.
[0042] The embodiment of the present application further provides a computer readable storage medium, which stores computer readable instructions, and the computer readable instructions are executed by a processor in an electronic device to implement the upload and download speed limiting method.
[0043] The upload and download speed limiting method based on artificial intelligence classifies upload requests and download requests based on IP addresses and login tokens in the upload requests and the download requests, queries users corresponding to the upload requests and the download requests in each category, calculates upload resource proportions of each user according to upload data volumes, calculates download resource proportions of the user according to download data volumes, calculates upload speed limits of each user according to preset data writing speeds and the upload resource proportions, calculates download speed limits of each user according to preset data reading speeds and the download resource proportions, and reasonably allocates upload bandwidth and download bandwidth for each user by comprehensively considering resource proportions of each user. Finally, upload speed limits of each upload request and download speed limits of each download request are updated in real time based on the upload speed limits and the download speed limits of each user, so that the upload speed limit rules have timeliness and can be flexibly configured. BRIEF DESCRIPTION OF DRAWINGS
[0044] Figure 1 is a flowchart of a preferred embodiment of an upload and download speed limiting method related to the present application.
[0045] Figure 2 is a function module diagram of a preferred embodiment of an upload and download speed limiting device related to the present application.
[0046] Figure 3 is a structural schematic diagram of an electronic device of a preferred embodiment of an upload and download speed limiting method related to the present application. DETAILED DESCRIPTION
[0047] In order to more clearly understand the purpose, features and advantages of the present application, the present application is described in detail below in combination with the drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict. In the following description, a large number of specific details are set forth in order to fully understand the present application, and the described embodiments are only part of the embodiments of the present application, not all embodiments.
[0048] In addition, the terms "first", "second" are only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "a plurality of" is two or more, unless otherwise specifically limited.
[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0050] Embodiments of the present application provide a method for uploading and downloading speed limiting, which can be applied to one or more electronic devices. The electronic device is a device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored instructions. The hardware of the electronic device includes, but is not limited to, a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital signal processor (DSP), an embedded device, etc.
[0051] The electronic device can be any electronic product capable of human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive Internet Protocol Television (IPTV), a smart wearable device, etc.
[0052] The electronic device can also include a network device and / or a user device. The network device includes, but is not limited to, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing.
[0053] The network in which the electronic device is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.
[0054] As shown in FIG. 1, it is a flowchart of a preferred embodiment of the method for uploading and downloading speed limiting. The order of the steps in the flowchart can be changed according to different needs, and some steps can be omitted. Figure 1
[0055] S10, respectively classifying the real-time received uploading requests and downloading requests in a preset update period, obtaining the categories corresponding to each uploading request and downloading request, and querying the users corresponding to the uploading requests of each category and the downloading requests of each category.
[0056] In an optional embodiment, the respective classification of the real-time received upload requests and download requests in the preset update period is performed to obtain the corresponding category of each upload request and each download request, and specifically includes:
[0057] The IP address and login token of the upload request and the download request are parsed;
[0058] The upload requests with the same IP address and login token are classified into the same category, and the download requests with the same IP address and login token are classified into the same category;
[0059] For each category of upload request, the user name recorded in the login token is queried as the name of the category;
[0060] For each category of download request, the user name recorded in the login token is queried as the name of the category.
[0061] In the optional embodiment, the preset update period refers to the update period of the preset upload speed limit and download speed limit. For example, when the preset period is 1 minute, it means that the upload speed limit of each upload request and the download speed limit of each download request are updated every 1 minute.
[0062] In the optional embodiment, the upload request and the download request refer to the upload request and the download request from the user received by the server in real time in the preset update period. The upload request is used to inform the server which file directory the user wants to upload data to. The download request is used to inform the server which file directory the user wants to download data from.
[0063] In a possible implementation manner, the server can be a medical server in an application digital medical system, and the medical server is used to upload and download medical data, such as personal health records, prescriptions, examination reports and the like.
[0064] In the optional embodiment, the upload request and the download request both include an IP address and a login token. The IP address represents the IP address used by the user sending the request. The login token includes at least a user name and a user password, and the login token is used to represent the identity information of the user sending the request. For example, a user sends an upload request to the server through a device with an IP address of 192.168.0.1. The IP address corresponding to the upload request is 192.168.0.1. When the login token corresponding to the upload request is admin, admin, it indicates that the name of the user sending the upload request is admin, and the user password is also admin.
[0065] In the optional embodiment, the upload requests with the same IP address and login token are classified into the same category, and the download requests with the same IP address and login token are classified into the same category.
[0066] In the optional embodiment, for each category of upload request, the username recorded in the login token corresponding to the upload request of the category is queried as the name of the category, that is, the user corresponding to the upload request of the category; for each category of download request, the username recorded in the login token corresponding to the download request of the category is queried as the name of the category, that is, the user corresponding to the download request of the category.
[0067] In this way, the upload requests and the download requests are classified based on the IP addresses and the user information in the upload requests and the download requests, the user to which each upload request and download request belongs is identified, and data support is provided for subsequent upload and download speed limiting based on the user level.
[0068] S11, for each user, calculating the upload resource proportion of the user in the preset update period according to the upload data recorded in the upload request of the user, and calculating the download resource proportion of the user in the preset update period according to the download data recorded in the download request of the user.
[0069] In an optional embodiment, the calculation of the upload resource proportion of the user in the preset update period according to the upload data recorded in the upload request of the user, and the calculation of the download resource proportion of the user in the preset update period according to the download data recorded in the download request of the user, specifically includes:
[0070] For each user, querying the upload data recorded in each upload request corresponding to the user, and taking the sum of all the upload data as the total upload data of the user;
[0071] For each user, querying the download data recorded in each download request corresponding to the user, and taking the sum of all the download data as the total download data of the user;
[0072] Querying a preset communication bandwidth, the preset communication bandwidth including an upload bandwidth and a download bandwidth, taking the ratio of the total upload data to the upload bandwidth as the upload resource proportion of the user in the preset update period, and taking the ratio of the total download data to the download bandwidth as the download resource proportion of the user in the preset update period.
[0073] In the optional embodiment, the upload request is further used to record an upload data amount, i.e., the amount of data to be uploaded; and the download request is further used to record a download data amount, i.e., the amount of data to be downloaded. The unit of the upload data amount and the download data amount can be KB, MB, GB, etc., which are not limited in the present application.
[0074] For example, for a user of the digital medical system, when the user issues three upload requests of electronic medical records to the medical server, and the upload data amount recorded in each of the upload requests is 10 KB, 20 KB and 30 KB respectively, the total upload data amount corresponding to the user is 60 KB; and when the user issues two download requests of electronic medical records to the medical server, and the download data amount recorded in each of the download requests is 40 KB and 50 KB respectively, the total download data amount corresponding to the user is 90 KB.
[0075] In the optional embodiment, the communication bandwidth is used to represent the maximum value that can be theoretically reached in the process of data uploading and downloading. For example, when the communication mode is a 100M optical fiber, the upload bandwidth is 1.25 MB per second, and the download bandwidth is 12.5 MB per second.
[0076] For each of the users, the ratio of the total upload data amount to the upload bandwidth is taken as the upload resource proportion of the user in the preset update period, and the ratio of the total download data amount to the download bandwidth is taken as the download resource proportion of the user in the preset update period. For example, when the total upload data amount corresponding to a user is 60 KB, and the upload bandwidth is 1.25 MB per second, the upload resource proportion corresponding to the user in the preset update period is 0.0468.
[0077] The higher the upload resource proportion is, the higher the upload speed limit of the user needs to be improved; and the higher the download resource proportion is, the higher the download speed limit of the user needs to be improved.
[0078] In this way, the upload resource proportion and the download resource proportion of each user are calculated based on the upload data amount, the download data amount and the communication bandwidth of the user, which provides data support for subsequently setting the upload speed limit and the download speed limit of each user.
[0079] S12, calculating the upload speed limit of each of the users in the preset update period according to a preset data writing speed and the upload resource proportion.
[0080] In an optional embodiment, the calculation of the upload speed limit of each of the users in the preset update period according to the preset data writing speed and the upload resource proportion specifically includes:
[0081] a smaller value between the preset data writing speed and the upload bandwidth as a reference upload speed;
[0082] for each of the users, a product of the reference upload speed and the upload resource proportion as a corresponding upload limited speed of the user in the preset update period.
[0083] In the optional embodiment, the preset data writing speed refers to a data writing speed that a data storage device theoretically can reach when receiving upload data. For example, when the data storage device is a mechanical hard disk, the preset data writing speed can be 120 MB per second; when the data storage device is a solid state disk, the preset data writing speed can be 500 MB per second.
[0084] For example, when the preset data writing speed of the data storage device in the medical data server is 120 MB per second, and the upload bandwidth is 12.5 MB per second, the reference upload speed of the medical data server is 12.5 MB per second.
[0085] For example, when the upload resource proportion of a certain user is 0.0468, and the reference upload speed is 12.5 MB per second, the corresponding upload limited speed of the user in the preset update period is 0.585 MB per second.
[0086] In this way, the corresponding upload limited speed of each user is calculated based on the upload resource proportion and the preset data writing speed, the difference between the theoretical value and the actual value is comprehensively considered, so that the upload limited speed is reasonably set, and the stability of data transmission can be improved.
[0087] S13, calculating a download limited speed of each of the users in the preset update period according to a preset data reading speed and the download resource proportion.
[0088] In an optional embodiment, the calculating of the download limited speed of each of the users in the preset update period according to the preset data reading speed and the download resource proportion specifically includes:
[0089] a smaller value between the preset data reading speed and the download bandwidth as a reference download speed;
[0090] for each of the users, a product of the reference download speed and the download resource proportion as a corresponding download limited speed of the user in the preset update period.
[0091] In the optional embodiment, the preset data reading speed refers to a data reading speed that the data storage device theoretically can reach when storing downloaded data. For example, when the data storage device is a mechanical hard disk, the preset data reading speed can be 60 MB per second; when the data storage device is a solid state disk, the preset data reading speed can be 150 MB per second.
[0092] For example, when the preset data reading speed of the data storage device of the medical server is 60 MB per second, and the download bandwidth is 1.25 MB per second, the reference download speed of the medical server is 1.25 MB per second.
[0093] For example, when the download resource proportion of a certain user is 0.07, and the reference download speed is 1.25 MB per second, the download speed limit corresponding to the user in the preset update period is 0.0875 MB per second.
[0094] In this way, the download speed limit corresponding to each user is calculated based on the download resource proportion and the preset data reading speed, and the difference between the theoretical value and the actual value is comprehensively considered, so as to reasonably set the download speed limit and improve the stability of data transmission.
[0095] S14, every other preset update period, real-time query of the upload data amount corresponding to each upload request and the download data amount corresponding to each download request, real-time update of the upload speed limit of each upload request and the download speed limit of each download request according to the upload data amount, the download data amount, the upload speed limit and the download speed limit of each user.
[0096] In an optional embodiment, the real-time update of the upload speed limit of each upload request and the download speed limit of each download request according to the upload data amount, the download data amount, the upload speed limit and the download speed limit of each user, specifically includes:
[0097] For each user, the sum of the upload data amounts of all upload requests of the user is calculated as the total upload data amount, the first ratio of the upload data amount of each upload request corresponding to the user to the total upload data amount is calculated respectively, and the product of each first ratio and the upload speed limit corresponding to the user is calculated as the upload speed limit of each upload request.
[0098] For each user, the sum of the download data amounts of all download requests of the user is calculated as the total download data amount, the second ratio of the download data amount of each download request corresponding to the user to the total download data amount is calculated respectively, and the product of each second ratio and the download speed limit corresponding to the user is calculated as the download speed limit of each download request.
[0099] In the optional embodiment, every other preset update period, the upload data volume of each upload request and the download data volume of each download request are queried.
[0100] For example, if a user has three upload requests A, B and C, and the upload data volumes are 10 KB, 20 KB and 30 KB respectively, the total upload data volume of the user is 60 KB, the first ratio of upload request A is 0.17, the first ratio of upload request B is 0.33, and the first ratio of upload request C is 0.5. When the upload limit of the user is 0.585 MB per second, the upload limit of upload request A is 0.09945 MB per second, the upload limit of upload request B is 0.19305 MB per second, and the upload limit of upload request C is 0.2925 MB per second.
[0101] In an optional embodiment, the method further comprises:
[0102] Every other preset sleep period, the total upload data volume and the total download data volume of each user are queried;
[0103] For each user, when the total upload data volume is greater than or equal to the upload bandwidth, all upload requests of the user are delayed for a preset sleep period for processing;
[0104] For each user, when the total download data volume is greater than or equal to the download bandwidth, all download requests of the user are delayed for a preset sleep period for processing.
[0105] Preferably, the preset sleep period in the present scheme can be 1 second.
[0106] In this way, by querying the proportion of upload data volume and download data volume in each user in real time, the limit of each upload request and download request is updated in real time, and the limit speed rule can be flexibly set according to the actual operation condition, thereby improving the feasibility of upload and download limit speed.
[0107] The uploading and downloading speed limiting method based on artificial intelligence classifies uploading requests and downloading requests based on IP addresses and login tokens in the uploading requests and the downloading requests, queries users corresponding to uploading requests and downloading requests of each category, calculates uploading resource proportions of each user according to uploading data volumes, calculates downloading resource proportions of each user according to downloading data volumes, and then calculates uploading speed limits of each user according to preset data writing speeds and the uploading resource proportions and calculates downloading speed limits of each user according to preset data reading speeds and the downloading resource proportions, so that the resource proportions of each user are comprehensively considered, the uploading bandwidth and the downloading bandwidth of each user are reasonably allocated, and finally, uploading speed limits of each uploading request and downloading speed limits of each downloading request are updated in real time based on the uploading speed limits and the downloading speed limits of each user, so that the rules of the uploading speed limits have timeliness and can be flexibly configured. The method can be applied to uploading and downloading of various electronic archives of a digital medical system or scenes requiring a large amount of uploading and downloading data in a smart city.
[0108] As shown in Figure 2 Fig. 1 is a functional module diagram of a preferred embodiment of an uploading and downloading speed limiting device provided by the present application. The uploading and downloading speed limiting device 11 comprises a classification unit 110, a first calculation unit 111, a second calculation unit 112, a third calculation unit 113, and a real-time updating unit 114. The module / unit referred to in the present application refers to a series of computer program segments capable of being executed by a processor 13 and capable of completing a fixed function, which are stored in a memory 12. In the present embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0109] The classification unit 110 is configured to classify uploading requests and downloading requests received in real time within a preset update period respectively, obtain categories corresponding to each of the uploading requests and the downloading requests, and query users corresponding to uploading requests of each category and downloading requests of each category.
[0110] The first calculation unit 111 is configured to calculate, for each user, an uploading resource proportion of the user within the preset update period according to an uploading data volume recorded by an uploading request of the user, and calculate a downloading resource proportion of the user within the preset update period according to a downloading data volume recorded by a downloading request of the user.
[0111] The second calculation unit 112 is configured to calculate an uploading speed limit of each of the users within the preset update period according to a preset data writing speed and the uploading resource proportion.
[0112] The third calculation unit 113 is configured to calculate a downloading speed limit of each of the users within the preset update period according to a preset data reading speed and the downloading resource proportion.
[0113] The real-time updating unit 114 is configured to query the upload data volume corresponding to each upload request and the download data volume corresponding to each download request every other preset updating period, and update the upload speed limit of each upload request and the download speed limit of each download request in real time according to the upload data volume, the download data volume, the upload speed limit of each user and the download speed limit of each user.
[0114] In an optional embodiment, the classification unit 110 is specifically configured to:
[0115] parse the IP address and login token of the upload request and the download request;
[0116] group the upload requests with the same IP address and login token into the same category, and group the download requests with the same IP address and login token into the same category;
[0117] for each category of upload requests, query the user name recorded in the login token as the name of the category;
[0118] for each category of download requests, query the user name recorded in the login token as the name of the category.
[0119] In an optional embodiment, the first calculation unit 111 is specifically configured to:
[0120] for each user, query the upload data volume recorded in each upload request corresponding to the user, and take the sum of all the upload data volumes as the total upload data volume of the user;
[0121] for each user, query the download data volume recorded in each download request corresponding to the user, and take the sum of all the download data volumes as the total download data volume of the user;
[0122] query a preset communication bandwidth, the preset communication bandwidth including an upload bandwidth and a download bandwidth, take the ratio of the total upload data volume to the upload bandwidth as the upload resource proportion of the user, and take the ratio of the total download data volume to the download bandwidth as the download resource proportion of the user.
[0123] In an optional embodiment, the second calculation unit 112 is specifically configured to:
[0124] take the smaller value between a preset data writing speed and the upload bandwidth as a reference upload speed;
[0125] for each user, take the product of the reference upload speed and the upload resource proportion as the upload speed limit corresponding to the user.
[0126] In an optional embodiment, the third computing unit 113 is specifically used for:
[0127] The smaller value between the preset data reading speed and the download bandwidth is used as the benchmark download speed;
[0128] For each user, the product of the baseline download speed and the percentage of download resources is used as the download speed limit for that user.
[0129] In an optional embodiment, the real-time update unit 114 is specifically used for:
[0130] For each user, the sum of the uploaded data volume of all upload requests of the user is calculated as the total uploaded data volume. The first ratio of the uploaded data volume of each upload request of the user to the total uploaded data volume is calculated. The product of each first ratio and the upload speed limit of the user is calculated as the upload speed limit of each upload request.
[0131] For each user, the sum of the download data of all download requests of the user is calculated as the total download data. A second ratio of the download data of each download request of the user to the total download data is calculated. The product of each second ratio and the download speed limit of the user is calculated as the download speed limit of each download request.
[0132] In an optional embodiment, the real-time update unit 114 is further configured to:
[0133] At every preset sleep cycle, query the total uploaded data volume and total downloaded data volume of each user;
[0134] For each user, when the total amount of uploaded data is greater than or equal to the upload bandwidth, all upload requests of the user will be delayed for one preset sleep cycle.
[0135] For each user, when the total downloaded data volume is greater than or equal to the download bandwidth, all download requests of the user will be postponed for one preset sleep cycle.
[0136] like Figure 3 The diagram shown is a structural schematic of an electronic device provided in an embodiment of this application. The electronic device 1 includes a memory 12 and a processor 13. The memory 12 stores computer-readable instructions, and the processor 13 executes the computer-readable instructions stored in the memory to implement the upload / download rate limiting method of any of the above embodiments.
[0137] In an alternative embodiment, the electronic device 1 further comprises a bus, a computer program stored in the memory 12 and executable on the processor 13, such as an upload download speed limiting program.
[0138] Figure 3 Only the electronic device 1 with the memory 12 and the processor 13 is shown, and those skilled in the art can understand that, Figure 3 The structure shown does not constitute a limitation on the electronic device 1, and can include fewer or more components than shown, or combine certain components, or different component arrangements.
[0139] In combination Figure 1 The memory 12 in the electronic device 1 stores a plurality of computer readable instructions to implement an upload download speed limiting method, and the processor 13 can execute the plurality of instructions to implement:
[0140] Classify the real-time received upload requests and download requests in a preset update period respectively, obtain the category corresponding to each of the upload requests and the download requests, and query the user corresponding to each category of upload requests and each category of download requests;
[0141] For each user, calculate the upload resource proportion of the user in the preset update period according to the upload data amount recorded by the upload request of the user, and calculate the download resource proportion of the user in the preset update period according to the download data amount recorded by the download request of the user;
[0142] According to the preset data write speed and the upload resource proportion, calculate the upload speed limit of each of the users in the preset update period;
[0143] According to the preset data read speed and the download resource proportion, calculate the download speed limit of each of the users in the preset update period;
[0144] Every other preset update period, real-time query the upload data amount corresponding to each of the upload requests and the download data amount corresponding to each of the download requests, and real-time update the upload speed limit of each of the upload requests and the download speed limit of each of the download requests according to the upload data amount, the download data amount, the upload speed limit of each of the users and the download speed limit.
[0145] Specifically, the specific implementation method of the processor 13 on the above instructions can refer to Figure 1 The description of related steps in the corresponding embodiments will not be repeated here.
[0146] Those skilled in the art can understand that the schematic diagram is only an example of the electronic device 1, and does not constitute a limitation on the electronic device 1, which can be a bus type structure or a star type structure, and the electronic device 1 can further include more or less other hardware or software, or different component arrangements, for example, the electronic device 1 can further include an input / output device, a network access device, etc.
[0147] It should be noted that the electronic device 1 is only an example, and other existing or future electronic products can also be applicable to the present application and should be included in the protection scope of the present application.
[0148] The memory 12 includes at least one type of readable storage medium, which can be non-volatile or volatile. The readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. The memory 12 can be an internal storage unit of the electronic device 1 in some embodiments, for example, a mobile hard disk of the electronic device 1. The memory 12 can also be an external storage device of the electronic device 1 in other embodiments, for example, a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 1. Further, the memory 12 can include both the internal storage unit and the external storage device of the electronic device 1. The memory 12 can be used to store application software and various data installed in the electronic device 1, for example, the code of the upload / download speed limiting program, and can also be used to temporarily store data that has been output or will be output.
[0149] The processor 13 can be composed of an integrated circuit in some embodiments, for example, can be composed of a single packaged integrated circuit, or can be composed of multiple packaged integrated circuits with the same function or different functions, including one or more combinations of a central processing unit (CPU), a microprocessor, a digital processing chip, a graphics processor, and various control chips, etc. The processor 13 is the control unit of the electronic device 1, which connects all components of the electronic device 1 through various interfaces and lines, executes programs or modules stored in the memory 12 (for example, executes the upload / download speed limiting program, etc.), and calls data stored in the memory 12, to perform various functions of the electronic device 1 and process data.
[0150] The processor 13 executes the operating system of the electronic device 1 and various application programs installed. The processor 13 executes the application programs to implement the steps in the various embodiments of the upload and download speed limiting method described above, such as Figure 1 the steps shown.
[0151] For example, the computer program can be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules / units can be a series of computer-readable instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program can be divided into a classification unit 110, a first calculation unit 111, a second calculation unit 112, a third calculation unit 113, and a real-time updating unit 114.
[0152] The integrated units implemented in the form of software function modules described above can be stored in a computer-readable storage medium. The software function modules described above are stored in a storage medium, including a number of instructions for causing a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute part of the upload and download speed limiting method described in various embodiments of the present application.
[0153] The modules / units integrated in the electronic device 1, if implemented in the form of software function modules and sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above-mentioned embodiments can also be instructed by a computer program to complete related hardware devices, and the computer program can be stored in a computer-readable storage medium. The computer program can implement the steps of the various method embodiments when executed by a processor.
[0154] The computer program includes computer program code, which can be in the form of source code, object code, executable files, or some intermediate forms, etc. The computer-readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory, and other memories, etc.
[0155] Further, the computer-readable storage medium can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; and the data storage area can store data created according to the use of the blockchain node, etc.
[0156] The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus or the like. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one arrow is shown in Figure 3
[0157] The embodiment of the present application further provides a computer readable storage medium (not shown in the figure), which stores computer readable instructions. The computer readable instructions are executed by a processor in an electronic device to implement the upload and download speed limiting method in any of the above embodiments.
[0158] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The plurality of units or devices stated in the specification can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names and do not mean any particular order.
[0159] Finally, it should be pointed out that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit it. Although the present application has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical solutions of the present application can be modified or replaced equivalently without departing from the spirit and scope of the technical solutions of the present application.
Claims
1. A method for limiting upload and download speeds, characterized in that, The method includes: The upload and download requests received in real time within a preset update cycle are classified to obtain the category corresponding to each upload and download request, and the user corresponding to each category of upload and download requests is queried. For each user, the proportion of uploaded resources of the user in the preset update period is calculated based on the amount of uploaded data recorded in the user's upload request, and the proportion of downloaded resources of the user in the preset update period is calculated based on the amount of downloaded data recorded in the user's download request. The upload speed limit for each user within the preset update cycle is calculated based on the preset data writing speed and the proportion of uploaded resources. The download speed limit for each user within the preset update cycle is calculated based on the preset data reading speed and the proportion of downloaded resources. Every preset update cycle, the upload data volume corresponding to each upload request and the download data volume corresponding to each download request are queried in real time. Based on the upload data volume, download data volume, upload speed limit and download speed limit of each user, the upload speed limit and download speed limit of each upload request are updated in real time.
2. The upload / download speed limiting method as described in claim 1, characterized in that, The step of classifying the real-time received upload and download requests to obtain the category corresponding to each upload and download request specifically includes: Parse the IP address and login token of the upload request and the download request; Upload requests with the same IP address and login token are grouped into the same category, and download requests with the same IP address and login token are grouped into the same category; For each category of upload request, the username recorded in the login token is queried to serve as the name of that category; For each category of download request, the username recorded in the login token is queried to serve as the name of that category.
3. The upload / download speed limiting method as described in claim 1, characterized in that, The calculation of the user's upload resource ratio based on the upload data volume recorded in the user's upload request, and the calculation of the user's download resource ratio based on the download data volume recorded in the user's download request, specifically include: For each user, query the amount of uploaded data recorded in each upload request corresponding to the user, and sum all the uploaded data amounts as the total amount of uploaded data for the user; For each user, query the amount of download data recorded in each download request corresponding to the user, and sum all the download data amounts as the total download data amount for the user; The preset communication bandwidth is queried. The preset communication bandwidth includes upload bandwidth and download bandwidth. The ratio of the total uploaded data volume to the upload bandwidth is taken as the user's upload resource ratio, and the ratio of the total downloaded data volume to the download bandwidth is taken as the user's download resource ratio.
4. The upload / download speed limiting method as described in claim 3, characterized in that, The calculation of the upload speed limit for each user based on the preset data writing speed and the upload resource ratio specifically includes: The smaller value between the preset data writing speed and the upload bandwidth is used as the benchmark upload speed; For each user, the product of the baseline upload speed and the proportion of uploaded resources is used as the upload speed limit for that user.
5. The upload / download speed limiting method as described in claim 3, characterized in that, The step of calculating the download speed limit for each user based on the preset data reading speed and the proportion of downloaded resources specifically includes: The smaller value between the preset data reading speed and the download bandwidth is used as the benchmark download speed; For each user, the product of the baseline download speed and the percentage of download resources is used as the download speed limit for that user.
6. The upload / download speed limiting method as described in claim 1, characterized in that, The step of updating the upload speed limit for each upload request and the download speed limit for each download request in real time based on the uploaded data volume, the downloaded data volume, and the upload and download speed limits for each user specifically includes: For each user, the sum of the uploaded data volume of all upload requests of the user is calculated as the total uploaded data volume. The first ratio of the uploaded data volume of each upload request of the user to the total uploaded data volume is calculated. The product of each first ratio and the upload speed limit of the user is calculated as the upload speed limit of each upload request. For each user, the sum of the download data of all download requests of the user is calculated as the total download data. A second ratio of the download data of each download request of the user to the total download data is calculated. The product of each second ratio and the download speed limit of the user is calculated as the download speed limit of each download request.
7. The upload / download speed limiting method as described in claim 3, characterized in that, The method further includes: At every preset sleep cycle, query the total uploaded data volume and total downloaded data volume of each user; For each user, when the total amount of uploaded data is greater than or equal to the upload bandwidth, all upload requests of the user will be delayed for one preset sleep cycle. For each user, when the total downloaded data volume is greater than or equal to the download bandwidth, all download requests of the user will be postponed for one preset sleep cycle.
8. An upload / download speed limiting device, characterized in that, The device includes: The classification unit is used to classify the upload requests and download requests received in real time within a preset update cycle, obtain the category corresponding to each upload request and download request, and query the user corresponding to each category of upload requests and download requests. The first calculation unit is used to calculate the proportion of uploaded resources of each user in the preset update cycle based on the amount of uploaded data recorded in the user's upload request, and to calculate the proportion of downloaded resources of each user in the preset update cycle based on the amount of downloaded data recorded in the user's download request. The second calculation unit is used to calculate the upload speed limit for each user within the preset update cycle based on the preset data writing speed and the upload resource ratio. The third calculation unit is used to calculate the download speed limit for each user within the preset update cycle based on the preset data reading speed and the download resource ratio. The real-time update unit is used to query the amount of uploaded data corresponding to each upload request and the amount of downloaded data corresponding to each download request in real time every preset update cycle, and update the upload speed limit of each upload request and the download speed limit of each download request in real time according to the amount of uploaded data, the amount of downloaded data, the upload speed limit and the download speed limit of each user.
9. An electronic device, characterized in that, The electronic device includes: Memory, which stores computer-readable instructions; and The processor executes computer-readable instructions stored in the memory to implement the upload / download rate limiting method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which are executed by a processor in an electronic device to implement the upload / download speed limiting method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Systems and methods for performing data replication in distributed cluster environments
US10264064B1
Data processing method for controlling write speed of memory device to avoid significant write delay and data storage device utilizing the same
US20220035736A1