TWI484335B - Cached data processing method, processing system, and means - Google Patents
Cached data processing method, processing system, and means Download PDFInfo
- Publication number
- TWI484335B TWI484335B TW099100278A TW99100278A TWI484335B TW I484335 B TWI484335 B TW I484335B TW 099100278 A TW099100278 A TW 099100278A TW 99100278 A TW99100278 A TW 99100278A TW I484335 B TWI484335 B TW I484335B
- Authority
- TW
- Taiwan
- Prior art keywords
- cache
- service node
- cache service
- client
- result
- Prior art date
Links
Landscapes
- Hardware Redundancy (AREA)
Description
本申請案關於網路技術領域,特別是關於一種快取資料的處理方法,處理系統和裝置。The present application relates to the field of network technologies, and in particular, to a method, a processing system and a device for processing cache data.
分散式快取(Distributed Cache),即快取在分散式系統記憶體中的快取資料,將需要快取的內容分散到物理上隔離的快取服務節點中保存,可以為事件驅動型第三方應用程式提供高可用性、高性能和可伸縮性。其中,高可用性是指事件處理第三方應用程式可以將輸出事件發佈到一個重複式的分散式快取,從而保證其計算結果具有高可用性;高性能和可伸縮性是指許多事件驅動型第三方應用程式都需要結合使用流資料和外部資料,例如從持久性記憶體中檢索出來的資料。快取可用於提高訪問非流式資料的速度,從而動態地提高第三方應用程式的性能,被廣泛應用於網際網路第三方應用以及大型網站架構設計中。Distributed Cache, which caches cached data in decentralized system memory, distributes cached content to physically isolated cache nodes, and can be event-driven third-party The application provides high availability, high performance and scalability. Among them, high availability means that event processing third-party applications can publish output events to a repetitive, decentralized cache to ensure high availability of their calculations; high performance and scalability refer to many event-driven third parties. Applications need to use both streaming and external data, such as data retrieved from persistent storage. Caches can be used to increase the speed of accessing non-streaming data, thereby dynamically improving the performance of third-party applications, and are widely used in Internet third-party applications and large-scale website architecture design.
當前分散式快取主要有服務端分散式和客戶端分散式兩類。Currently, distributed caches mainly include server-side decentralization and client-side decentralization.
服務端分散式的分散式快取結構示意圖如圖1所示,由Cache Client(快取客戶端)、Cache Node A(快取服務節點A)、Cache Node B(快取服務節點B)和Cache Node C(快取服務節點C)組成。其特點是分散式操作由服務端來完成,通常採用JGroup的多播通信作為手段,透過三階段事務協定執行操作和同步資料。該類型的主要代表是:JBoss Cache和EhCache。這種模式最大的問題就是效率問題,由於多播通信本身的不可靠性及三階段事務的策略複雜性,導致這類快取的效率不高,無法應用於操作頻繁,高並發請求的系統架構。The server-decentralized decentralized cache structure is shown in Figure 1. It consists of Cache Client (Cache Client), Cache Node A (Cache Node A), Cache Node B (Cache Node B), and Cache. Node C (cache service node C). It is characterized by decentralized operations performed by the server. Usually, JGroup's multicast communication is used as a means to perform operations and synchronize data through a three-phase transaction protocol. The main representatives of this type are: JBoss Cache and EhCache. The biggest problem with this model is the efficiency problem. Due to the unreliability of multicast communication itself and the complexity of the strategy of three-phase transaction, the efficiency of such cache is not high enough to be applied to the system architecture with frequent operations and high concurrent requests. .
客戶端分散式的分散式快取結構示意圖如圖2所示,由Cache Client、Cache Node A、Cache Node B和Cache Node C組成。其特點是快取服務端本身是集中式的快取,服務端不負責分發資料和同步資料,但是透過客戶端的演算法設置,將不同Key的資料分發到不同的服務端,就形成了可擴展的客戶端分散式快取系統。該類型的主要代表:Memcached Cache。這種模式可擴展性強,效率很高,但是缺少容錯機制,當其中某一資料快取服務節點不可用時,系統將丟失部分資料,影響業務系統正常使用。新浪的開源Memcached DB,將資料固化到記憶體資料庫或者本地硬碟來保證資料的完整性,但是這並不能夠在高並發下起到集群容錯和均衡負載的效果。The decentralized decentralized cache structure of the client is shown in Figure 2. It consists of Cache Client, Cache Node A, Cache Node B, and Cache Node C. The feature is that the cache server itself is a centralized cache, the server is not responsible for distributing data and synchronizing data, but through the client's algorithm settings, the data of different keys is distributed to different servers, forming an expandable Client-side decentralized cache system. The main representative of this type: Memcached Cache. This mode is highly scalable and efficient, but lacks a fault tolerance mechanism. When one of the data cache service nodes is unavailable, the system will lose some data and affect the normal use of the business system. Sina's open source Memcached DB, the data is solidified to the memory database or local hard disk to ensure the integrity of the data, but this does not have the effect of cluster fault tolerance and balanced load under high concurrency.
現有技術存在如下問題:快取服務節點失效導致資料丟失無法恢復。資料被客戶端透過固定演算法分發到某一快取服務節點,快取服務節點的異常,將使得這個快取服務節點上的所有資料丟失。而且,快取服務節點失效導致無法繼續正常服務。資料被客戶端透過固定演算法分發到某一快取服務節點,快取服務節點的異常,將使得被分發到這個快取服務節點上的請求都將不再被接收處理。The prior art has the following problem: the failure of the cache service node causes the data loss to be unrecoverable. The data is distributed by the client to a cache service node through a fixed algorithm. The cache node exception will cause all data on the cache service node to be lost. Moreover, the failure of the cache service node prevents the normal service from continuing. The data is distributed by the client to a cache service node through a fixed algorithm. The cache service node exception will cause the requests distributed to the cache service node to be no longer processed.
本申請案提供一種快取資料的處理方法、處理系統和裝置,應用於集群中多個快取服務節點的網路中,用於解決快取服務節點失效引起的資料丟失和快取服務節點不可用的問題,提高系統可靠性和可用性。The application provides a method, a processing system and a device for processing cache data, which are applied to a network of multiple cache service nodes in a cluster, and are used for solving data loss caused by failure of the cache service node and the cache service node is unavailable. Use problems to improve system reliability and availability.
本申請案提供一種快取資料的處理方法,應用於包括多個快取服務節點的集群中,包括:快取客戶端在需要對快取資料進行操作時,向主用快取服務節點發送操作請求;該快取客戶端接收所述主用快取服務節點對該操作請求的操作結果;該快取客戶端在該主用快取服務節點執行操作失敗時,選擇一備用快取服務節點並向該備用快取服務節點發送操作請求。The present application provides a method for processing cache data, which is applied to a cluster including a plurality of cache service nodes, including: the cache client sends an operation to the primary cache service node when the cache data needs to be operated. a request; the cache client receives an operation result of the operation request by the primary cache service node; and the cache client selects an alternate cache service node when the primary cache service node fails to perform an operation and Send an operation request to the alternate cache service node.
該選擇一備用快取服務節點並向該備用快取服務節點發送操作請求之前,還包括:當該主用快取服務節點執行操作失敗時,該快取客戶端累計其失敗次數;該快取客戶端將該失敗次數與閥值進行比較,當該失敗次數超過閥值時,將主用快取服務節點標示為失效。Before selecting an alternate cache service node and sending an operation request to the standby cache service node, the method further includes: when the primary cache service node performs an operation failure, the cache client accumulates the number of failures; the cache The client compares the number of failures with a threshold, and when the number of failures exceeds a threshold, the primary cache service node is marked as invalid.
該將主用快取服務節點標示為失效之後,還包括:設定該主用快取服務節點的失效有效期。該選擇一備用快取服務節點包括:該快取客戶端根據獲取到的標示為失效的快取服務節點,獲取網路中可用的快取服務節點;該快取客戶端在該可用的快取服務節點中,根據演算法選擇一快取服務節點作為備用快取服務節點。After the primary cache service node is marked as invalid, the method further includes: setting an expiration validity period of the primary cache service node. The selecting an alternate cache service node includes: the cache client acquiring a cache service node available in the network according to the obtained cache service node marked as invalid; the cache client is in the available cache In the service node, a cache service node is selected as an alternate cache service node according to the algorithm.
該演算法包括:動態負載分配選擇演算法和哈希演算法或一致性哈希演算法。The algorithm includes: dynamic load distribution selection algorithm and hash algorithm or consistent hash algorithm.
該向該備用快取服務節點發送操作請求之後,還包括:該快取客戶端接收該備用快取服務節點對該操作請求的操作結果並根據操作結果進行處理。After the operation request is sent to the standby cache service node, the method further includes: the cache client receiving the operation result of the operation request by the standby cache service node, and processing according to the operation result.
該快取客戶端向主用快取服務節點發送操作請求前,還包括:該快取客戶端根據獲取到的標示為失效的快取服務節點,獲取網路中可用的快取服務節點;該快取客戶端在該可用的快取服務節點中,根據演算法選擇一快取服務節點作為主用快取服務節點。Before the cache client sends an operation request to the active cache service node, the method further includes: the cache client acquiring the cache service node available in the network according to the obtained cache service node marked as invalid; The cache client selects a cache service node as the active cache service node according to the algorithm in the available cache service node.
該根據操作結果進行處理包括:該快取客戶端根據該操作結果判斷該操作是否成功;當該操作成功時,該快取客戶端對該主用快取服務節點進行非同步處理;當該操作失敗時,該快取客戶端將該備用快取服務節點標示失效,並重新選擇備用快取服務節點。The processing according to the operation result includes: determining, by the cache client, whether the operation is successful according to the operation result; when the operation is successful, the cache client performs asynchronous processing on the primary cache service node; Upon failure, the cache client invalidates the alternate cache service node and reselects the alternate cache service node.
該快取客戶端對該主用快取服務節點進行非同步處理具體包括:當該操作成功且為獲取操作時,該快取客戶端將該操作結果快取到該快取客戶端,並將該操作和操作結果保存到集群操作任務佇列並由任務執行緒池將該操作和操作內容恢復到集群中除去進行該操作的其他快取服務節點;當該操作成功且為更新操作時,該快取客戶端將該操作和操作結果保存到集群操作任務佇列並由任務執行緒池將該操作和操作內容複製到集群中除去進行該操作的其他快取服務節點。The cache client performs asynchronous processing on the active cache service node, specifically: when the operation succeeds and is an acquisition operation, the cache client caches the operation result to the cache client, and The operation and operation result are saved to the cluster operation task queue and the operation and operation content is restored to the cluster by the task thread pool to remove other cache service nodes that perform the operation; when the operation is successful and the update operation is performed, The cache client saves the operation and operation results to the cluster operation task queue and copies the operation and operation content to the cluster by the task thread pool to remove other cache service nodes that perform the operation.
該快取客戶端向主用快取服務節點發送操作請求前,還包括:該快取客戶端在需要對快取資料進行操作時,獲取預先指定的該主用快取服務節點。Before the cache client sends an operation request to the active cache service node, the method further includes: the cache client acquiring the pre-designated primary cache service node when the cache data needs to be operated.
該根據操作結果進行處理包括:該快取客戶端根據該操作結果判斷該操作是否成功;當該操作成功時,該備用快取服務節點對該主用快取服務節點進行資料同步;當該操作失敗時,該快取客戶端將重新選擇備用快取服務節點並向該備用快取服務節點發送操作請求。The processing according to the operation result includes: determining, by the cache client, whether the operation is successful according to the operation result; when the operation is successful, the standby cache service node performs data synchronization on the primary cache service node; Upon failure, the cache client will reselect the alternate cache service node and send an operation request to the alternate cache service node.
還包括:該快取客戶端對該主用快取服務節點和該備用快取服務節點進行心跳檢測;該快取客戶端根據心跳檢測的結果更新該主用快取服務節點和/或備用快取服務節點的失效狀態。The method further includes: the cache client performing heartbeat detection on the primary cache service node and the standby cache service node; the cache client updating the primary cache service node and/or standby fast according to a result of heartbeat detection Take the failure status of the service node.
還包括:當該集群中快取服務節點能力不夠時,可以進行單節點動態擴容。It also includes: when the capability of the cache service node in the cluster is insufficient, dynamic expansion of the single node can be performed.
本申請案提供一種快取資料的處理系統,包括多個快取服務節點,包括:快取客戶端,用於向主用快取服務節點發送操作請求,並接收該主用快取服務節點對該操作請求的操作結果;當根據接收的該主用快取服務節點對該操作請求的操作結果判斷該操作失敗時,選擇一備用快取服務節點並向該備用快取服務節點發送操作快取資料請求;主用快取服務節點,用於接收該快取客戶端發送的操作快取資料請求,並向該快取客戶端返回操作結果;備用快取服務節點,當該主用快取服務節點失效時,接收該快取客戶端發送的操作快取資料請求。The application provides a processing system for cache data, including a plurality of cache service nodes, including: a cache client, configured to send an operation request to the primary cache service node, and receive the master cache service node pair. The operation result of the operation request; when it is determined that the operation fails according to the received operation result of the operation request by the active cache service node, selecting an alternate cache service node and sending an operation cache to the standby cache service node a data request; the main cache service node is configured to receive an operation cache data request sent by the cache client, and return an operation result to the cache client; the alternate cache service node, when the main cache service When the node fails, the operation cache data request sent by the cache client is received.
該集群中多個快取服務節點為Active集群配置模式時,該集群中多個快取服務節點都處於工作狀態,當某一快取服務節點失效時,其他快取服務節點分擔請求;該集群中多個快取服務節點為Standby集群配置模式時,該集群中多個快取服務節點中只有一個快取服務節點作為主快取服務節點處於工作狀態,其他快取服務節點都處於備用狀態,當該主用快取服務節點失效時,其他快取服務節點中的一個快取服務節點作為備用快取服務節點接替該主用快取服務節點,接收請求。When multiple cache service nodes in the cluster are in the active cluster configuration mode, multiple cache service nodes in the cluster are in working state. When one cache service node fails, other cache service nodes share the request; the cluster When multiple cache service nodes are in the Standby cluster configuration mode, only one of the cache service nodes in the cluster is in the working state as the primary cache service node, and other cache service nodes are in the standby state. When the primary cache service node fails, one of the other cache service nodes replaces the primary cache service node as a backup cache service node and receives the request.
當該集群中多個快取服務節點能力不夠時,可以進行單節點動態擴容。When the capacity of multiple cache service nodes in the cluster is insufficient, dynamic expansion of single nodes can be performed.
本申請案提供一種快取客戶端,應用於包括多個快取服務節點的集群中,包括:請求發送單元,用於在需要對快取資料進行操作時,向主用快取服務節點發送操作請求;結果接收單元,用於接收該主用快取服務節點對該請求發送單元發送的操作請求的操作結果;快取服務節點選擇單元,用於當根據該結果接收單元接收的操作結果判斷該主用快取服務節點執行操作失敗時,選擇一備用快取服務節點並由該請求發送單元向該備用快取服務節點發送操作請求。The application provides a cache client, which is applied to a cluster including a plurality of cache service nodes, and includes: a request sending unit, configured to send an operation to the active cache service node when the cache data needs to be operated. a result receiving unit, configured to receive an operation result of the operation request sent by the primary cache service node to the request sending unit, and a cache service node selecting unit, configured to determine, according to an operation result received by the result receiving unit When the primary cache service node fails to perform the operation, an alternate cache service node is selected and an operation request is sent by the request sending unit to the standby cache service node.
還包括:失效標示單元,用於當根據該結果接收單元接收的操作結果判斷該主用快取服務節點執行操作失敗時,將該主用快取服務節點標示為失效。The method further includes: a failure indication unit, configured to mark the primary cache service node as invalid when it is determined that the primary cache service node fails to perform an operation according to the operation result received by the result receiving unit.
該失效標示單元具體包括:次數累計子單元,用於當該主用快取服務節點執行操作失敗時,該快取客戶端累計其失敗次數;失效標示子單元,用於將該次數累計子單元累計的失敗次數與閥值進行比較,當該失敗次數超過該閥值時,將該主用快取服務節點標示為失效;失效有效期設定子單元,用於在該失效標示子單元將該主用快取服務節點標示為失效後,設定該主用快取服務節點的失效有效期。The failure indication unit specifically includes: a time accumulation subunit, configured to accumulate the number of failures of the cache client when the main cache service node fails to perform the operation; the failure flag subunit is used to accumulate the subunits The cumulative number of failures is compared with a threshold value. When the number of failures exceeds the threshold, the primary cache service node is marked as invalid; the invalidation validity period setting subunit is used for the primary use in the failure indication subunit. After the cache service node is marked as invalid, the expiration validity period of the active cache service node is set.
該快取服務節點選擇單元具體包括:可用快取服務節點獲取子單元,用於根據該失效標示子單元標示為失效的快取服務節點,獲取網路中可用的快取服務節點;快取服務節點選擇子單元,用於在該可用快取服務節點獲取子單元獲取的可用的快取服務節點中,根據演算法選擇一快取服務節點作為備用快取服務節點,該演算法包括動態負載分配選擇演算法和哈希演算法或一致性哈希演算法。The cache service node selection unit specifically includes: an available cache service node acquisition subunit, configured to acquire a cache service node available in the network according to the cache service node indicated as the invalidation by the failure indication subunit; the cache service a node selection subunit, configured to select a cache service node as an alternate cache service node according to an algorithm, in the available cache service node obtained by the available cache service node acquisition subunit, the algorithm includes dynamic load distribution Choose an algorithm and a hash algorithm or a consistent hash algorithm.
該結果接收單元還用於接收該備用快取服務節點對該請求發送單元發送的操作請求的操作結果;該快取客戶端還包括:操作結果處理單元,用於根據該結果接收單元接收的該備用快取服務節點對該操作請求的操作結果進行處理。The result receiving unit is further configured to receive an operation result of the operation request sent by the standby cache service node to the request sending unit; the cache client further includes: an operation result processing unit, configured to receive the The alternate cache service node processes the result of the operation request.
該集群中多個快取服務節點為Active集群配置模式時,該快取服務節點選擇子單元還用於在該可用的快取服務節點獲取子單元獲取的可用的快取服務節點中,根據演算法選擇一快取服務節點作為主用快取服務節點。When multiple cache service nodes in the cluster are in the active cluster configuration mode, the cache service node selection subunit is further used to obtain available cache service nodes obtained by the subunits in the available cache service node, according to the calculation The method selects a cache service node as the primary cache service node.
該操作結果處理單元還包括:非同步處理子單元,用於當根據該快取客戶端的結果接收單元接收的操作結果判斷該操作成功時,對該主用快取服務節點進行非同步處理;具體的:當該操作成功且為獲取操作時,將該操作結果快取到該快取客戶端,並將該操作和操作結果保存到集群操作任務佇列並由任務執行緒池將該操作和操作內容恢復到集群中除去進行該操作的其他快取服務節點;當該操作成功且為更新操作時,將該操作和操作結果保存到集群操作任務佇列並由任務執行緒池將該操作和操作內容複製到集群中除去進行該操作的其他快取服務節點。The operation result processing unit further includes: a non-synchronization processing sub-unit, configured to perform non-synchronization processing on the main cache service node when the operation is successful according to the operation result received by the result receiving unit of the cache client; When the operation succeeds and the operation is fetched, the result of the operation is cached to the cache client, and the operation and operation result are saved to the cluster operation task queue and the operation and operation are performed by the task thread pool. The content is restored to the cluster and the other cache service nodes that perform the operation are removed; when the operation is successful and the update operation is performed, the operation and operation results are saved to the cluster operation task queue and the operation and operation are performed by the task thread pool. The content is copied to the cluster and the other cache service nodes that do this are removed.
該失效標示單元還用於當根據該結果接收單元接收的操作結果判斷該操作失敗時,將該備用快取服務節點標示為失效。The failure flag indicating unit is further configured to: when the operation failure is determined according to the result of the operation received by the result receiving unit, the standby cache service node is marked as invalid.
該集群中多個快取服務節點為Standby集群配置模式時,該操作結果處理單元還包括:資料同步子單元,用於當根據該快取客戶端的結果接收單元接收的操作結果判斷該操作成功時,對該備用快取服務節點進行資料同步。When the plurality of cache service nodes in the cluster are in the Standby cluster configuration mode, the operation result processing unit further includes: a data synchronization sub-unit, configured to determine, when the operation succeeds according to the operation result received by the result receiving unit of the cache client , data synchronization is performed on the standby cache service node.
還包括:心跳檢測單元,用於對該主用快取服務節點和備用快取服務節點進行心跳檢測,並根據心跳檢測結果更新該主用快取服務節點和/或備用快取服務節點的失效狀態。The method further includes: a heartbeat detecting unit, configured to perform heartbeat detection on the primary cache service node and the standby cache service node, and update the failure of the primary cache service node and/or the standby cache service node according to the heartbeat detection result. status.
本申請案包括以下優點,因為採用了集群配置模式,當主快取服務節點失效時選擇備用快取服務節點來執行操作,從而解決快取服務節點失效引起的資料丟失和快取服務節點不可用的問題,提高系統可靠性和可用性。The present application includes the following advantages, because the cluster configuration mode is adopted, when the primary cache service node fails, the standby cache service node is selected to perform operations, thereby solving the data loss caused by the failure of the cache service node and the cache service node being unavailable. The problem is to improve system reliability and availability.
本申請案的主要思想包括,當主用快取服務節點執行操作快取資料失敗時,快取客戶端將主用快取服務節點標示為失效,選擇一備用快取服務節點並向該備用快取服務節點發送操作請求,從而解決快取服務節點失效引起的資料丟失和快取服務節點不可用的問題,達到了提高系統可靠性和可用性的效果。The main idea of the present application includes that when the primary cache service node fails to execute the operation cache data, the cache client marks the primary cache service node as invalid, selects an alternate cache service node and sends the standby cache node to the standby fast. The service node sends an operation request, thereby solving the problem of data loss caused by the failure of the cache service node and the unavailability of the cache service node, thereby achieving the effect of improving system reliability and availability.
下面將結合本申請案中的附圖,對本申請案中的技術方案進行清楚、完整的描述,顯然,所描述的實施例是本申請案的一部分實施例,而不是全部的實施例。基於本申請案中的實施例,本領域普通技術人員在沒有做出創造性勞動的前提下所獲得的所有其他實施例,都屬於本申請案保護的範圍。The technical solutions in the present application are clearly and completely described in the following with reference to the drawings in the present application. It is obvious that the described embodiments are a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative efforts are within the scope of the present application.
本申請案中提供一種快取資料的處理方法,採用集群配置模式用於集群中多個快取服務節點的網路中,解決快取服務節點失效引起的資料丟失和快取服務節點不可用的問題,如圖3所示,其中包括快取客戶端,用於接收第三方應用的快取操作請求和選擇快取服務節點;快取服務節點,相當於邏輯上的快取伺服器,用於快取資料庫中的資料,具體包括以下步驟:The present application provides a method for processing cache data, which is used in a network of multiple cache service nodes in a cluster, and solves the problem of data loss caused by failure of the cache service node and the cache service node being unavailable. The problem, as shown in FIG. 3, includes a cache client for receiving a cache operation request of a third-party application and selecting a cache service node; the cache service node is equivalent to a logical cache server for Cache the data in the database, including the following steps:
步驟s301,快取客戶端在需要對快取資料進行操作時,向主用快取服務節點發送操作請求。In step s301, the cache client sends an operation request to the active cache service node when the cache data needs to be operated.
步驟s302,快取客戶端接收主用快取服務節點對該操作請求的操作結果。In step s302, the cache client receives the operation result of the operation request by the active cache service node.
步驟s303,快取客戶端在主用快取服務節點執行操作失敗時,選擇一備用快取服務節點並向該備用快取服務節點發送操作請求。Step s303: The cache client selects an alternate cache service node and sends an operation request to the standby cache service node when the primary cache service node fails to perform the operation.
其中,該集群配置模式包括:Active集群配置模式和Standby集群配置模式。The cluster configuration mode includes an Active Cluster configuration mode and a Standby cluster configuration mode.
Active集群配置模式是指集群中多個快取服務節點都處於工作狀態,當某一快取服務節點失效時,其他快取服務節點分擔請求,並在操作結束時,進行集群中各個節點的資料同步。The active cluster configuration mode means that multiple cache service nodes in the cluster are in working state. When a cache service node fails, other cache service nodes share the request, and at the end of the operation, the data of each node in the cluster is performed. Synchronize.
Standby集群配置模式是指集群中多個快取服務節點中只有一個快取服務節點作為主快取服務節點處於工作狀態,其他快取服務節點都處於備用狀態,當主用快取服務節點失效時,其他快取服務節點中的一個快取服務節點作為備用快取服務節點替換主用快取服務節點,接收請求,並定時對集群中各個節點的資料進行同步。The Standby cluster configuration mode means that only one cache service node in the cluster is in the working state as the primary cache service node, and other cache service nodes are in the standby state. When the primary cache service node fails. One of the other cache service nodes replaces the active cache service node as an alternate cache service node, receives the request, and periodically synchronizes the data of each node in the cluster.
上述Active和Standby兩種集群配置模式實際上是為整個網路系統提供了一種故障自動恢復能力,保證在不需要進行人工干預的情況下使客戶不間斷的對資料進行訪問。The above two Active and Standby cluster configuration modes actually provide an automatic fault recovery capability for the entire network system, ensuring that the client can access the data without interruption without manual intervention.
當集群中多個快取服務節點為Active集群配置模式時,如圖4所示,該快取資料的處理方法的具體步驟為:步驟s401,快取客戶端在需要對快取資料進行操作時,在集群中多個快取服務節點中透過演算法選擇一主用快取服務節點並向該主用快取服務節點發送操作請求。When multiple cache service nodes in the cluster are in the active cluster configuration mode, as shown in FIG. 4, the specific steps of the method for processing the cache data are: step s401, when the cache client needs to operate on the cache data. Selecting an active cache service node through the algorithm in multiple cache service nodes in the cluster and sending an operation request to the master cache service node.
具體的,集群中的快取服務節點如果處於失效狀態,則會保存有失效標示,快取客戶端根據從本地儲存中或在其他位置的儲存中,獲取標示為失效的快取服務節點,進而獲取網路中可用的快取服務節點;快取客戶端在可用的快取服務節點中,根據演算法選擇一快取服務節點作為主用快取服務節點,該演算法包括動態負載分配選擇演算法、哈希演算法或一致性哈希演算法。Specifically, if the cache service node in the cluster is in a failed state, the failure indication is saved, and the cache client obtains the cache service node marked as invalid according to the storage from the local storage or in another location, and further Obtaining a cache service node available in the network; the cache client selects a cache service node as the primary cache service node according to the algorithm in the available cache service node, and the algorithm includes dynamic load distribution selection calculation Method, hash algorithm or consistent hash algorithm.
步驟s402,快取客戶端接收主用快取服務節點對該操作請求的操作結果。In step s402, the cache client receives the operation result of the operation request by the active cache service node.
快取客戶端在可用的快取服務節點中,根據演算法選擇一快取服務節點作為主用快取服務節點之後,向主用快取服務節點發送操作快取資料的請求,主用快取服務節點執行操作快取資料的請求後,將該操作結果發送給快取客戶端。After the cache client selects a cache service node as the active cache service node according to the algorithm, the cache client sends a request for operating the cache data to the master cache service node, and the cache server uses the cache. After the service node performs a request to operate the cache data, the service result is sent to the cache client.
步驟s403,快取客戶端在主用快取服務節點執行操作失敗時,將主用快取服務節點標示為失效,選擇一備用快取服務節點並向該備用快取服務節點發送操作請求。In step s403, when the main cache service node fails to perform the operation, the cache client marks the primary cache service node as invalid, selects an alternate cache service node, and sends an operation request to the standby cache service node.
具體的,當主用快取服務節點執行操作失敗時,快取客戶端累計操作失敗次數;快取客戶端將失敗次數與閥值進行比較,當失敗次數超過閥值時,將主用快取服務節點標示為失效,並設定失效有效期。Specifically, when the main cache service node fails to perform the operation, the cache client accumulates the number of operation failures; the cache client compares the number of failures with the threshold, and when the number of failures exceeds the threshold, the cache is used for the main cache. The service node is marked as invalid and the expiration date is set.
此時,快取客戶端根據獲取到的標示為失效的快取服務節點,獲取網路中可用的快取服務節點;快取客戶端在可用的快取服務節點中,根據演算法選擇一備用快取服務節點並向該備用快取服務節點發送操作請求。備用快取服務節點執行該操作快取資料請求並向快取客戶端發送該操作結果。At this time, the cache client obtains the cache service node available in the network according to the obtained cache service node marked as invalid; the cache client selects a backup according to the algorithm in the available cache service node. The service node is cached and an operation request is sent to the alternate cache service node. The alternate cache service node performs the operation cache data request and sends the operation result to the cache client.
當根據該操作結果判斷該操作成功時,快取客戶端對主用快取服務節點進行非同步處理;其中,非同步處理具體包括:當該操作成功且為獲取操作時,快取客戶端將該操作結果快取到快取客戶端,並將該操作和操作結果保存到集群操作任務佇列。由任務執行緒池將該操作和操作內容恢復到集群中除去進行該操作的其他快取服務節點;當該操作成功且為更新操作時,快取客戶端將該操作和操作結果保存到集群操作任務佇列並由任務執行緒池將該操作和操作內容複製到集群中除去進行該操作的其他快取服務節點。When the operation is successful according to the result of the operation, the cache client performs asynchronous processing on the primary cache service node. The asynchronous processing specifically includes: when the operation is successful and the operation is acquired, the cache client will The result of the operation is cached to the cache client, and the operation and operation results are saved to the cluster operation task queue. The operation and operation content is restored to the cluster by the task thread pool to remove other cache service nodes that perform the operation; when the operation is successful and is an update operation, the cache client saves the operation and operation result to the cluster operation. The task queues and copies the operations and operations from the task thread pool to the cluster to remove other cache service nodes that do the operation.
在Active集群配置模式下,當主用快取服務節點失效時,備用快取服務節點接替主用快取服務節點;當主用快取服務節點恢復時,集群操作任務佇列將備用快取服務節點進行的操作及操作結果恢復或複製到主用快取服務節點,此時主用快取服務節點將重新處於工作狀態,備用快取服務節點將不接替主用快取服務節點接收請求。In the Active Cluster Configuration mode, when the primary cache service node fails, the standby cache service node takes over the primary cache service node; when the primary cache service node is restored, the cluster operation task queues the standby cache service. The operation and operation result of the node is restored or copied to the active cache service node. At this time, the primary cache service node will be in the working state again, and the standby cache service node will not take over the request from the primary cache service node.
上述非同步處理還用於當主用快取服務節點未失效時,將該主用快取服務節點進行的操作更新到集群中所有其他的快取服務節點。也就是說,在Active集群配置模式下,無論是主用快取服務節點還是備用快取服務節點,只要進行了操作,都將該操作及操作結果保存到集群操作任務佇列,在佇列中等待對集群中所有其他的快取服務節點進行資料的非同步處理,以保證集群中的所有快取服務節點資料的一致性。The above asynchronous processing is further used to update the operation performed by the primary cache service node to all other cache service nodes in the cluster when the primary cache service node has not failed. That is to say, in the Active Cluster Configuration mode, whether the primary cache service node or the standby cache service node is operated, the operation and operation result are saved to the cluster operation task queue in the queue. Waiting for non-synchronization of data to all other cache service nodes in the cluster to ensure the consistency of data of all cache service nodes in the cluster.
當根據該操作結果判斷該操作失敗時,快取客戶端將備用快取服務節點標示失效,並重新選擇備用快取服務節點。When it is determined according to the operation result that the operation fails, the cache client invalidates the alternate cache service node identifier and reselects the alternate cache service node.
上述步驟s401中該的動態負載分配選擇演算法如圖5所示,其具體步驟為:步驟s501,Cache Client透過後臺的緒定時從各個可用的快取服務節點獲取可用快取服務節點的參數,包括快取服務節點處理能力指數W[i],快取服務節點當前快取資料總量C[i]、快取服務節點請求回應時間R[i]。The dynamic load distribution selection algorithm in the above step s401 is as shown in FIG. 5, and the specific steps are as follows: in step s501, the Cache Client obtains parameters of the available cache service nodes from the available cache service nodes through the background timing. Including the cache service node processing capability index W[i], the cache server node current cache data total C[i], and the cache service node request response time R[i].
步驟s502,Cache Client對獲取到的可用快取服務節點的各個參數進行昇冪或降冪排列。In step s502, the Cache Client performs an ascending or descending power on each parameter of the obtained available cache service node.
例如:F(K[i],{K[1]..K[N]},ASC)表示先對陣列{K[1]...K[N]}作昇冪排列,然後返回K[i]所在位置的下標。For example: F(K[i], {K[1]..K[N]}, ASC) means that the array {K[1]...K[N]} is first ranked as an ascending power, and then K is returned. i] The subscript of the location.
F(K[i],{K[1]..K[N]},DESC)表示先對陣列{K[1]...K[N]}作降冪排列,然後返回K[i]所在位置的下標。F(K[i], {K[1]..K[N]}, DESC) means that the array {K[1]...K[N]} is firstly arranged in power, and then K[i] is returned. The subscript of the location.
步驟s503,Cache Client將各個參數按照選擇快取服務節點公式進行計算。In step s503, the Cache Client calculates each parameter according to the formula of the selected cache service node.
具體的,選擇快取服務節點公式為:Specifically, select the cache service node formula as:
Max(F(W[i],{W[1]...W[N]},ASC)*25%+F(C[i],{C[1]...C[N]},DESC)Max(F(W[i],{W[1]...W[N]}, ASC)*25%+F(C[i],{C[1]...C[N]}, DESC)
*25%+F(R[i],{R[1]...R[N]},DESC)*50%)。具體含義就是處理能力占25%權重(處理能力越大越好),儲存內容總量占25%權重(儲存內容越少越好),回應時間占50%權重(回應時間越短越好)。*25%+F(R[i], {R[1]...R[N]}, DESC)*50%). The specific meaning is that the processing power accounts for 25% of the weight (the greater the processing power, the better), the total amount of stored content accounts for 25% of the weight (the less the storage content is better), the response time accounts for 50% of the weight (the shorter the response time, the better).
步驟s504,Cache Client根據選擇快取服務節點公式的計算結果,選擇主用快取服務節點,獲取最後統計出來的值最大的快取服務節點作為所選擇的快取服務節點。Step s504: The Cache Client selects the active cache service node according to the calculation result of selecting the cache service node formula, and obtains the last cached service node with the largest value as the selected cache service node.
當集群中多個快取服務節點為Standby集群配置模式時,如圖6所示,該快取資料的處理方法的具體步驟為:步驟s601,快取客戶端在需要對快取資料進行操作時,向集群中指定的主用快取服務節點發送操作請求,其中主用快取服務節點的確定為以快取服務節點進入集群的先後順序為序,即集群中的快取服務節點按照進入集群的先後順序排列,排在第一位的即為集群中的主用快取服務節點;當該主用快取服務節點失效時,進入集群時間排在第二的快取服務節點變為主用快取服務節點;當失效的原主快取服務節點恢復時,將重新排列在集群中快取服務節點的最後。When multiple cache service nodes in the cluster are in the Standby cluster configuration mode, as shown in FIG. 6, the specific steps of the method for processing the cache data are: Step s601, when the cache client needs to operate on the cache data. And sending an operation request to the primary cache service node specified in the cluster, wherein the determination of the primary cache service node is in the order of the cache service node entering the cluster, that is, the cache service node in the cluster enters the cluster according to the order. The order of the first order is the primary cache service node in the cluster; when the primary cache service node fails, the cache service node that enters the second cluster time becomes the primary service. The cache service node; when the failed original primary cache service node recovers, it will be rearranged at the end of the cache service node in the cluster.
步驟s602,快取客戶端接收主用快取服務節點對該操作請求的操作結果。Step s602: The cache client receives an operation result of the operation request by the active cache service node.
當快取客戶端向主用快取服務節點發送操作快取資料的請求,主用快取服務節點執行操作快取資料的請求後,將操作結果發送給快取客戶端。When the cache client sends a request for operating the cache data to the active cache service node, the master cache service node performs a request for operating the cache data, and then sends the operation result to the cache client.
步驟s603,快取客戶端在主用快取服務節點執行操作失敗時,將主用快取服務節點標示為失效,選擇一備用快取服務節點並向該備用快取服務節點發送操作請求。In step s603, when the main cache service node fails to perform the operation, the cache client marks the primary cache service node as invalid, selects an alternate cache service node, and sends an operation request to the standby cache service node.
具體的,當主用快取服務節點執行操作失敗時,快取客戶端累計操作失敗次數;快取客戶端將失敗次數與閥值進行比較,當失敗次數超過閥值時,將主用快取服務節點標示為失效,並設定失效有效期。Specifically, when the main cache service node fails to perform the operation, the cache client accumulates the number of operation failures; the cache client compares the number of failures with the threshold, and when the number of failures exceeds the threshold, the cache is used for the main cache. The service node is marked as invalid and the expiration date is set.
快取客戶端根據獲取到的標示為失效的快取服務節點,獲取網路中可用的快取服務節點;快取客戶端在可用的快取服務節點中,根據哈希演算法或一致性哈希演算法選擇一快取服務節點作為備用快取服務節點。備用快取服務節點執行該操作快取資料請求並向快取客戶端發送該操作結果。The cache client obtains the cache service node available in the network according to the obtained cache service node marked as invalid; the cache client is in the available cache service node, according to the hash algorithm or consistency. The algorithm selects a cache service node as the alternate cache service node. The alternate cache service node performs the operation cache data request and sends the operation result to the cache client.
當根據該操作結果判斷該操作失敗時,快取客戶端將該備用快取服務節點標示失效,並重新選擇備用快取服務節點。When it is determined according to the operation result that the operation fails, the cache client invalidates the alternate cache service node identifier and reselects the alternate cache service node.
在Standby集群配置模式下,當主用快取服務節點失效,備用快取服務節點接替主用快取服務節點時,備用快取服務節點將永久替換原主用快取服務節點作為主用快取服務節點;當原主用快取服務節點恢復時,則作為當前主用快取服務節點的備用快取服務節點。並且,集群中的備用快取服務節點會定時地向當前的主用快取服務節點請求資料集,進行資料非同步同步,以保證集群中的所有快取服務節點資料的一致性。In the Standby cluster configuration mode, when the primary cache service node fails and the standby cache service node takes over the primary cache service node, the standby cache service node will permanently replace the original primary cache service node as the primary cache service. Node; when the original primary cache service node is restored, it acts as the alternate cache service node of the current primary cache service node. Moreover, the alternate cache service node in the cluster periodically requests the data set from the current active cache service node to perform asynchronous synchronization of the data to ensure the consistency of data of all the cache service nodes in the cluster.
本申請案的實施例中,為本申請案中的方法採用Active集群配置模式應用於對資料安全性要求高,讀寫比例均衡高發的系統。該網路中包括Application(第三方應用)、Cache Client、Cache Node A和Cache Node B。當需要使用快取機制的第三方,即第三方應用發送讀取或者操作快取資料請求,Cache Client根據動態負載分配演算法所選擇的執行操作快取資料的Cache Node A發生故障操作失敗時,Cache Client重新根據動態負載分配演算法選擇Cache Node B執行操作快取資料,並當Cache Node B操作成功時進行非同步處理。In the embodiment of the present application, the Active Cluster configuration mode is applied to the method in the present application to apply to a system with high data security requirements and a high read/write ratio. The network includes Application (third party application), Cache Client, Cache Node A, and Cache Node B. When a third party that needs to use the cache mechanism, that is, a third-party application sends a read or operation cache data request, the Cache Client fails to perform a failure operation according to the cache node A that performs the operation cache data selected by the dynamic load distribution algorithm. The Cache Client re-selects the Cache Node B to perform operation cache data according to the dynamic load distribution algorithm, and performs asynchronous processing when the Cache Node B operation succeeds.
具體的,如圖7所示,該快取資料的處理方法包括以下步驟:Specifically, as shown in FIG. 7, the processing method of the cache data includes the following steps:
步驟s701,第三方應用向Cache Client發送讀取或者操作快取資料請求。In step s701, the third-party application sends a read or operation cache request to the Cache Client.
步驟s702,Cache Client接收第三方應用發送的請求,確定可用的快取服務節點。In step s702, the Cache Client receives the request sent by the third-party application to determine the available cache service node.
集群中的快取服務節點如果處於失效狀態,會保存有失效標示。Cache Client檢查所有快取服務節點的狀態,根據是否標有失效標示來判斷快取服務節點是否可用,將沒有失效標示的快取服務節點確定為可用的快取服務節點。當Cache Client沒有檢查到可用的快取服務節點時,Cache Client向第三方應用發送出錯資訊;當Cache Client檢查到可用的快取服務節點時,則轉到步驟s703。If the cache service node in the cluster is in a failed state, a failure indication is saved. The Cache Client checks the status of all cache service nodes, determines whether the cache service node is available according to whether it is marked with a failure indication, and determines the cache service node without the invalidation identifier as the available cache service node. When the Cache Client does not check the available cache service node, the Cache Client sends an error message to the third-party application; when the Cache Client checks the available cache service node, it proceeds to step s703.
步驟s703,Cache Client選擇主用快取服務節點。In step s703, the Cache Client selects the active cache service node.
具體的,該步驟同步驟s401中的“根據演算法選擇一快取服務節點作為主用快取服務節點”相同。Specifically, the step is the same as "selecting a cache service node as the primary cache service node according to the algorithm" in step s401.
本流程中以Cache Client選擇了Cache Node A為例進行說明。In this procedure, the Cache Node A is selected by the Cache Client as an example.
步驟s704,當Cache Client選擇了Cache Node A時,則向Cache Node A發送操作快取資料請求。In step s704, when the Cache Client selects the Cache Node A, the operation cache data request is sent to the Cache Node A.
步驟s705,Cache Node A接收Cache Client發送的操作請求,操作快取資料。In step s705, the Cache Node A receives the operation request sent by the Cache Client, and operates the cache data.
步驟s706,當Cache Node A完成該操作請求時,返回操作結果給Cache Client。In step s706, when the Cache Node A completes the operation request, the operation result is returned to the Cache Client.
步驟s707,Cache Client根據返回的操作結果判斷該操作是否成功。In step s707, the Cache Client determines whether the operation is successful according to the returned operation result.
步驟s708,Cache Client根據該操作是否成功進行處理。In step s708, the Cache Client performs processing according to whether the operation is successful.
本流程中以該操作失敗為例進行說明。In this flow, the operation failure is taken as an example for description.
具體的,當該操作失敗時,由於可能存在其他原因(例如,網路連接故障)致使本次操作失敗,所以不直接標示Cache Node A失效,而是累加失敗次數到Cache Node A的失敗計數器,得到失敗次數n。失敗計數器設定有閥值N,當該失敗次數n大於閥值N時,該Cache Client將標示Cache Node A的狀態為失效。Specifically, when the operation fails, the operation may fail due to other reasons (for example, a network connection failure), so the Cache Node A failure is not directly indicated, but the failure counter is accumulated to the failure counter of the Cache Node A. Get the number of failures n. The failure counter is set with a threshold N. When the number of failures n is greater than the threshold N, the Cache Client will indicate that the state of the Cache Node A is invalid.
步驟s709,Cache Client接收第三方應用發送的請求,確定可用的備用快取服務節點。In step s709, the Cache Client receives the request sent by the third-party application to determine the available alternate cache service node.
集群中的快取服務節點如果處於失效狀態,會保存有失效標示。Cache Client根據獲取到的標示為失效的快取服務節點,獲取網路中可用的快取服務節點。當Cache Client沒有檢查到可用的快取服務節點時,Cache Client向第三方應用發送出錯資訊;當Cache Client檢查到可用的快取服務節點時,則轉到步驟s710。If the cache service node in the cluster is in a failed state, a failure indication is saved. The Cache Client obtains the cache service nodes available in the network according to the obtained cache service node marked as invalid. When the Cache Client does not check the available cache service node, the Cache Client sends an error message to the third-party application; when the Cache Client checks the available cache service node, it proceeds to step s710.
步驟s710,Cache Client從可用的快取服務節點中根據演算法選擇一快取服務節點作為備用快取服務節點,該演算法包括動態負載分配選擇演算法和哈希演算法或一致性哈希演算法。Step s710: The Cache Client selects a cache service node as an alternate cache service node from the available cache service nodes according to the algorithm, and the algorithm includes a dynamic load distribution selection algorithm and a hash algorithm or a consistent hash calculation. law.
本流程中以Cache Client選擇了Cache Node B為例進行說明。In this procedure, the Cache Node B is selected by the Cache Client as an example.
步驟s711,Cache Client向Cache Node B發送操作快取資料請求。In step s711, the Cache Client sends an operation cache data request to the Cache Node B.
步驟s712,Cache Node B接收Cache Client發送的操作請求,操作快取資料。In step s712, the Cache Node B receives the operation request sent by the Cache Client, and operates the cache data.
步驟s713,當Cache Node B完成該操作請求時,返回操作結果給Cache Client。In step s713, when the Cache Node B completes the operation request, the operation result is returned to the Cache Client.
步驟s714,Cache Client根據接收的操作結果判斷該操作是否成功。In step s714, the Cache Client determines whether the operation is successful according to the received operation result.
當該操作失敗時,則轉到步驟s709;當該操作成功時,則轉到步驟s715;步驟s715,Cache Client根據該操作結果進行處理。When the operation fails, go to step s709; when the operation is successful, go to step s715; in step s715, the Cache Client performs processing according to the operation result.
具體包括以下兩種情況的任一種:Specifically, it includes any of the following two situations:
(a)當該操作成功且為獲取操作時,如果需要快取,快取資料到Cache Client,並設定有效期,提高命中資料的訪問速度,並將該操作和操作結果保存到集群操作任務佇列。(a) When the operation is successful and the operation is fetched, if the cache is needed, cache the data to the Cache Client, set the validity period, increase the access speed of the hit data, and save the operation and operation result to the cluster operation task queue. .
(b)當該操作成功且為更新操作時,Cache Client將該操作和操作結果保存到集群操作任務佇列。(b) When the operation is successful and is an update operation, the Cache Client saves the operation and operation result to the cluster operation task queue.
步驟s716,Cache Client返回操作結果給第三方應用。In step s716, the Cache Client returns the operation result to the third-party application.
上述步驟s715中將該操作及操作結果保存到集群操作任務佇列後,採用非同步模式和佇列結合緒池的方式完成非同步處理的工作,包括非同步資料恢復和複製。After the operation and the operation result are saved in the cluster operation task queue in the above step s715, the asynchronous processing and the non-synchronous data recovery and copying are performed by using the asynchronous mode and the queue combination.
具體的,如圖8所示,該非同步處理的方法包括以下步驟:Specifically, as shown in FIG. 8, the method for asynchronous processing includes the following steps:
步驟s801,Cache Client記錄快取服務節點執行的獲取或更新操作到集群操作任務佇列。In step s801, the Cache Client records the acquisition or update operation performed by the cache service node to the queue operation task queue.
步驟s802,任務消費者向集群操作任務佇列發送輪詢檢查,查看是否有新的任務在佇列中。當查詢到有新的任務在佇列中,則轉到步驟s803。In step s802, the task consumer sends a polling check to the cluster operation task queue to check whether a new task is in the queue. When it is found that there is a new task in the queue, go to step s803.
步驟s803,任務消費者向任務執行緒池發送該任務。In step s803, the task consumer sends the task to the task thread pool.
步驟s804,集群操作任務佇列將該任務刪除。In step s804, the cluster operation task queue deletes the task.
步驟s805,任務執行緒池根據任務命令、任務目標和任務內容分析該任務,並根據分析結果創建任務執行緒。In step s805, the task thread pool analyzes the task according to the task command, the task target, and the task content, and creates a task thread according to the analysis result.
步驟s806,任務執行緒池執行快取服務節點非同步處理任務。In step s806, the task thread pool performs a cache processing node asynchronous processing task.
當該操作為獲取操作時,將該操作和操作內容恢復到集群中除去進行該操作的其他快取服務節點;當該操作為更新操作時,將該操作和操作內容複製到集群中除去進行該操作的其他快取服務節點;When the operation is a get operation, the operation and operation content are restored to the cluster to remove other cache service nodes that perform the operation; when the operation is an update operation, the operation and operation content are copied to the cluster to remove the Other cache service nodes that operate;
步驟s807,集群快取服務節點發送操作結果給任務執行緒池。In step s807, the cluster cache service node sends the operation result to the task thread pool.
步驟s808,任務執行緒池根據該操作結果判斷該任務是否執行成功並根據該判斷結果進行處理。In step s808, the task thread pool determines whether the task is successfully executed according to the operation result and performs processing according to the judgment result.
當該任務執行成功時,該任務結束;當該任務執行失敗時,對失敗任務進行處理,具體為以下任一種:When the task is successfully executed, the task ends; when the task fails to execute, the failed task is processed, specifically one of the following:
(a)簡單丟棄。(a) Simply discard.
(b)有限次重試。(b) Limited retry.
(c)任務固化到本地快取。(c) The task is solidified to the local cache.
本申請案的實施例中,為本申請案中的方法採用Standby集群配置模式應用於讀操作比例高,對資料同步要求不高,但可靠性要求高的系統。該網路中包括Application、Cache Client、Cache Node A和Cache Node A'。當主用快取服務節點Cache Node A未失效但執行操作失敗或主用快取服務節點Cache Node A失效時,Cache Client向備用快取服務節點Cache Node A'發出請求,Cache Node A'執行操作並自行同步資料。In the embodiment of the present application, the method in the present application adopts the Standby cluster configuration mode, which is applied to a system with a high proportion of read operations and low requirements for data synchronization, but high reliability requirements. The network includes Application, Cache Client, Cache Node A, and Cache Node A'. When the primary cache service node Cache Node A is not invalid but the execution operation fails or the primary cache service node Cache Node A fails, the Cache Client issues a request to the alternate cache service node Cache Node A', and the Cache Node A' performs the operation. And synchronize the data yourself.
具體的,如圖9所示,該快取資料的處理方法包括以下步驟:Specifically, as shown in FIG. 9, the processing method of the cache data includes the following steps:
步驟s901,第三方應用向發送Cache Client讀取或者操作快取資料請求。In step s901, the third-party application reads or operates the cache data request to the sending Cache Client.
步驟s902,Cache Client接收第三方應用發送的請求,檢查本地快取中主用快取服務節點Cache Node A的狀態,如果失效狀態已經超出時效,將失效標示清除。In step s902, the Cache Client receives the request sent by the third-party application, and checks the status of the Cache Node A of the primary cache service node in the local cache. If the invalidation status has expired, the invalidation flag is cleared.
當主用快取服務節點未失效時,轉到步驟s903;當主用快取服務節點失效時,轉到步驟s908;When the primary cache service node has not expired, go to step s903; when the primary cache service node fails, go to step s908;
步驟s903,Cache Client向Cache Node A發出操作快取資料請求。In step s903, the Cache Client sends an operation cache data request to the Cache Node A.
步驟s904,Cache Node A接收Cache Client發出操作快取資料請求,操作快取資料。In step s904, the Cache Node A receives the Cache Client to issue an operation cache data request, and operates the cache data.
步驟s905,當Cache Node A執行操作快取資料之後,返回操作結果給Cache Client。In step s905, after the Cache Node A executes the operation cache data, the operation result is returned to the Cache Client.
步驟s906,Cache Client根據返回的操作結果判斷該操作是否成功。In step s906, the Cache Client determines whether the operation is successful according to the returned operation result.
步驟s907,Cache Client根據該操作是否成功進行處理。In step s907, the Cache Client performs processing according to whether the operation is successful.
本流程以該操作失敗為例進行說明。This process uses the failure of this operation as an example.
由於可能存在其他原因(例如,網路連接故障)致使該操作失敗,所以不直接標示Cache Node A失效,而是累加失敗次數到Cache Node A的失敗計數器,得到失敗次數n。失敗計數器設定有閥值N,當該失敗次數n大於閥值N時,則將Cache Node A的狀態標示為失效,並設置失效有效期。Since the operation may fail due to other reasons (for example, a network connection failure), the Cache Node A failure is not directly indicated, but the failure counter is accumulated to the failure counter of the Cache Node A, and the number of failures n is obtained. The failure counter is set with a threshold N. When the number of failures n is greater than the threshold N, the state of the Cache Node A is marked as invalid, and the expiration date is set.
步驟s908,Cache Client從可用的快取服務節點中選擇其一作為備用快取服務節點。In step s908, the Cache Client selects one of the available cache service nodes as the alternate cache service node.
具體的,集群中的快取服務節點如果處於失效狀態,會保存有失效標示。Cache Client根據獲取到的標示為失效的快取服務節點,獲取網路中可用的快取服務節點並從中選擇其一作為備用快取服務節點。當Cache Client沒有檢查到可用的快取服務節點時,Cache Client向第三方應用發送出錯資訊。Specifically, if the cache service node in the cluster is in a failed state, a failure indication is saved. The Cache Client obtains the cache service node available in the network according to the obtained cache service node marked as invalid, and selects one of them as the backup cache service node. When the Cache Client does not check the available cache service node, the Cache Client sends an error message to the third-party application.
本流程以Cache Client選擇了備用快取服務節點Cache Node A'為例進行說明。This process uses the Cache Client to select the alternate cache service node Cache Node A' as an example.
步驟s909,Cache Client向備用快取服務節點Cache Node A'發出操作快取資料請求。In step s909, the Cache Client sends an operation cache data request to the alternate cache service node Cache Node A'.
步驟s910,Cache Node A'執行該操作。In step s910, the Cache Node A' performs the operation.
步驟s911,Cache Node A'返回操作結果給Cache Client。In step s911, the Cache Node A' returns the operation result to the Cache Client.
步驟s912,Cache Client根據接收的操作結果判斷該操作是否成功。In step s912, the Cache Client determines whether the operation is successful according to the received operation result.
當該操作失敗時,則轉到步驟s908;當該操作成功時,則轉到步驟s913。When the operation fails, go to step s908; when the operation is successful, go to step s913.
步驟s913,Cache Client返回操作結果給第三方應用。In step s913, the Cache Client returns the operation result to the third-party application.
步驟s914,備用快取服務節點Cache Node A'定時同步資料。In step s914, the alternate cache service node Cache Node A's timing synchronization data.
需要說明的是,此時備用快取服務節點接替原主用快取服務節點,為當前的主用快取服務節點,當原主用快取服務節點恢復時,成為當前主用快取服務節點的備用快取服務節點,所以Cache Node A將作為當前的備用快取服務節點向當前的主用快取服務節點Cache Node A'請求資料集,進行資料非同步同步。It should be noted that, at this time, the standby cache service node takes over the original active cache service node, which is the current active cache service node, and becomes the standby of the current active cache service node when the original primary cache service node is restored. The service node is cached, so Cache Node A will request the data set as the current alternate cache service node to the current primary cache service node Cache Node A' for data asynchronous synchronization.
具體的,備用快取服務節點Cache Node A'定時同步資料包括以下步驟:Specifically, the alternate cache service node Cache Node A' timing synchronization data includes the following steps:
(a)Cache Node A向Cache Node A'請求資料集;(a) Cache Node A requests a data set from Cache Node A';
(b)Cache Node A'返回請求的資料集結果給Cache Node A,Cache Node A完成與Cache Node A'的資料同步。(b) Cache Node A' returns the requested data set result to Cache Node A, and Cache Node A completes the data synchronization with Cache Node A'.
在Standby集群配置模式下,Cache Client對集群中的快取服務節點進行周期性心跳檢測,根據心跳檢測的結果定時更新標有失效標示和未標有失效標示快取服務節點的狀態。In the Standby cluster configuration mode, the Cache Client performs periodic heartbeat detection on the cache service node in the cluster, and periodically updates the state marked with the failure indication and the node marked with the failure indication cache according to the result of the heartbeat detection.
當快取服務節點標有失效標示時,快取客戶端對快取服務節點進行心跳檢測,當應答次數超過閥值時,快取客戶端將該快取服務節點的失效標示清除。具體的,如圖10所示,為Cache Client對標有失效標示的快取服務節點進行心跳檢測的具體步驟:本流程以對標有失效標示的Cache Node C為例進行說明。When the cache service node is marked with a failure indication, the cache client performs heartbeat detection on the cache service node. When the response times exceed the threshold, the cache client clears the failure indication of the cache service node. Specifically, as shown in FIG. 10, the Cache Client performs a specific step of performing heartbeat detection on the cache service node marked with a failure indication: this process uses an example of the Cache Node C marked with a failure indication as an example.
步驟s1001,Cache Client向Cache Node C發出周期性心跳檢測資料包。In step s1001, the Cache Client sends a periodic heartbeat detection packet to the Cache Node C.
步驟s1002,Cache Node C返回心跳檢測結果給Cache Client。In step s1002, the Cache Node C returns the heartbeat detection result to the Cache Client.
步驟s1003,Cache Client根據接收的心跳檢測結果,判斷Cache Node C是否對該資料包進行了應答。In step s1003, the Cache Client determines, according to the received heartbeat detection result, whether the Cache Node C responds to the data packet.
步驟s1004,如果Cache Node C對該資料包進行了應答,清除Cache Node C的失效標示。In step s1004, if the Cache Node C responds to the data packet, the Cache Node C invalidation flag is cleared.
當快取服務節點未標有失效標示時,快取客戶端對快取服務節點進行心跳檢測,當未應答次數超過閥值時,快取客戶端標示該快取服務節點失效。具體的,如圖11所示,為Cache Client對未標有失效標示的快取服務節點進行心跳檢測的具體步驟:本流程以對未標有失效標示的Cache Node D為例進行說明。When the cache service node is not marked with a failure indication, the cache client performs heartbeat detection on the cache service node. When the number of unanswered times exceeds the threshold, the cache client indicates that the cache service node is invalid. Specifically, as shown in FIG. 11 , a specific step for the Cache Client to perform heartbeat detection on a cache service node that is not marked with a failure indication is as follows: This process uses an example of a Cache Node D that is not marked with a failure indication.
步驟s1101,Cache Client向Cache Node D發出周期性心跳檢測資料包。In step s1101, the Cache Client sends a periodic heartbeat detection packet to the Cache Node D.
步驟s1102,Cache Node D返回心跳檢測結果給Cache Client。In step s1102, the Cache Node D returns the heartbeat detection result to the Cache Client.
步驟s1103,Cache Client根據接收心跳檢測結果,判斷Cache Node D是否對該資料包進行了應答。In step s1103, the Cache Client determines whether the Cache Node D responds to the data packet according to the received heartbeat detection result.
步驟s1104,如果Cache Node D未對該資料包進行應答,Cache Client累記失敗次數到Cache Node D的失敗計數器。In step s1104, if the Cache Node D does not respond to the data packet, the Cache Client accumulates the number of failures to the failure counter of the Cache Node D.
步驟s1105,當Cache C的失敗次數n大於閥值N,則更新Cache Node D的狀態,對Cache Node D進行失效標示。In step s1105, when the number n of failures of the Cache C is greater than the threshold N, the state of the Cache Node D is updated, and the Cache Node D is invalidated.
需要說明的是,當透過心跳檢測檢測到快取服務節點操作失敗與當快取服務節點接收操作快取請求操作失敗時,累計失敗次數到同一失敗計數器,失敗次數n為二者之和,與閥值N相比較。It should be noted that when the operation of the cache service node fails to be detected by the heartbeat detection and the operation of the cache service node receiving the operation cache request fails, the cumulative number of failures reaches the same failure counter, and the number of failures n is the sum of the two, The threshold N is compared.
本申請案實施例中還提供了一種快取資料的處理系統,其結構如圖12所示,包括:快取客戶端1201,用於向主用快取服務節點1202發送操作請求,並接收主用快取服務節點1202對該操作請求的操作結果;當根據接收的主用快取服務節點1202對該操作請求的操作結果判斷該操作失敗時,選擇一備用快取服務節點1203並向備用快取服務節點1203發送操作快取資料請求。The embodiment of the present application further provides a processing system for cache data, which is structured as shown in FIG. 12, and includes: a cache client 1201, configured to send an operation request to the main cache service node 1202, and receive the main request. The operation result of the operation request by the cache service node 1202; when it is determined that the operation fails according to the received operation result of the operation request by the primary cache service node 1202, an alternate cache service node 1203 is selected and is fast to the standby. The service node 1203 sends an operation cache request.
主用快取服務節點1202,用於接收快取客戶端1201發送的操作快取資料請求,並向快取客戶端1201返回操作結果。The active cache service node 1202 is configured to receive an operation cache data request sent by the cache client 1201, and return an operation result to the cache client 1201.
備用快取服務節點1203,當主用快取服務節點1202失效時,接收快取客戶端1201發送的操作請求。The alternate cache service node 1203 receives the operation request sent by the cache client 1201 when the primary cache service node 1202 fails.
上述主用快取服務節點1202和備用快取服務節點1203為Active集群配置模式時,集群中多個快取服務節點都處於工作狀態,當某一快取服務節點失效時,其他快取服務節點分擔請求;上述主用快取服務節點1202和備用快取服務節點1203為Standby集群配置模式時,集群中多個快取服務節點中只有一個快取服務節點作為主快取服務節點處於工作狀態,其他快取服務節點都處於備用狀態,當主用快取服務節點失效時,其他快取服務節點中的一個快取服務節點作為備用快取服務節點替換該主用快取服務節點,接收請求。When the active cache service node 1202 and the standby cache service node 1203 are in the active cluster configuration mode, multiple cache service nodes in the cluster are in a working state. When a cache service node fails, other cache service nodes are inactive. When the primary cache service node 1202 and the standby cache service node 1203 are in the Standby cluster configuration mode, only one of the plurality of cache service nodes in the cluster is in the working state as the primary cache service node. The other cache service nodes are in the standby state. When the primary cache service node fails, one of the other cache service nodes replaces the primary cache service node as the standby cache service node, and receives the request.
此外,當集群中多個快取服務節點能力不夠時,可以進行單節點動態擴容。In addition, when multiple cache service nodes in the cluster have insufficient capacity, dynamic expansion of single nodes can be performed.
如圖13所示,為本申請案實施例中的一種快取客戶端1300結構示意圖,包括:請求發送單元1301,用於在需要對快取資料進行操作時,向主用快取服務節點發送操作請求。As shown in FIG. 13 , a schematic structural diagram of a cache client 1300 in the embodiment of the present application includes: a request sending unit 1301, configured to send to the active cache service node when the cached data needs to be operated. Operation request.
結果接收單元1302,用於接收主用快取服務節點對請求發送單元發送的操作請求的操作結果。The result receiving unit 1302 is configured to receive an operation result of the operation request sent by the primary cache service node to the request sending unit.
快取服務節點選擇單元1303,用於當根據該結果接收單元接收的操作結果判斷所述主用快取服務節點執行操作失敗時,選擇一備用快取服務節點並由請求發送單元向備用快取服務節點發送操作請求。The cache service node selecting unit 1303 is configured to: when determining, according to the operation result received by the result receiving unit, that the main cache service node fails to perform an operation, select an alternate cache service node and request the sending unit to the standby cache The service node sends an operation request.
如圖14所示,為本申請案實施例中的一種Active集群配置模式下的快取客戶端1400的結構示意圖,包括:請求發送單元1401,用於在需要對快取資料進行操作時,向主用快取服務節點發送操作請求。As shown in FIG. 14, the schematic diagram of the configuration of the cache client 1400 in the active cluster configuration mode in the embodiment of the present application includes: a request sending unit 1401, when the operation of the cached data is required, The primary cache service node sends an operation request.
結果接收單元1402,用於接收主用快取服務節點對請求發送單元1401發送的操作請求的操作結果。The result receiving unit 1402 is configured to receive an operation result of the operation request sent by the primary cache service node to the request sending unit 1401.
失效標示單元1403,用於根據結果接收單元1402接收的操作結果判斷該操作失敗時,將主用快取服務節點標示為失效。The failure indication unit 1403 is configured to indicate that the primary cache service node is invalid when the operation fails according to the operation result received by the result receiving unit 1402.
失效標示單元1403具體包括:次數累計子單元14031,用於當主用快取服務節點執行操作失敗時,快取客戶端累計其失敗次數;失效標示子單元14032,用於將次數累計子單元14031累計的失敗次數與閥值進行比較,當失敗次數超過閥值時,將主用快取服務節點標示為失效。The failure indication unit 1403 specifically includes: a number accumulation sub-unit 14031, configured to: when the main cache service node performs an operation failure, the cache client accumulates the number of failures; the failure indication sub-unit 14032 is configured to accumulate the sub-unit 14031 The cumulative number of failures is compared to the threshold, and when the number of failures exceeds the threshold, the primary cache service node is marked as invalid.
失效有效期設定子單元10433,用於在該失效標示子單元14032將該主用快取服務節點標示為失效後,設定該主用快取服務節點的失效有效期。The expiration validity period setting sub-unit 10433 is configured to set the expiration validity period of the main cache service node after the failure flag sub-unit 14032 indicates that the main cache service node is invalid.
快取服務節點選擇單元1404,用於選擇備用快取服務節點並向備用快取服務節點發送操作請求。The cache service node selection unit 1404 is configured to select an alternate cache service node and send an operation request to the alternate cache service node.
快取服務節點選擇單元1404具體包括:可用快取服務節點獲取子單元14041,用於根據標示為失效的快取服務節點,獲取網路中可用的快取服務節點;快取服務節點選擇子單元14042,用於在可用快取服務節點獲取子單元14041獲取的可用的快取服務節點中,根據演算法選擇一快取服務節點作為備用快取服務節點,該演算法包括動態負載分配選擇演算法和哈希演算法或一致性哈希演算法。The cache service node selection unit 1404 specifically includes: an available cache service node acquisition subunit 14041, configured to acquire a cache service node available in the network according to the cache service node indicated as invalid; the cache service node selection subunit 14042. The available cache service node obtained by the available cache service node acquisition subunit 14041 selects a cache service node as a backup cache service node according to an algorithm, and the algorithm includes a dynamic load distribution selection algorithm. And a hash algorithm or a consistent hash algorithm.
快取服務節點選擇單元1404,還用於選擇主用快取服務節點並由請求發送單元1401向主用快取服務節點發送操作請求。The cache service node selection unit 1404 is further configured to select the primary cache service node and send an operation request to the primary cache service node by the request sending unit 1401.
上述請求發送單元1401,還用於在需要對快取資料進行操作時,向備用快取服務節點發送操作請求。The request sending unit 1401 is further configured to send an operation request to the standby cache service node when the cached data needs to be operated.
上述結果接收單元1402,還用於接收備用快取服務節點對請求發送單元1401發送的操作請求的操作結果。The result receiving unit 1402 is further configured to receive an operation result of the operation request sent by the requesting sending unit 1401 by the standby cache service node.
上述失效標示單元1403,還用於根據結果接收單元1402接收的操作結果判斷該操作失敗時,將備用快取服務節點標示為失效。The failure indication unit 1403 is further configured to: when the operation failure is determined according to the operation result received by the result receiving unit 1402, mark the standby cache service node as invalid.
快取客戶端1400還包括:操作結果處理單元1405,用於根據結果接收單元1402接收的備用快取服務節點對操作請求的操作結果進行處理。The cache client 1400 further includes an operation result processing unit 1405 for processing the operation result of the operation request according to the alternate cache service node received by the result receiving unit 1402.
操作結果處理單元1405還包括:非同步處理子單元14051,用於當根據快取客戶端的結果接收單元1402接收的操作結果判斷該操作成功時,快取客戶端對主用快取服務節點進行非同步處理。The operation result processing unit 1405 further includes: a non-synchronization processing sub-unit 14051, configured to perform a non-cache on the main cache service node when the operation is successful according to the operation result received by the result receiving unit 1402 of the cache client. Synchronous processing.
該非同步處理子單元14051具體用於:當該操作成功且為獲取操作時,快取客戶端將該操作結果快取到快取客戶端,並將該操作和操作結果保存到集群操作任務佇列並由任務執行緒池將該操作和操作內容恢復到集群中除去進行該操作的其他快取服務節點;當該操作成功且為更新操作時,快取客戶端將操作和操作結果保存到集群操作任務佇列並由任務執行緒池將該操作和操作內容複製到集群中除去進行該操作的其他快取服務節點。The non-synchronization processing sub-unit 14051 is specifically configured to: when the operation succeeds and is an acquisition operation, the cache client caches the operation result to the cache client, and saves the operation and the operation result to the cluster operation task queue. And the task thread pool restores the operation and operation content to the cluster and removes other cache service nodes that perform the operation; when the operation succeeds and is an update operation, the cache client saves the operation and operation result to the cluster operation. The task queues and copies the operations and operations from the task thread pool to the cluster to remove other cache service nodes that do the operation.
如圖15所示,為本申請案實施例中的一種Standby集群配置模式下的快取客戶端1500的結構示意圖,包括:請求發送單元1501,用於在需要對快取資料進行操作時,向主用快取服務節點發送操作請求。FIG. 15 is a schematic structural diagram of a cache client 1500 in a Standby cluster configuration mode according to an embodiment of the present application, including: a request sending unit 1501, configured to perform operations on cache data when The primary cache service node sends an operation request.
結果接收單元1502,用於接收主用快取服務節點對請求發送單元1501發送的操作請求的操作結果。The result receiving unit 1502 is configured to receive an operation result of the operation request sent by the primary cache service node to the request sending unit 1501.
失效標示單元1503,用於根據結果接收單元1502接收的操作結果判斷該操作失敗時,將主用快取服務節點標示為失效。The failure indication unit 1503 is configured to indicate that the primary cache service node is invalid when the operation fails according to the operation result received by the result receiving unit 1502.
失效標示單元1503具體包括:次數累計子單元15031,用於當主用快取服務節點執行操作失敗時,快取客戶端累計其失敗次數;失效標示子單元15032,用於將次數累計子單元15031累計的失敗次數與閥值進行比較,當失敗次數超過閥值時,將主用快取服務節點標示為失效。The failure indication unit 1503 specifically includes: a number accumulation subunit 15031, configured to: when the main cache service node performs an operation failure, the cache client accumulates the number of failures; the failure indication subunit 15032 is configured to use the number accumulation subunit 15031. The cumulative number of failures is compared to the threshold, and when the number of failures exceeds the threshold, the primary cache service node is marked as invalid.
失效有效期設定子單元15033,用於在該失效標示子單元15032將該主用快取服務節點標示為失效後,設定該主用快取服務節點的失效有效期。The expiration validity period setting sub-unit 15033 is configured to set an expiration validity period of the main cache service node after the failure flag sub-unit 15032 indicates that the main cache service node is invalid.
快取服務節點選擇單元1504,用於選擇備用快取服務節點並由請求發送單元1501向備用快取服務節點發送操作請求。The cache service node selection unit 1504 is configured to select an alternate cache service node and send an operation request to the alternate cache service node by the request sending unit 1501.
上述請求發送單元1501,還用於在需要對快取資料進行操作時,向備用快取服務節點發送操作請求。The request sending unit 1501 is further configured to send an operation request to the standby cache service node when the cached data needs to be operated.
上述結果接收單元1502還用於接收備用快取服務節點對請求發送單元1501發送的操作請求的操作結果。The result receiving unit 1502 is further configured to receive an operation result of the operation request sent by the requesting sending unit 1501 by the standby cache service node.
上述失效標示單元1503,還用於根據結果接收單元1502接收的操作結果判斷該操作失敗時,將備用快取服務節點標示為失效。The failure indication unit 1503 is further configured to: when the operation failure is determined according to the operation result received by the result receiving unit 1502, mark the standby cache service node as invalid.
快取客戶端1500還包括:操作結果處理單元1505,用於結果接收單元1502接收的備用快取服務節點對該操作請求的操作結果進行處理。The cache client 1500 further includes an operation result processing unit 1505, and the standby cache service node received by the result receiving unit 1502 processes the operation result of the operation request.
操作結果處理單元1505還包括:資料同步子單元15051,用於當根據快取客戶端的結果接收單元1502接收的操作結果判斷該操作成功時,快取客戶端對備用快取服務節點進行資料同步;快取客戶端1500還包括:心跳檢測單元1506,用於對主用快取服務節點和備用快取服務節點進行心跳檢測,並根據心跳檢測結果更新主用快取服務節點和/或備用快取服務節點的失效狀態。The operation result processing unit 1505 further includes: a data synchronization subunit 15051, configured to perform data synchronization on the alternate cache service node when the operation is successful according to the operation result received by the result receiving unit 1502 of the cache client; The cache client 1500 further includes: a heartbeat detecting unit 1506, configured to perform heartbeat detection on the primary cache service node and the standby cache service node, and update the primary cache service node and/or the standby cache according to the heartbeat detection result. The failure status of the service node.
為了描述的方便,以上所述Cache Client的各部分以功能分為各種模組分別描述。當然,在實施本申請案時可以把各模組的功能在同一個或多個軟體或硬體中實現。For the convenience of description, each part of the Cache Client described above is divided into various modules by functions. Of course, in the implementation of the present application, the functions of each module can be implemented in the same software or multiple hardware or hardware.
當上述實施例集群中多個快取服務節點能力不夠時,可以進行單節點動態擴容。對於集中式Cache來說,為了能夠提供擴展,Cache Node其實是一個虛擬的快取服務節點,由一些快取實例(Cache Instance)組成,具體的,如圖16所示。其中集群A由Cache Node A和Cache Node B組成,Cache Node A由Cache Instance 1,Cache Instance 2和Cache Instance 3構成,Cache NodeB由Cache Instance4,Cache Instance5和Cache Instance6構成。這些快取實例可以是在同一個伺服器上的也可以分佈在不同的伺服器上,這樣當快取服務節點能力不夠的時候,只需要增加虛擬快取服務節點中的快取實例,就能夠提高處理能力,同時不影響Cache Client的使用情況。When the capacity of multiple cache service nodes in the cluster in the above embodiment is insufficient, dynamic expansion of a single node can be performed. For a centralized Cache, in order to provide extensions, the Cache Node is actually a virtual cache service node, which is composed of cache Instances, as shown in Figure 16. Cluster A is composed of Cache Node A and Cache Node B. Cache Node A is composed of Cache Instance 1, Cache Instance 2 and Cache Instance 3. Cache NodeB is composed of Cache Instance4, Cache Instance5 and Cache Instance6. These cache instances can be on the same server or distributed on different servers, so when the cache service node is not enough, you only need to increase the cache instance in the virtual cache service node. Improve processing power without affecting the usage of the Cache Client.
但是當快取實例數目增加或者減少的時候,將會直接影響資料獲取演算法的命中,例如原來只有三個快取服務節點,那麽根據Key作Hash,然後得到Hash結果去對快取服務節點數取模,最終確定將內容存放到哪個實例,或者從哪個實例裏面獲得。當增加或者減少了Cache Node,那麽發現原先儲存的資料將無法正常獲取到。採取集群配置以後,可以透過兩種方式來進行資料遷移:1.Cache Client提供了資料遷移介面,可以將集群某一快取服務節點資料移動到其他快取服務節點。例如Cache Node A進行了擴容,那麽可以直接從Cache Node B上將資料遷移到Cache Node A,遷移過程透過Cache Client獲取Cache Node B的全部資料,然後按照新的演算法存入Cache Node A。2.自動緩慢遷移,當採用Active集群配置模式的時候,如果Cache Node A擴容以後,Cache Client無法取到資料,則立刻從集群其他快取服務節點獲取資料,獲得資料的話,則將資料按照新演算法保存到Cache Node A,這樣就會緩慢的將所有被存取的資料複製到Cache Node A上。However, when the number of cache instances increases or decreases, it will directly affect the hit of the data acquisition algorithm. For example, there are only three cache service nodes, then hash according to Key, and then get the hash result to the number of cache service nodes. Mice, and finally determine which instance to store the content to, or from which instance. When the Cache Node is added or decreased, it is found that the previously stored data will not be obtained normally. After the cluster configuration is adopted, data migration can be performed in two ways: 1. The Cache Client provides a data migration interface, which can move a cache service node data of the cluster to other cache service nodes. For example, if the Cache Node A is expanded, the data can be directly migrated from the Cache Node B to the Cache Node A. The migration process obtains all the data of the Cache Node B through the Cache Client, and then deposits the Cache Node A according to the new algorithm. 2. Automatically and slowly migrate. When the Active Cluster configuration mode is adopted, if the Cache Client cannot obtain the data after the Cache Node A is expanded, the data will be obtained from other cache service nodes in the cluster. If the data is obtained, the data will be updated according to the new one. The algorithm is saved to Cache Node A, which will slowly copy all the accessed data to Cache Node A.
為了描述的方便,以上所述一種快取資料的處理系統的各部分以功能分為各種模組分別描述。當然,在實施本申請案時可以把各模組的功能在同一個或多個軟體或硬體中實現。For convenience of description, each part of the processing system of the cache data described above is divided into various modules by function. Of course, in the implementation of the present application, the functions of each module can be implemented in the same software or multiple hardware or hardware.
本申請案包括以下優點,因為採用了集群配置模式,當主快取服務節點失效時選擇備用快取服務節點來執行操作,從而解決快取服務節點失效引起的資料丟失和快取服務節點不可用的問題,達到了提高系統可靠性和可用性的效果。當然,實施本申請案的任一產品並不一定需要同時達到以上所述的所有優點。The present application includes the following advantages, because the cluster configuration mode is adopted, when the primary cache service node fails, the standby cache service node is selected to perform operations, thereby solving the data loss caused by the failure of the cache service node and the cache service node being unavailable. The problem is achieved by improving system reliability and availability. Of course, implementing any of the products of the present application does not necessarily require all of the advantages described above to be achieved at the same time.
透過以上的實施方式的描述,本領域的技術人員可以清楚地瞭解到本申請案可借助軟體加必需的通用硬體平臺的方式來實現,當然也可以透過硬體,但很多情況下前者是更佳的實施方式。基於這樣的理解,本申請案的技術方案本質上或者說對現有技術做出貢獻的部分可以以軟體產品的形式體現出來,該電腦軟體產品儲存在一個儲存介質中,包括若干指令用以使得一個終端設備(可以是手機,個人電腦,伺服器,或者網路設備等)執行本申請案各個實施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of a software plus a necessary universal hardware platform, and of course, can also be through hardware, but in many cases, the former is more Good implementation. Based on such understanding, the technical solution of the present application may be embodied in the form of a software product in essence or in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for making one The terminal device (which may be a cell phone, a personal computer, a server, or a network device, etc.) performs the methods described in various embodiments of the present application.
本領域技術人員可以理解附圖只是一個較佳實施例的示意圖,附圖中的模組或流程並不一定是實施本申請案所必須的。A person skilled in the art can understand that the drawings are only a schematic diagram of a preferred embodiment, and the modules or processes in the drawings are not necessarily required to implement the present application.
以上所述僅是本申請案的較佳實施方式,應當指出,對於本技術領域的普通技術人員來說,在不脫離本申請案原理的前提下,還可以做出若干改進和潤飾,這些改進和潤飾也應視為本申請案的保護範圍。The above description is only a preferred embodiment of the present application, and it should be noted that those skilled in the art can make several improvements and refinements without departing from the principles of the present application. And retouching should also be considered as the scope of protection of this application.
1201...快取客戶端1201. . . Cache client
1202...主用快取服務節點1202. . . Primary cache service node
1203...備用快取服務節點1203. . . Alternate cache service node
1300...快取客戶端1300. . . Cache client
1301...請求發送單元1301. . . Request sending unit
1302...結果接收單元1302. . . Result receiving unit
1303...快取服務節點選擇單元1303. . . Cache service node selection unit
1400...快取客戶端1400. . . Cache client
1401...請求發送單元1401. . . Request sending unit
1402...結果接收單元1402. . . Result receiving unit
1403...失效標示單元1403. . . Failure indicator unit
14031...次數累計子單元14031. . . Cumulative subunit
14032...失效標示子單元14032. . . Failure flag subunit
14033...失效有效期設定子單元14033. . . Expiration validity period setting subunit
1404...快取服務節點選擇單元1404. . . Cache service node selection unit
14041...可用快取服務節點獲取子單元14041. . . The sub-unit can be obtained by the cache service node.
14042...快取服務節點選擇子單元14042. . . Cache service node selection subunit
1405...操作結果處理單元1405. . . Operation result processing unit
14051...非同步處理子單元14051. . . Asynchronous processing subunit
1500...快取客戶端1500. . . Cache client
1501...請求發送單元1501. . . Request sending unit
1502...結果接收單元1502. . . Result receiving unit
1503...失效標示單元1503. . . Failure indicator unit
15031...次數累計子單元15031. . . Cumulative subunit
15032...失效標示子單元15032. . . Failure flag subunit
15033...失效有效期設定子單元15033. . . Expiration validity period setting subunit
1504...快取服務節點選擇單元1504. . . Cache service node selection unit
1505...操作結果處理單元1505. . . Operation result processing unit
15051...資料同步子單元15051. . . Data synchronization subunit
1506...心跳檢測單元1506. . . Heartbeat detection unit
為了更清楚地說明本申請案或現有技術中的技術方案,下面將對本申請案或現有技術描述中所需要使用的附圖作簡單的介紹,顯而易見地,下面描述中的附圖僅僅是本申請案的一些實施例,對於本領域普通技術人員來講,在不付出創造性勞動的前提下,還可以根據這些附圖獲得其他的附圖。In order to more clearly illustrate the present application or the technical solutions in the prior art, the drawings to be used in the present application or the prior art description will be briefly described below. Obviously, the drawings in the following description are only the present application. For some embodiments of the present invention, other drawings may be obtained from those skilled in the art without departing from the drawings.
圖1為現有技術中的一種服務端分散式的分散式快取結構示意圖;1 is a schematic diagram of a distributed decentralized cache structure of a server in the prior art;
圖2為現有技術中的一種客戶端分散式的分散式快取結構示意圖;2 is a schematic diagram of a distributed decentralized cache structure of a client in the prior art;
圖3為本申請案實施例中的一種快取資料方法流程圖;FIG. 3 is a flowchart of a method for cache data according to an embodiment of the present application;
圖4為本申請案實施例中的一種Active集群配置模式下的快取資料處理方法流程圖;4 is a flowchart of a method for processing cache data in an Active Cluster configuration mode according to an embodiment of the present application;
圖5為本申請案實施例中的一種動態負載分配選擇演算法的流程圖;FIG. 5 is a flowchart of a dynamic load distribution selection algorithm in an embodiment of the present application; FIG.
圖6為本申請案實施例中的一種Standby集群配置模式下的快取資料處理方法流程圖;6 is a flowchart of a method for processing cache data in a Standby cluster configuration mode according to an embodiment of the present application;
圖7為本申請案實施例中的一種Active集群配置模式下的快取資料處理方法流程圖;FIG. 7 is a flowchart of a method for processing cache data in an Active Cluster configuration mode according to an embodiment of the present application;
圖8為本申請案實施例中的一種Active集群配置模式下的非同步處理的方法流程圖;FIG. 8 is a flowchart of a method for asynchronous processing in an Active Cluster configuration mode according to an embodiment of the present application;
圖9為本申請案實施例中的一種Standby集群配置模式下的快取資料方法流程圖;FIG. 9 is a flowchart of a method for cache data in a Standby cluster configuration mode according to an embodiment of the present application;
圖10為本申請案實施例中的一種Standby集群配置模式下的心跳檢測方法流程圖;10 is a flowchart of a heartbeat detection method in a Standby cluster configuration mode according to an embodiment of the present application;
圖11為本申請案實施例中的一種Standby集群配置模式下的心跳檢測方法流程圖;11 is a flowchart of a heartbeat detection method in a Standby cluster configuration mode according to an embodiment of the present application;
圖12為本申請案實施例中的一種快取資料處理系統的結構示意圖;12 is a schematic structural diagram of a cache data processing system in an embodiment of the present application;
圖13為本申請案實施例中的一種快取客戶端的結構示意圖;FIG. 13 is a schematic structural diagram of a cache client according to an embodiment of the present application;
圖14為本申請案實施例中的一種Active集群配置模式下的快取客戶端的結構示意圖;14 is a schematic structural diagram of a cache client in an Active Cluster configuration mode according to an embodiment of the present application;
圖15為本申請案實施例中的一種Standby集群配置模式下的快取客戶端的結構示意圖;15 is a schematic structural diagram of a cache client in a Standby cluster configuration mode according to an embodiment of the present application;
圖16為本申請案實施例中的一種集群結構示意圖;16 is a schematic structural diagram of a cluster in an embodiment of the present application;
Claims (16)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW099100278A TWI484335B (en) | 2010-01-07 | 2010-01-07 | Cached data processing method, processing system, and means |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW099100278A TWI484335B (en) | 2010-01-07 | 2010-01-07 | Cached data processing method, processing system, and means |
Publications (2)
Publication Number | Publication Date |
---|---|
TW201124842A TW201124842A (en) | 2011-07-16 |
TWI484335B true TWI484335B (en) | 2015-05-11 |
Family
ID=45047237
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW099100278A TWI484335B (en) | 2010-01-07 | 2010-01-07 | Cached data processing method, processing system, and means |
Country Status (1)
Country | Link |
---|---|
TW (1) | TWI484335B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104583942B (en) * | 2012-06-15 | 2018-02-13 | 英特尔公司 | Based on lock and based on synchronization the method for out of order loading |
EP2862068B1 (en) | 2012-06-15 | 2022-07-06 | Intel Corporation | Reordered speculative instruction sequences with a disambiguation-free out of order load store queue |
EP2862061A4 (en) | 2012-06-15 | 2016-12-21 | Soft Machines Inc | A virtual load store queue having a dynamic dispatch window with a unified structure |
EP2862069A4 (en) | 2012-06-15 | 2016-12-28 | Soft Machines Inc | An instruction definition to implement load store reordering and optimization |
CN104823168B (en) | 2012-06-15 | 2018-11-09 | 英特尔公司 | The method and system restored in prediction/mistake is omitted in predictive forwarding caused by for realizing from being resequenced by load store and optimizing |
KR101818967B1 (en) | 2012-06-15 | 2018-01-16 | 인텔 코포레이션 | A disambiguation-free out of order load store queue |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW508505B (en) * | 2000-07-14 | 2002-11-01 | Ibm | Non-disruptive migration of coordinator services in a distributed computer system |
TW200602895A (en) * | 2004-03-04 | 2006-01-16 | Ibm | Event ownership assigner with failover for multiple event server system |
US20080172679A1 (en) * | 2007-01-11 | 2008-07-17 | Jinmei Shen | Managing Client-Server Requests/Responses for Failover Memory Managment in High-Availability Systems |
TW200907719A (en) * | 2007-06-22 | 2009-02-16 | Microsoft Corp | Server-assisted and peer-to-peer synchronization |
-
2010
- 2010-01-07 TW TW099100278A patent/TWI484335B/en active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW508505B (en) * | 2000-07-14 | 2002-11-01 | Ibm | Non-disruptive migration of coordinator services in a distributed computer system |
TW200602895A (en) * | 2004-03-04 | 2006-01-16 | Ibm | Event ownership assigner with failover for multiple event server system |
US20080172679A1 (en) * | 2007-01-11 | 2008-07-17 | Jinmei Shen | Managing Client-Server Requests/Responses for Failover Memory Managment in High-Availability Systems |
TW200907719A (en) * | 2007-06-22 | 2009-02-16 | Microsoft Corp | Server-assisted and peer-to-peer synchronization |
Also Published As
Publication number | Publication date |
---|---|
TW201124842A (en) | 2011-07-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20200358848A1 (en) | Methods, systems, and media for providing distributed database access during a network split | |
CN101562543B (en) | Cache data processing method and processing system and device thereof | |
US9395933B2 (en) | Distributed storage system, distributed storage method, and program and storage node for distributed storage | |
JP6404907B2 (en) | Efficient read replica | |
US10530855B2 (en) | Lock state synchronization for non-disruptive persistent operation | |
CN103268318B (en) | A kind of distributed key value database system of strong consistency and reading/writing method thereof | |
US9152501B2 (en) | Write performance in fault-tolerant clustered storage systems | |
US8812897B1 (en) | Locality based quorums | |
WO2017113276A1 (en) | Data reconstruction method, apparatus and system in distributed storage system | |
TWI484335B (en) | Cached data processing method, processing system, and means | |
CN105493474B (en) | System and method for supporting partition level logging for synchronizing data in a distributed data grid | |
US10831741B2 (en) | Log-shipping data replication with early log record fetching | |
CN111274310A (en) | Distributed data caching method and system | |
WO2021129477A1 (en) | Data synchronization method and related device | |
CN113010496B (en) | Data migration method, device, equipment and storage medium | |
JP4671399B2 (en) | Data processing system | |
US10452680B1 (en) | Catch-up replication with log peer | |
CN113901024A (en) | Data storage system, data storage method, readable medium, and electronic device | |
WO2015088813A1 (en) | Elastic data metadata compression in a distributed data grid | |
Guo et al. | Distributedlog: A high performance replicated log service | |
CN110807039A (en) | Data consistency maintenance system and method in cloud computing environment | |
CN109726211B (en) | Distributed time sequence database | |
EP4198701A1 (en) | Active-active storage system and data processing method based on same | |
WO2019109209A1 (en) | Data replacement method for memory, server node, and data storage system | |
Afonso | Mechanisms for providing causal consistency on edge computing |