Service data source switching method and device, electronic equipment and storage medium

By automatically detecting and judging the data source status and dynamically switching data sources, the problem of enterprises needing to frequently manually switch data sources in data processing and analysis is solved, and the high availability and user experience of the system are improved.

CN120029682APending Publication Date: 2025-05-23CHINA TELECOM ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411944479.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

Enterprises need to frequently switch data sources in data processing and analysis. The existing technology requires administrators to manually configure, which is time-consuming and labor-intensive, and it is difficult to automatically deal with complex and changeable data processing needs.

Method used

Provide a switching method for service data sources. By detecting the status of the target service and the data source, it automatically determines whether there is a data source switching requirement, and dynamically configures the target service to query data from another data source.

Benefits of technology

It improves the high availability and performance of business systems, simplifies operation and maintenance and management, improves user experience, and can effectively respond to complex and changeable data processing and analysis needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029682A_ABST
    Figure CN120029682A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a service data source switching method and device, electronic equipment and a storage medium, and the method comprises the steps: detecting a first service data source and / or a target service when the target service is configured to query data from the first service data source; based on the detection result of the first service data source and / or the target service, judging whether the target service has a data source switching demand or not; and when it is judged that the target service has the data source switching requirement, configuring the target service to query data from the second service data source. Through the embodiment of the invention, the high availability of the service system can be improved, the performance can be optimized, the operation, maintenance and management can be simplified, the user experience can be improved, and the service system can effectively cope with complex and changeable data processing and analysis requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a method for switching a service data source, a device for switching a service data source, an electronic device and a computer-readable storage medium. Background Art

[0002] With the development of big data technology, enterprises' needs for data processing and analysis are becoming more diverse and complex.

[0003] In actual applications, an enterprise can set up multiple data sources for a business. When a data source needs to be used, the enterprise administrator can perform configuration management to configure the business to query data from the data source. When another data source needs to be used, the enterprise administrator can perform configuration management again to configure the business to query data from the other data source. Although this configuration method allows the business to query data from different data sources, it requires the enterprise administrator to perform configuration management operations, which is time-consuming and labor-intensive. Summary of the invention

[0004] In view of the above problems, a method for switching a service data source, a device for switching a service data source, an electronic device and a computer-readable storage medium are proposed to overcome the above problems or at least partially solve the above problems, including:

[0005] A method for switching a service data source, wherein the service data source of a target service includes at least a first service data source and a second service data source, and the method includes:

[0006] When the target service is configured to query data from the first service data source, detecting the first service data source and / or the target service;

[0007] Based on the detection result of the first service data source and / or the target service, determining whether the target service has a data source switching demand;

[0008] When it is determined that the target service has a need to switch the data source, the target service is configured to query data from the second service data source.

[0009] Optionally, the method further comprises:

[0010] When the target service is configured to query data from the first service data source, upon receiving a switching instruction input by a user, the target service is configured to query data from the second service data source.

[0011] Optionally, the method further comprises:

[0012] When the target service is configured to query data from the first service data source, when the first service data source is modified, the second service data source is synchronized based on the modification to the first service data source.

[0013] Optionally, when synchronizing the second service data source based on the modification of the first service data source, the method further includes:

[0014] Based on the modification of the first service data source, the preset cache is synchronized.

[0015] Optionally, after configuring the target service to query data from the second service data source, the method further includes:

[0016] When an exception occurs in the second service data source, the target service is configured to query data from the first service data source.

[0017] Optionally, the method further comprises:

[0018] Recording the configuration of the data source query of the target service;

[0019] And / or, the switching operation of the data source is recorded.

[0020] Optionally, the first service data source and the second service data source share a target connection pool;

[0021] Alternatively, the first service data source corresponds to a first connection pool, and the second service data source corresponds to a second connection pool; when the target service is configured to query data from the first service data source, the target service is configured to connect to the first service data source based on the first connection pool; when the target service is configured to query data from the second service data source, the target service is configured to connect to the second service data source based on the second connection pool.

[0022] An embodiment of the present invention further provides a device for switching a service data source, the device comprising:

[0023] a detection module, configured to detect the first service data source and / or the target service when the target service is configured to query data from the first service data source;

[0024] A judgment module, configured to judge whether the target service has a data source switching requirement based on the detection result of the first service data source and / or the target service;

[0025] The switching module is used to configure the target service to query data from the second service data source when it is determined that the target service has a need to switch the data source.

[0026] Optionally, the switching module is further configured to configure the target service to query data from the second service data source when a switching instruction input by a user is received when the target service is configured to query data from the first service data source.

[0027] Optionally, the switching module is further used to synchronize the second service data source based on the modification of the first service data source when the target service is configured to query data from the first service data source and the first service data source is modified.

[0028] Optionally, the device further comprises

[0029] The cache synchronization module is used to synchronize the preset cache based on the modification of the first service data source when synchronizing the second service data source based on the modification of the first service data source.

[0030] Optionally, the switching module is further used to configure the target service to query data from the first service data source after configuring the target service to query data from the second service data source, when an exception occurs in the second service data source.

[0031] Optionally, the device further comprises:

[0032] The recording module is used to record the configuration of the data source query of the target service; and / or to record the switching operation of the data source.

[0033] Optionally, the first service data source and the second service data source share a target connection pool;

[0034] Alternatively, the first service data source corresponds to a first connection pool, and the second service data source corresponds to a second connection pool; when the target service is configured to query data from the first service data source, the target service is configured to connect to the first service data source based on the first connection pool; when the target service is configured to query data from the second service data source, the target service is configured to connect to the second service data source based on the second connection pool.

[0035] An embodiment of the present invention further provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the above-mentioned method for switching a service data source when executed by the processor.

[0036] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method for switching a service data source as described above is implemented.

[0037] The embodiments of the present invention have the following advantages:

[0038] In an embodiment of the present invention, when the target service is configured to query data from a first service data source, the first service data source and / or the target service are detected; based on the detection results of the first service data source and / or the target service, it is determined whether the target service has a need to switch the data source; when it is determined that the target service has a need to switch the data source, the target service is configured to query data from a second service data source. Through the embodiment of the present invention, the high availability of the business system can be improved, the performance can be optimized, the operation and maintenance and management can be simplified, the user experience can be improved, and the business system can effectively respond to complex and changeable data processing and analysis needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0040] Figure 1 is a flow chart of steps of a method for switching a service data source according to an embodiment of the present invention;

[0041] Figure 2 is a flowchart of another method for switching a service data source according to an embodiment of the present invention;

[0042] Figure 3 is a flowchart of steps of another method for switching a service data source according to an embodiment of the present invention;

[0043] Figure 4 is a schematic diagram of checking and modifying an embodiment of the present invention;

[0044] Figure 5 is a schematic diagram of manual switching in an embodiment of the present invention;

[0045] Figure 6 is a schematic diagram of an automatic switching according to an embodiment of the present invention;

[0046] Figure 7 It is a structural schematic diagram of a switching device for a service data source according to an embodiment of the present invention. DETAILED DESCRIPTION

[0047] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] In order to improve the high availability of business systems, optimize performance, simplify operation and maintenance, and improve user experience, and to enable business systems to effectively respond to complex and changeable data processing and analysis needs, an embodiment of the present invention provides a method for switching service data sources, which can automatically detect whether there is a need to automatically switch data sources; if there is a need to switch data sources, the data source of the business is automatically switched, thereby eliminating the need for enterprise managers to perform switching operations, saving manpower and improving efficiency.

[0049] For details, please refer to Figure 1 , shows a step flow chart of a method for switching a service data source according to an embodiment of the present invention.

[0050] like Figure 1 As shown, the method for switching the service data source may include the following steps:

[0051] Step 101: When a target service is configured to query data from a first service data source, the first service data source and / or the target service is detected.

[0052] In the embodiment of the present invention, multiple service data sources may be configured for the target service; illustratively, at least a first service data source and a second service data source may be configured for the target service.

[0053] The first service data source and the second service data source may be different data sources; for example, the first service data source may be clickhouse, and the second service data source may be doris.

[0054] ClickHouse is a high-performance, open source columnar data source management system developed by Yandex and designed for online analytical processing (OLAP). It achieves excellent query speed through columnar storage and vectorized execution, and is suitable for processing large-scale data sets. ClickHouse supports real-time data writing and querying, and uses a variety of compression algorithms to achieve high compression ratios, significantly reducing storage costs. Its distributed architecture allows data sharding and replication, enhancing processing capabilities and reliability. It supports most SQL (Structured Query Language) syntax, allowing users to easily perform complex queries. ClickHouse is widely used in log analysis, time series data processing, business intelligence, and monitoring.

[0055] Doris is a high-performance, real-time analytical data source based on the MPP architecture. It is well-known for its high efficiency, simplicity, and uniformity. It can return query results under massive data in sub-second response time. It can not only support high-concurrency point query scenarios, but also support high-throughput complex analysis scenarios. Based on this, Apache Doris can better meet the use scenarios such as report analysis, ad hoc query, unified data warehouse construction, data lake federated query acceleration, etc. Users can build large-screen dashboards, user behavior analysis, AB experimental platforms, log retrieval analysis, user portrait analysis, order analysis and other applications on it.

[0056] In actual applications, the target service may be pre-configured to query data from the first service data source. When the target service is configured to query data from the first service data source, the performance of the first service data source may be tested, and the requirements of the target service for the data source may also be tested; based on the test, corresponding test results may be generated.

[0057] Step 102: Based on the detection result of the first service data source and / or the target service, determine whether the target service has a data source switching demand.

[0058] After detecting the first service data source and / or the target service and generating corresponding detection results, it can be determined whether the target service has a need to switch data sources based on the detection results generated after detecting the first service data source and / or the target service, that is, whether the configuration for the target service needs to be changed from querying data from the first service data source to querying data from the second service data source.

[0059] Step 103: When it is determined that the target service has a need to switch the data source, configure the target service to query data from the second service data source.

[0060] In actual applications, based on the detection results, if it is determined that the target service has different data query requirements, or there are performance problems with the first service data source, or there is an abnormality in the first service data source, it can be determined that the target service has a need to switch the data source.

[0061] When it is determined that the target service has a need to switch the data source, the configuration of the target service may be modified to configure the target service to query data from the second service data source.

[0062] When the target service is configured to query data from the second service data source, the target service can query data from the second service data source based on the configuration when it needs to query data.

[0063] For example, a large e-commerce platform needs to analyze user behavior data and transaction data in real time. ClickHouse is used for high-performance analysis of real-time data, such as statistics on sales data per minute, user click behavior, etc.; Doris is used to generate real-time sales reports, inventory reports, etc. In order to cope with the surge in visits during promotional activities, it is necessary to be able to switch seamlessly between ClickHouse and Doris to ensure the high availability and responsiveness of the system. Based on this, it is possible to detect whether there is a need to switch data sources for the target service; for example: ClickHouse can be used as a service data source for query data on a daily basis; when a surge in visits is detected, it can be automatically switched to Doris as a service data source for query data; when the visits are detected to be normal, it can be automatically switched to ClickHouse as a service data source for query data. The embodiments of the present invention do not limit this.

[0064] In another example, a bank needs to analyze and monitor transaction data in real time to detect abnormal transactions and prevent fraud. ClickHouse can be used to process large amounts of transaction log data in real time, while Doris is used to generate real-time financial statements and risk analysis reports. When a performance bottleneck or failure is detected in the currently configured service data source for querying data, the system can automatically switch to another service data source to ensure the continuity of analysis and monitoring services.

[0065] In another example, a social media company needs to analyze users' social behaviors and content publishing. ClickHouse is used to process users' interactive data and content recommendation algorithms in real time, while Doris is used to generate user behavior analysis reports and content quality assessments. When a surge in user activity is detected or a data source needs maintenance, the system can automatically switch the service data source to ensure that the user experience is not affected.

[0066] In one embodiment of the present invention, ClickHouse and Doris can be connected and operated based on JAVA's JDBC (Java Database Connectivity) driver.

[0067] For example, the key to achieving seamless dynamic switching lies in designing reasonable switching strategies, such as active health checks, passive fault switching, and load balancing strategies. Active health checks regularly detect the availability and performance of data sources. When a data source fails or performance degradation is found, it automatically switches to another backup data source; passive fault switching triggers switching when an operation fails, such as automatically retrying Doris when querying ClickHouse fails; load balancing dynamically selects the most suitable data source based on the current system load and data source performance.

[0068] In an embodiment of the present invention, when the target service is configured to query data from a first service data source, the first service data source and / or the target service are detected; based on the detection results of the first service data source and / or the target service, it is determined whether the target service has a need to switch the data source; when it is determined that the target service has a need to switch the data source, the target service is configured to query data from a second service data source. Through the embodiment of the present invention, the high availability of the business system can be improved, the performance can be optimized, the operation and maintenance and management can be simplified, the user experience can be improved, and the business system can effectively respond to complex and changeable data processing and analysis needs.

[0069] Reference Figure 2 , shows a flowchart of another method for switching a service data source according to an embodiment of the present invention, which may include the following steps:

[0070] Step 201: When the target service is configured to query data from a first service data source, the first service data source and / or the target service is detected.

[0071] In the embodiment of the present invention, multiple service data sources may be configured for the target service; illustratively, at least a first service data source and a second service data source may be configured for the target service.

[0072] When the target service is configured to query data from the first service data source, the performance of the first service data source can be tested, and the target service's demand for the data source can also be tested; based on the detection, corresponding detection results can be generated.

[0073] Step 202: Based on the detection result of the first service data source and / or the target service, determine whether the target service has a data source switching demand.

[0074] After detecting the first service data source and / or the target service and generating corresponding detection results, it can be determined whether the target service has a need to switch data sources based on the detection results generated after detecting the first service data source and / or the target service, that is, whether the configuration for the target service needs to be changed from querying data from the first service data source to querying data from the second service data source.

[0075] Step 203: When it is determined that the target service has a need to switch the data source, configure the target service to query data from the second service data source.

[0076] In actual applications, based on the detection results, if it is determined that the target service has different data query requirements, or there are performance problems with the first service data source, or there is an abnormality in the first service data source, it can be determined that the target service has a need to switch the data source.

[0077] When it is determined that the target service has a need to switch the data source, the configuration of the target service may be modified to configure the target service to query data from the second service data source.

[0078] When the target service is configured to query data from the second service data source, the target service can query data from the second service data source based on the configuration when it needs to query data.

[0079] Step 204: After configuring the target service to query data from the second service data source, when an exception occurs in the second service data source, configure the target service to query data from the first service data source.

[0080] In some feasible embodiments, after configuring the target service to query data from the second service data source, it may be detected whether the second service data source has abnormal problems such as incompatibility.

[0081] If after configuring the target service to query data from the second service data source, an abnormality is detected in the second service data source, the data source can be backtracked; specifically, the target service can be reconfigured to query data from the first service data source to avoid affecting the user's use of the target service due to problems with the data source.

[0082] In an embodiment of the present invention, when the target service is configured to query data from a first service data source, the first service data source and / or the target service are detected; based on the detection results of the first service data source and / or the target service, it is determined whether the target service has a need to switch the data source; when it is determined that the target service has a need to switch the data source, the target service is configured to query data from a second service data source; after configuring the target service to query data from the second service data source, when the second service data source has an abnormality, the target service is configured to query data from the first service data source. Through the embodiments of the present invention, the high availability of the business system can be improved, the performance can be optimized, the operation and maintenance and management can be simplified, the user experience can be improved, and the business system can effectively respond to complex and changeable data processing and analysis needs.

[0083] And once the new version of the data source encounters an exception or incompatibility, the configuration can be rolled back immediately and the system can be switched back to the original data source to ensure business continuity.

[0084] Reference Figure 3 , shows a flowchart of another method for switching a service data source according to an embodiment of the present invention, which may include the following steps:

[0085] Step 301: When the target service is configured to query data from a first service data source, when the first service data source is modified, the second service data source is synchronized based on the modification of the first service data source.

[0086] In some feasible embodiments, when the target service is configured to query data from the first service data source, in order to ensure that the data of the first service data source and the second service data source are the same when switching, thereby ensuring that the switching is seamless, the second service data source can be synchronized based on the modifications to the first service data source when the first service data source is modified.

[0087] Therefore, even if the target service switches from querying data from the first service data source to querying data from the second service data source, the data is the same, and the target service will not be unable to operate normally due to data differences.

[0088] Step 302: When the target service is configured to query data from the first service data source, the first service data source and / or the target service is detected.

[0089] When the target service is configured to query data from the first service data source, the performance of the first service data source can be tested, and the target service's demand for the data source can also be tested; based on the detection, corresponding detection results can be generated.

[0090] Step 303: Based on the detection result of the first service data source and / or the target service, determine whether the target service has a data source switching demand.

[0091] After detecting the first service data source and / or the target service and generating corresponding detection results, it can be determined whether the target service has a need to switch data sources based on the detection results generated after detecting the first service data source and / or the target service, that is, whether the configuration for the target service needs to be changed from querying data from the first service data source to querying data from the second service data source.

[0092] Step 304: When it is determined that the target service has a need to switch the data source, configure the target service to query data from the second service data source.

[0093] In actual applications, based on the detection results, if it is determined that the target service has different data query requirements, or there are performance problems with the first service data source, or there is an abnormality in the first service data source, it can be determined that the target service has a need to switch the data source.

[0094] When it is determined that the target service has a need to switch the data source, the configuration of the target service may be modified to configure the target service to query data from the second service data source.

[0095] When the target service is configured to query data from the second service data source, the target service can query data from the second service data source based on the configuration when it needs to query data.

[0096] Step 305: After configuring the target service to query data from the second service data source, when an exception occurs in the second service data source, configure the target service to query data from the first service data source.

[0097] In some feasible embodiments, after configuring the target service to query data from the second service data source, it may be detected whether the second service data source has abnormal problems such as incompatibility.

[0098] If, after configuring the target service to query data from the second service data source, an abnormality is detected in the second service data source, data source backtracking may be performed.

[0099] Specifically, the target service may be reconfigured to query data from the first service data source to avoid affecting the user's use of the target service due to problems with the data source, which is not limited in this embodiment of the present invention.

[0100] In an embodiment of the present invention, the above method may further include the following steps:

[0101] When the second service data source is synchronized based on the modification of the first service data source, the preset cache is synchronized based on the modification of the first service data source.

[0102] In some feasible embodiments, in order to reduce the number of data source queries and improve system performance, a cache mechanism (such as Ehcache, Redis, etc.) can be used. In the embodiments of the present invention, it is necessary to consider the synchronization and consistency of the cache to ensure that the cache is still valid after switching the data source. Therefore, while synchronizing the second service data source based on the modification of the first service data source, the preset cache can be synchronized based on the modification of the first service data source to ensure that the data in the preset cache is still valid after switching the data source.

[0103] In an embodiment of the present invention, the above method may further include the following steps:

[0104] When the target service is configured to query data from the first service data source, upon receiving a switching instruction input by the user, the target service is configured to query data from the second service data source.

[0105] In some feasible embodiments, the switching of the data source may also be performed by a manager; specifically, when the manager finds that the data source needs to be switched, the manager may input a switching instruction.

[0106] Upon receiving a switching instruction, and if the switching instruction is received when the target service is configured to query data from the first service data source, the system may configure the target service to query data from the second service data source in response to the switching instruction.

[0107] In an embodiment of the present invention, the above method may further include the following steps:

[0108] The configuration of the data source query of the target service is recorded; and / or the switching operation of the data source is recorded.

[0109] In some feasible embodiments, in order to promptly discover problems during the switching process and ensure stable operation of the system, the switching operation and data source status can be recorded through logs, and the performance and availability of the data source can be monitored in real time through a monitoring system.

[0110] Specifically, the configuration of the data source query of the target service can be recorded; in addition, the switching operation of the data source can also be recorded. For example, when switching to querying data from the second service data source, the switching operation can be recorded for subsequent troubleshooting and other operations.

[0111] In one embodiment of the present invention, the first service data source and the second service data source share a target connection pool;

[0112] Alternatively, the first service data source corresponds to the first connection pool, and the second service data source corresponds to the second connection pool; when the target service is configured to query data from the first service data source, the target service is configured to connect to the first service data source based on the first connection pool; when the target service is configured to query data from the second service data source, the target service is configured to connect to the second service data source based on the second connection pool.

[0113] In some feasible embodiments, connection pool technology can be used to improve the reusability of data source connections and reduce the overhead of frequently creating and closing connections. Common connection pool tools include HikariCP, C3P0, etc.

[0114] In the embodiment of the present invention, it is necessary to share or switch the connection pool between different data sources to ensure the stability and efficiency of the connection during the switching process.

[0115] Specifically, the first service data source and the second service data source may share the same target connection pool.

[0116] In addition, the first service data source and the second service data source may also correspond to a connection pool respectively; specifically, the first service data source may correspond to the first connection pool, and the second service data source may correspond to the second connection pool.

[0117] Among them, when the target service is configured to query data from a first service data source, the target service is configured to connect to the first service data source based on a first connection pool; when the target service is configured to query data from a second service data source, the target service is configured to connect to the second service data source based on a second connection pool, and the embodiment of the present invention does not impose any restrictions on this.

[0118] In an embodiment of the present invention, when the target service is configured to query data from the first service data source, when the first service data source is modified, the second service data source is synchronized based on the modification of the first service data source; when the target service is configured to query data from the first service data source, the first service data source and / or the target service are detected; based on the detection results of the first service data source and / or the target service, it is determined whether the target service has a need to switch the data source; when it is determined that the target service has a need to switch the data source, the target service is configured to query data from the second service data source; after the target service is configured to query data from the second service data source, when the second service data source has an abnormality, the target service is configured to query data from the first service data source. Through the embodiments of the present invention, the high availability of the business system can be improved, the performance can be optimized, the operation and maintenance and management can be simplified, the user experience can be improved, and the business system can effectively cope with complex and changeable data processing and analysis requirements.

[0119] And once the new version of the data source encounters an exception or incompatibility, the configuration can be rolled back immediately and the system can be switched back to the original data source to ensure business continuity.

[0120] For example, during the operation of the target service, when a version is upgraded, if it is necessary to switch the data source, a smooth and imperceptible switch can be achieved through dynamic configuration.

[0121] Specifically, by dynamically modifying the configuration, the system can quickly adjust the current data source direction, thereby immediately switching to the preset backup data source or new version data source without restarting the service or other complex operations. This switching process is completely transparent at the application level, that is, for end users using the service, the entire switching process is "unnoticeable" and will not affect their normal usage experience. This not only effectively avoids service interruptions or delays caused by data source switching, but also greatly improves the system's response speed and stability to users.

[0122] In addition, this dynamic switching solution provides extremely high flexibility and security for system upgrades and maintenance. Since it supports seamless switching back to the old version of the data source, once the new version of the data source is abnormal or incompatible, the operation and maintenance personnel can immediately roll back the configuration and switch the system back to the original data source, thereby ensuring business continuity.

[0123] During the entire process, the service is always online and does not need to be restarted, which greatly reduces the complexity of the switching operation and the maintenance cost. This dynamic configuration and seamless switching solution not only ensures that online business is not affected by data source switching, but also has strong fault tolerance and rollback capabilities, providing solid support for the system's high availability and business continuity.

[0124] During service operation, if Figure 4 As shown, if the data source used is abnormal or the storage space is insufficient, the system can perform real-time monitoring through the health check mechanism (Health Check).

[0125] The health check mechanism will continuously detect the status of the data source to ensure that problems are discovered in a timely manner and the service configuration is modified for the service; specifically, the data source configured for the service and used to query data can be modified.

[0126] Once the system detects abnormal connection with the data source, increased response delay, or insufficient storage space, it will automatically trigger an alarm to notify relevant operation and maintenance personnel.

[0127] This alarm not only contains specific information about the problem, but also helps operation and maintenance personnel quickly locate the problem, reduce troubleshooting time, and thus respond and handle it in a timely manner.

[0128] After the alarm is issued, if Figure 5 As shown, the operation and maintenance personnel can configure the service according to the system prompts and choose to manually switch the data source to directly switch the service to another data source.

[0129] At the same time, the system can also automatically switch to another data source according to the preset strategy to achieve unattended automatic fault tolerance. Figure 6 As shown, you can switch from ClickHouse to Doris.

[0130] This switching process can effectively avoid the risks brought by data source anomalies, ensure the continuous availability of services, and reduce the impact of data source problems on the normal operation of the system.

[0131] In addition, in order to minimize user perception, the system uses a senseless dynamic switching method when switching data sources. The system can smoothly complete the switching of data sources without the user noticing, thereby ensuring business continuity. Even at the moment of switching, the processing of user requests will not be interrupted or affected, providing a smooth and high-quality user experience.

[0132] Through health checks and intelligent switching mechanisms, the system can detect and resolve data source anomalies in real time, and implement an integrated security process from monitoring, alarming to switching. This not only effectively avoids service interruptions caused by data source problems, but also greatly improves system reliability, ensuring that the business continues to run stably under high availability.

[0133] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0134] Reference Figure 7 , shows a schematic diagram of the structure of a switching device for a service data source according to an embodiment of the present invention, which may include the following modules:

[0135] A detection module 701, configured to detect the first service data source and / or the target service when the target service is configured to query data from the first service data source;

[0136] A determination module 702 is used to determine whether the target service has a data source switching requirement based on the detection result of the first service data source and / or the target service;

[0137] The switching module 703 is used to configure the target service to query data from the second service data source when it is determined that the target service has a need to switch the data source.

[0138] In an optional embodiment of the present invention, the switching module 703 is further used to configure the target service to query data from the second service data source when a switching instruction input by the user is received when the target service is configured to query data from the first service data source.

[0139] In an optional embodiment of the present invention, the switching module 703 is also used to synchronize the second service data source based on the modification of the first service data source when the target service is configured to query data from the first service data source and the first service data source is modified.

[0140] In an optional embodiment of the present invention, the device further comprises

[0141] The cache synchronization module is used to synchronize the preset cache based on the modification of the first service data source when synchronizing the second service data source based on the modification of the first service data source.

[0142] In an optional embodiment of the present invention, the switching module 703 is further used to configure the target service to query data from the first service data source when an exception occurs in the second service data source after the target service is configured to query data from the second service data source.

[0143] In an optional embodiment of the present invention, the device further comprises:

[0144] The recording module is used to record the configuration of the data source query of the target service; and / or to record the switching operation of the data source.

[0145] In an optional embodiment of the present invention, the first service data source and the second service data source share a target connection pool;

[0146] Alternatively, the first service data source corresponds to the first connection pool, and the second service data source corresponds to the second connection pool; when the target service is configured to query data from the first service data source, the target service is configured to connect to the first service data source based on the first connection pool; when the target service is configured to query data from the second service data source, the target service is configured to connect to the second service data source based on the second connection pool.

[0147] In an embodiment of the present invention, when the target service is configured to query data from a first service data source, the first service data source and / or the target service are detected; based on the detection results of the first service data source and / or the target service, it is determined whether the target service has a need to switch the data source; when it is determined that the target service has a need to switch the data source, the target service is configured to query data from a second service data source. Through the embodiment of the present invention, the high availability of the business system can be improved, the performance can be optimized, the operation and maintenance and management can be simplified, the user experience can be improved, and the business system can effectively respond to complex and changeable data processing and analysis needs.

[0148] An embodiment of the present invention further provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and when the computer program is executed by the processor, the above-mentioned method for switching a service data source is implemented.

[0149] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned method for switching a service data source is implemented.

[0150] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0151] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0152] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0153] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0154] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0155] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0156] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0157] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0158] The above provides a detailed introduction to a method for switching a service data source, a device for switching a service data source, an electronic device and a computer-readable storage medium. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for switching a service data source, characterized in that: The service data source of the target service includes at least a first service data source and a second service data source, and the method includes: When the target service is configured to query data from the first service data source, detecting the first service data source and / or the target service; Based on the detection result of the first service data source and / or the target service, determining whether the target service has a data source switching demand; When it is determined that the target service has a need to switch the data source, the target service is configured to query data from the second service data source.

2. The method according to claim 1, characterized in that The method further comprises: When the target service is configured to query data from the first service data source, upon receiving a switching instruction input by a user, the target service is configured to query data from the second service data source.

3. The method according to claim 1, characterized in that The method further comprises: When the target service is configured to query data from the first service data source, when the first service data source is modified, the second service data source is synchronized based on the modification to the first service data source.

4. The method according to claim 3, characterized in that When synchronizing the second service data source based on the modification of the first service data source, the method further includes: Based on the modification of the first service data source, the preset cache is synchronized.

5. The method according to claim 1, characterized in that After configuring the target service to query data from the second service data source, the method further includes: When an exception occurs in the second service data source, the target service is configured to query data from the first service data source.

6. The method according to claim 1, characterized in that The method further comprises: Recording the configuration of the data source query of the target service; And / or, the switching operation of the data source is recorded.

7. The method according to claim 1, characterized in that The first service data source and the second service data source share a target connection pool; Alternatively, the first service data source corresponds to a first connection pool, and the second service data source corresponds to a second connection pool; When the target service is configured to query data from the first service data source, configuring the target service to connect to the first service data source based on the first connection pool; When the target service is configured to query data from the second service data source, the target service is configured to connect to the second service data source based on the second connection pool.

8. A switching device for a service data source, characterized in that: The service data source of the target service includes at least a first service data source and a second service data source, and the device includes: a detection module, configured to detect the first service data source and / or the target service when the target service is configured to query data from the first service data source; A judgment module, configured to judge whether the target service has a data source switching requirement based on the detection result of the first service data source and / or the target service; The switching module is used to configure the target service to query data from the second service data source when it is determined that the target service has a need to switch the data source.

9. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the method for switching the service data source as claimed in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for switching a service data source according to any one of claims 1 to 7 is implemented.