A method for realizing primary and backup of an OCR service
By dynamically adjusting the number of machines in a local OCR service master-slave architecture, combined with QPS exceeding rules and rate limiting thresholds, the problems of high cost and low efficiency of public cloud OCR services are solved, achieving cost-effective OCR service management.
Patent Information
- Application Number
- CN202310391975.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-13
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-04-13
AI Technical Summary
In existing technologies, the cost of using public cloud OCR services is high and the QPS is limited, which leads to increased information collection costs and limited efficiency.
The architecture primarily uses local OCR services, supplemented by public cloud OCR services. By defining QPS exceedance rules and rate limiting thresholds, the number of local OCR service machines is dynamically adjusted to reduce calls to public cloud services.
This effectively reduces the frequency of use of public cloud OCR services, lowers the cost of OCR text recognition, and ensures high availability and user experience of OCR services.
Smart Images

Figure CN116311258B_ABST
Abstract
Description
Technical Field
[0001] This invention discloses a method relating to the field of text recognition technology, specifically a method for implementing primary and backup OCR services. Background Technology
[0002] For large-scale information collection, stable public cloud OCR services provided by third-party vendors are generally used. However, public cloud OCR services are charged based on the number of calls, which increases the cost of OCR text recognition. In addition, there are limitations on QPS, which is not conducive to information collection. Summary of the Invention
[0003] This invention addresses the problems of existing technologies by providing a method for implementing primary and backup OCR services. The aim is to rationally utilize local OCR services, making local OCR services the primary service and public cloud OCR services the secondary service, while using public cloud OCR services as a backup, thereby minimizing the use of public cloud OCR services.
[0004] The specific solution proposed in this invention is as follows:
[0005] This invention provides a method for implementing primary and backup OCR services. It defines the local OCR service of a cluster node as a local OCR service resource, defines corresponding QPS (Queries Per Second) exceeding rules based on the local OCR service resource, and sets a single-machine rate limiting threshold based on the QPS exceeding rules.
[0006] Set a node in the cluster as a server, use the server to count the total OCR service resource calls in the cluster, set a cluster rate limiting threshold, and communicate with other nodes.
[0007] Assess the hardware and network configuration of the local OCR service machines on each node, and adjust the number of local OCR service machines on each node by combining the cluster rate limiting threshold and single machine rate limiting threshold with the total OCR service resource call volume of the cluster, thereby reducing the call to public cloud OCR services.
[0008] Furthermore, the method for implementing primary and backup OCR services, which involves defining corresponding QPS exceeding rules based on local OCR service resources, includes:
[0009] Define a QPS exceedance rule, which sets a single-machine rate limiting threshold. If the single-machine traffic exceeds the single-machine rate limiting threshold, the public cloud OCR service is invoked.
[0010] Furthermore, the method for implementing primary and backup OCR services, which involves determining the basic hardware and network environment configuration of the local OCR service machine on each node, includes:
[0011] If the judgment result is that the basic hardware and network environment configurations of each OCR service machine are basically the same, then according to the formula:
[0012] Number of local OCR service machines = Cluster rate limiting threshold / Single machine rate limiting threshold
[0013] Adjust the number of local OCR service machines based on the total OCR service resource usage of the cluster.
[0014] Furthermore, the method for implementing primary and backup OCR services, which involves determining the basic hardware and network environment configuration of the local OCR service machine on each node, includes:
[0015] If the determination result is that the basic hardware and network environment configurations of each OCR service machine cannot be basically the same, then stress testing is performed, and a single-machine rate limiting threshold is configured for each local OCR service machine. The cluster rate limiting threshold is set as follows: the single-machine rate limiting threshold of local OCR service machine 1 + the single-machine rate limiting threshold of local OCR service machine 2 + ... + the single-machine rate limiting threshold of local OCR service machine n.
[0016] The number of local OCR service machines is adjusted based on the cluster rate limiting threshold and the single-machine rate limiting threshold of each local OCR service machine, combined with the total OCR service resource call volume of the cluster.
[0017] Furthermore, in the method for implementing primary and backup OCR services, the server uses the Sentinl component to count the total OCR service resource call volume of the cluster, and uses the Sentinl component to monitor the local OCR service resource call volume, dynamically adjusting the QPS exceeding the rules.
[0018] The present invention also provides an apparatus for implementing primary and backup OCR services, including a configuration module, an adjustment module, and a judgment module.
[0019] The configuration module defines the local OCR service of the cluster nodes as local OCR service resources, defines corresponding QPS exceeding rules based on the local OCR service resources, and sets single-machine rate limiting thresholds based on the QPS exceeding rules.
[0020] The adjustment module sets a node in the cluster as a server, uses the server to count the total OCR service resource calls in the cluster, sets the cluster rate limiting threshold, and communicates with other nodes.
[0021] The judgment module assesses the basic configuration of the hardware and network environment of the local OCR service machines on each node, and the adjustment module adjusts the number of local OCR service machines on each node by combining the cluster rate limiting threshold and the single machine rate limiting threshold with the total OCR service resource call volume of the cluster, thereby reducing the call to public cloud OCR services.
[0022] Furthermore, in the aforementioned device for implementing primary and backup OCR services, the configuration module defines corresponding QPS exceeding rules based on local OCR service resources, including:
[0023] Define a QPS exceedance rule, which sets a single-machine rate limiting threshold. If the single-machine traffic exceeds the single-machine rate limiting threshold, the public cloud OCR service is invoked.
[0024] Furthermore, in the aforementioned device for implementing primary and backup OCR services, the judgment module judges the basic configuration of the hardware and network environment of the local OCR service machine at each node, including:
[0025] If the judgment result is that the basic hardware and network environment configurations of each OCR service machine are basically the same, then the adjustment module is based on the formula:
[0026] Number of local OCR service machines = Cluster rate limiting threshold / Single machine rate limiting threshold
[0027] Adjust the number of local OCR service machines based on the total OCR service resource usage of the cluster.
[0028] Furthermore, in the aforementioned device for implementing primary and backup OCR services, the judgment module judges the basic configuration of the hardware and network environment of the local OCR service machine at each node, including:
[0029] If the assessment result indicates that the basic hardware and network environment configurations of each OCR service machine are not sufficiently identical, then the module is adjusted and stress tests are conducted. A single-machine rate limiting threshold is configured for each local OCR service machine, and the cluster rate limiting threshold is set as follows: Cluster rate limiting threshold = Single-machine rate limiting threshold of local OCR service machine 1 + Single-machine rate limiting threshold of local OCR service machine 2 + ... + Single-machine rate limiting threshold of local OCR service machine n.
[0030] The number of local OCR service machines is adjusted based on the cluster rate limiting threshold and the single-machine rate limiting threshold of each local OCR service machine, combined with the total OCR service resource call volume of the cluster.
[0031] Furthermore, in the aforementioned device for implementing primary and backup OCR services, the adjustment module uses the Sentinl component on the server to count the total OCR service resource call volume of the cluster, and uses the Sentinl component to monitor the local OCR service resource call volume, dynamically adjusting the QPS exceeding the rules.
[0032] The advantages of this invention are:
[0033] This invention provides a method for implementing primary and backup OCR services, dynamically and rationally utilizing local OCR services, prioritizing local OCR services, minimizing the use of public cloud OCR services, reducing OCR text recognition costs, and ensuring the normal operation of OCR services. Attached Figure Description
[0034] Figure 1 This is a schematic diagram of the method flow of the present invention. Detailed Implementation
[0035] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.
[0036] This invention provides a method for implementing primary and backup OCR services. It defines the local OCR service of a cluster node as a local OCR service resource, defines corresponding QPS (Queries Per Second) exceeding rules based on the local OCR service resource, and sets a single-machine rate limiting threshold based on the QPS exceeding rules.
[0037] Set a node in the cluster as a server, use the server to count the total OCR service resource calls in the cluster, set a cluster rate limiting threshold, and communicate with other nodes.
[0038] Assess the hardware and network configuration of the local OCR service machines on each node, and adjust the number of local OCR service machines on each node by combining the cluster rate limiting threshold and single machine rate limiting threshold with the total OCR service resource call volume of the cluster, thereby reducing the call to public cloud OCR services.
[0039] This invention achieves a system that primarily uses local OCR services and secondarily uses public cloud OCR services, ensuring high service availability while reducing the number of calls to public cloud OCR services.
[0040] In specific applications, in some embodiments of the method of the present invention, the implementation process based on the technical solution of the present invention can be referred to as follows:
[0041] Step 1: Define the local OCR service of the cluster nodes as the local OCR service resource, and define corresponding QPS exceedance rules based on the local OCR service resource. Set a single-machine rate limiting threshold based on the QPS exceedance rules. The resource that calls the local OCR service can provide optional exception handling and fallback configurations, so that when the local OCR service exceeds the specified QPS exceedance rules, the public cloud OCR service is called, without the user's awareness.
[0042] Furthermore, the definition of corresponding QPS exceeding rules based on local OCR service resources includes:
[0043] Define a QPS exceedance rule, which sets a single-machine rate limiting threshold. If the traffic to a single machine exceeds the single-machine rate limiting threshold, the public cloud OCR service will be invoked. For example, the QPS exceedance rule can be set to limit QPS to 100. If this limit is exceeded, the public cloud OCR service will be automatically invoked to avoid affecting the user experience.
[0044] Step 2: Set a node in the cluster as a server. The server will then be used to track the total OCR service resource usage across the cluster, set a rate-limiting threshold, and communicate with other nodes. Furthermore, the server can utilize the Sentinel component to track the total OCR service resource usage across the cluster.
[0045] Step 3: Determine the basic configuration of the hardware and network environment of the local OCR service machines on each node, and adjust the number of local OCR service machines on each node by combining the cluster rate limiting threshold and the single machine rate limiting threshold with the total OCR service resource call volume of the cluster, so as to reduce the call to public cloud OCR services.
[0046] Furthermore, determining the basic configuration of the hardware and network environment of the local OCR service machine at each node may include:
[0047] If the judgment result is that the basic hardware and network environment configurations of each OCR service machine are basically the same, then according to the formula:
[0048] Number of local OCR service machines = Cluster rate limiting threshold / Single machine rate limiting threshold
[0049] Adjust the number of local OCR service machines based on the total OCR service resource usage of the cluster.
[0050] Alternatively, it may include:
[0051] If the determination result is that the basic hardware and network environment configurations of each OCR service machine cannot be basically the same, then stress testing is performed, and a single-machine rate limiting threshold is configured for each local OCR service machine. The cluster rate limiting threshold is set as follows: the single-machine rate limiting threshold of local OCR service machine 1 + the single-machine rate limiting threshold of local OCR service machine 2 + ... + the single-machine rate limiting threshold of local OCR service machine n.
[0052] The number of local OCR service machines is adjusted based on the cluster rate limiting threshold and the single-machine rate limiting threshold of each local OCR service machine, combined with the total OCR service resource call volume of the cluster.
[0053] For example, if there are 10 machines in the cluster, and each machine is set with a single-machine rate limit of 10 QPS, the ideal rate limit for the entire cluster would be 100 QPS. However, if it is determined that there are significant differences in the hardware and network environment of the OCR service, the traffic to each machine may be uneven. This could cause some machines to start rate limiting even if the total traffic is not reached. Therefore, it is necessary to adjust the number of local OCR service machines based on the total call volume of the cluster and the single-machine rate limit as a safety net, in order to avoid excessive traffic being sent to the public cloud OCR service.
[0054] Furthermore, the Sentinl component can be used to monitor the resource usage of the local OCR service and dynamically adjust the QPS exceeding the rules. When the local OCR service traffic is too high, the number of machines required for the local OCR service can be calculated based on the traffic monitored by the Sentinl component and the traffic threshold for each machine, and then the number of local OCR services can be adjusted.
[0055] The present invention also provides an apparatus for implementing primary and backup OCR services, including a configuration module, an adjustment module, and a judgment module.
[0056] The configuration module defines the local OCR service of the cluster nodes as local OCR service resources, defines corresponding QPS exceeding rules based on the local OCR service resources, and sets single-machine rate limiting thresholds based on the QPS exceeding rules.
[0057] The adjustment module sets a node in the cluster as a server, uses the server to count the total OCR service resource calls in the cluster, sets the cluster rate limiting threshold, and communicates with other nodes.
[0058] The judgment module assesses the basic configuration of the hardware and network environment of the local OCR service machines on each node, and the adjustment module adjusts the number of local OCR service machines on each node by combining the cluster rate limiting threshold and the single machine rate limiting threshold with the total OCR service resource call volume of the cluster, thereby reducing the call to public cloud OCR services.
[0059] The information interaction and execution process between the modules in the above-mentioned device are based on the same concept as the method embodiment of the present invention, and the specific details can be found in the description of the method embodiment of the present invention, and will not be repeated here.
[0060] Similarly, the device of the present invention dynamically and rationally uses local OCR services, prioritizing local OCR services and minimizing the use of public cloud OCR services to reduce the cost of OCR text recognition while ensuring the normal use of OCR services.
[0061] It should be noted that not all steps and modules in the above processes and device structures are mandatory; some steps or modules can be omitted as needed. The execution order of each step is not fixed and can be adjusted as required. The system structure described in the above embodiments can be a physical structure or a logical structure. That is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or they may be jointly implemented by certain components in multiple independent devices.
[0062] The above-described embodiments are merely preferred embodiments provided to fully illustrate the present invention, and the scope of protection of the present invention is not limited thereto. Equivalent substitutions or modifications made by those skilled in the art based on the present invention are all within the scope of protection of the present invention. The scope of protection of the present invention is defined by the claims.
Claims
1. A method for implementing primary and backup OCR services, characterized by defining... The local OCR service on each cluster node is a local OCR service resource. When calling resources from the local OCR service, optional exception handling and fallback configurations are provided. This allows the public cloud OCR service to be invoked when the local OCR service exceeds a specified QPS rule, without the user being aware of the error. The system defines corresponding QPS (Queries Per Second) limits based on local OCR service resources. This includes defining QPS limits, setting a single-machine rate-limiting threshold for each rule, and calling the public cloud OCR service if the single-machine traffic exceeds the threshold. Set a single-machine rate limiting threshold based on QPS exceeding the rules. Set a node in the cluster as a server, use the server to count the total OCR service resource calls in the cluster, set a cluster rate limiting threshold, and communicate with other nodes. Determine the basic hardware and network configuration of each node's local OCR service machine, including: if the determination result is that the basic hardware and network configuration of each OCR service machine is basically the same, then according to the formula: Number of local OCR service machines = Cluster rate limiting threshold / Single machine rate limiting threshold Adjust the number of local OCR service machines based on the total OCR service resource usage of the cluster; If the determination result is that the basic hardware and network environment configurations of each OCR service machine cannot be basically the same, then stress testing is performed, and a single-machine rate limiting threshold is configured for each local OCR service machine. The cluster rate limiting threshold is set as follows: the single-machine rate limiting threshold of local OCR service machine 1 + the single-machine rate limiting threshold of local OCR service machine 2 + ... the single-machine rate limiting threshold of local OCR service machine n. The number of local OCR service machines is adjusted based on the cluster rate limiting threshold and the single-machine rate limiting threshold of each local OCR service machine, combined with the total OCR service resource call volume of the cluster. By combining cluster rate limiting thresholds and single-machine rate limiting thresholds with the total OCR service resource call volume of the cluster, the number of local OCR service machines on each node is adjusted to reduce calls to public cloud OCR services. Specifically, the Sentinl component is used on the server side to count the total OCR service resource call volume of the cluster and to monitor the local OCR service resource call volume, dynamically adjusting the QPS exceeding the rules.
2. A device for implementing primary and backup OCR services, characterized in that: It includes a configuration module, an adjustment module, and a judgment module. The configuration module defines the local OCR service of the cluster nodes as local OCR service resources. It calls these local OCR service resources and provides optional exception handling and fallback configurations. This allows the local OCR service to call the public cloud OCR service when it exceeds a specified QPS rule, without the user being aware of the error. The system defines corresponding QPS (Queries Per Second) limits based on local OCR service resources. This includes defining QPS limits, setting a single-machine rate-limiting threshold for each rule, and calling the public cloud OCR service if the single-machine traffic exceeds the threshold. The configuration module sets a single-machine rate limiting threshold based on the QPS exceeding the rules. The adjustment module sets a node in the cluster as a server, uses the server to count the total OCR service resource calls in the cluster, sets the cluster rate limiting threshold, and communicates with other nodes. The judgment module assesses the basic hardware and network configuration of each node's local OCR service machine. If the judgment result indicates that the basic hardware and network configurations of each OCR service machine are essentially the same, then according to the formula: Number of local OCR service machines = Cluster rate limiting threshold / Single machine rate limiting threshold Adjust the number of local OCR service machines based on the total OCR service resource usage of the cluster; If the determination result is that the basic hardware and network environment configurations of each OCR service machine cannot be basically the same, then stress testing is performed, and a single-machine rate limiting threshold is configured for each local OCR service machine. The cluster rate limiting threshold is set as follows: the single-machine rate limiting threshold of local OCR service machine 1 + the single-machine rate limiting threshold of local OCR service machine 2 + ... the single-machine rate limiting threshold of local OCR service machine n. The number of local OCR service machines is adjusted based on the cluster rate limiting threshold and the single-machine rate limiting threshold of each local OCR service machine, combined with the total OCR service resource call volume of the cluster. The adjustment module uses cluster rate limiting thresholds and single-machine rate limiting thresholds combined with the total OCR service resource call volume of the cluster to adjust the number of local OCR service machines on each node, reducing the call volume to public cloud OCR services. Specifically, the server uses the Sentinl component to count the total OCR service resource call volume of the cluster and monitors the local OCR service resource call volume, dynamically adjusting the QPS exceeding the rules.
Citation Information
Patent Citations
Mobile user terminal task unloading method under distributed edge computing service system
CN111262906A
Flow control method and device
CN115174479A
Cluster current limiting method and device, equipment and medium
CN115242718A
