匯出 (0) 列印
全部展開

角色中快取疑難排解和診斷 (Azure 快取)

更新日期: 2010年7月

note附註
如需為應用程式選擇正確 Azure 快取提供項目的相關指引,請參閱 Azure 快取常見問題集

角色中快取 應用程式已針對使用診斷層級收集診斷資料進行設定。此診斷層級提供一項可用於設定資料收集層級的設定。本主題提供疑難排解步驟和診斷的概觀,協助進行 角色中快取 應用程式的疑難排解。

在 上執行的應用程式是四處分散且具有多重執行個體的應用程式,偵錯很困難。需要有標準以上的工具和方法才能疑難排解這類應用程式。 應用程式的疑難排解超出本主題的範疇,如需詳細資訊,請參閱在 Azure 中疑難排解在 Azure 中診斷和偵錯。這些主題會討論經過證實的疑難排解作法,也包含深入資訊和最佳作法的連結。如需以下內容的詳細資訊 檢視收集的診斷資料,請參閱在 Azure 儲存體中儲存和檢視診斷資料

設定 角色中快取 應用程式以收集用於疑難排解的診斷資料時,必須在角色啟動期間設定診斷層級及設定快取診斷。本主題提供下列步驟的概觀,協助進行 角色中快取 應用程式的疑難排解。

角色中快取 提供五個診斷層級,可用於設定診斷資料收集量。診斷層級範圍由 0 到 4,而數字表示針對快取伺服器和用戶端所收集的診斷資訊數量。每個診斷層級都包含一組預先設定的效能計數器、事件記錄檔、追蹤和損毀傾印設定,可用來監控 角色中快取 應用程式的健康情況。

 

診斷層級 收集的診斷資料

0

僅限非常重大/嚴重的伺服器記錄檔。

1

有助於評估使用模式、快取系統健康情況及任何潛在錯誤的診斷資料。這是預設組態層級。

2

所有要求和重要系統資訊的精細診斷資料。

3

包含更多詳細資訊和系統資訊的診斷資料。

4

所有要求和系統資訊的最高詳細程度記錄檔。

對應於快取用戶端和快取伺服器診斷的快取診斷層級有兩種。DiagnosticLevel 代表快取伺服器診斷,而 ClientDiagnosticLevel 代表快取用戶端診斷。每一個層級都會設定一組不同的效能計數器、記錄檔、追蹤和損毀傾印設定。這些診斷層級會設定於應用程式的 ServiceConfiguration.cscfg 檔案中,只需部署更新後的 ServiceConfiguration.cscfg 檔案,即可針對執行中的雲端應用程式進行變更。

快取叢集的快取伺服器診斷層級會在 ServiceConfiguration.cscfg 檔案中指定,該檔案位於主控快取叢集之角色的組態中。若已在角色的 [Caching] 索引標籤中啟用快取,此設定是由 Visual Studio 新增,而當 Cache Worker Role 新增至專案後,此設定早已存在。預設 DiagnosticLevel 為 1,如果角色沒有 DiagnosticLevel,則使用的 DiagnosticLevel 為 1。若要變更 DiagnosticLevel,請在 ServiceConfiguration.cscfg 中修改角色的 DiagnosticLevel 設定。下列範例是 ServiceConfiguration.cscfg 檔案中的 WorkerRole1 區段,其 DiagnosticLevel 為 1。

<Role name="WorkerRole1">
  <Instances count="1" />
  <ConfigurationSettings>
    <!-- Other settings omitted for clarity... -->
    <Setting name="Microsoft.WindowsAzure.Plugins.Caching.DiagnosticLevel" value="1" />
  </ConfigurationSettings>
</Role>

下表列出針對各診斷層級收集的診斷資料。

 

DiagnosticLevel 收集的資料

0

  • 記錄等級:Critical

  • 沒有效能計數器

  • 未登錄事件記錄檔

  • 迷你損毀傾印

1

2

  • 記錄等級:Information

  • 伺服器診斷層級 2 效能計數器

  • 除了診斷層級 1 的事件記錄檔外,已登錄下列事件記錄檔

    • Azure!*

    • Microsoft-Windows-Application Server-System Services/Admin!*

    • Microsoft-Windows-Application Server-System Services/Operational!*

  • 完整損毀傾印

3

4

note附註
在 模擬器中執行 角色中快取 應用程式時,即使有多個角色執行個體,仍然會在 *_IN_0 資料夾之下追蹤所有角色執行個體。這是原廠行為。當在 中主控 角色中快取 應用程式時,針對每個角色執行個體的追蹤都會分別位於角色執行個體的資料夾中。

快取用戶端的 ClientDiagnosticLevel 層級會於 ServiceConfiguration.cscfg 檔案中指定,該檔案位於角色 (也就是快取用戶端) 的組態中。若已將角色設定成作為快取用戶端,此設定則是由 角色中快取 NuGet 封裝新增。

note附註
使用 如需以下內容的詳細資訊 NuGet 封裝設定 角色中快取 快取用戶端,請參閱Configure a Project for Caching on Roles

預設 ClientDiagnosticLevel 為 1,如果角色沒有 ClientDiagnosticLevel,則使用的 ClientDiagnosticLevel 為 1。若要變更 ClientDiagnosticLevel,請在 ServiceConfiguration.cscfg 中修改角色的 ClientDiagnosticLevel 設定。下列範例是 ServiceConfiguration.cscfg 檔案中的 WebRole1 區段,其 ClientDiagnosticLevel 為 1。

<Role name="WebRole1">
  <Instances count="1" />
  <ConfigurationSettings>
    <!-- Other settings omitted for clarity... -->
    <Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" value="1" />
  </ConfigurationSettings>
</Role>

下表列出針對各用戶端診斷層級收集的診斷資料。

note附註
用戶端診斷層級的損毀傾印設定僅與使用 Memcached 用戶端填充碼的快取用戶端相關。不會收集非 Memcache 用戶端的損毀傾印。如需以下內容的詳細資訊 Memcached 用戶端填充碼,請參閱 Azure 快取的 Memcached 包裝函式

 

ClientDiagnosticLevel 收集的資料

0

  • 記錄等級:Critical

  • 沒有效能計數器

  • 未登錄事件記錄檔

  • 迷你損毀傾印

1

2

3

4

note附註
在 模擬器中執行 角色中快取 應用程式時,即使有多個角色執行個體,仍然會在 *_IN_0 資料夾之下追蹤所有角色執行個體。這是原廠行為。當在 中主控 角色中快取 應用程式時,針對每個角色執行個體的追蹤都會分別位於角色執行個體的資料夾中。

若要開始收集快取診斷資料,則必須在角色啟動期間叫用下列程式碼。此代碼必須新增至快取用戶端或快取伺服器的每個角色,以便快取要收集的診斷資料。角色 OnStart 覆寫區是一個可裝載此程式碼的方便位置 (如下列範例所示)。

public override bool OnStart()
{
    DiagnosticMonitorConfiguration dmConfig = 
        DiagnosticMonitor.GetDefaultInitialConfiguration();

    // Configure the collection of cache diagnostic data.
    CacheDiagnostics.ConfigureDiagnostics(dmConfig);

    DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", 
        dmConfig);

    return base.OnStart();
}

ConfigureDiagnostics 方法會設定快取診斷資料收集。如果未呼叫此方法,則不會收集快取診斷資料。若要使用 CacheDiagnostics 類別,請新增 Microsoft.ApplicationServer.Caching.AzureCommon.dll (位於 C:\Program Files\Microsoft SDKs\Azure\.NET SDK\2012-10\ref\Caching) 的參考,以及新增下列 using (或 Imports) 陳述式。

using Microsoft.ApplicationServer.Caching.AzureCommon;
note附註
若已使用 角色中快取 NuGet 封裝將角色設為快取用戶端,則可以新增 Microsoft.ApplicationServer.Caching.AzureCommon.dll 組件參照。

如果將快取新增至現有角色且診斷組態程式碼早已存在,您即可在呼叫 Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.Start 之前,將對 ConfigureDiagnostics 的呼叫新增至現有的診斷啟動程式碼。

Warning警告
角色中快取 應用程式中的診斷資料收集需要呼叫 ConfigureDiagnosticsMicrosoft.WindowsAzure.Diagnostics.DiagnosticMonitor.Start。若這兩種方法均未在啟動角色期間呼叫,則不會收集快取診斷資料。

下列幾節包含各伺服器和用戶端診斷層級內含的效能計數器清單。角色中快取 和 效能計數器都會包含在內。如需具備 角色中快取 效能計數器說明的完整清單,請參閱 監控角色中快取 (Azure 快取)。如需以下內容的詳細資訊 效能計數器,請參閱Performance Counters in the .NET Framework

DiagnosticLevel 1 包含下列效能計數器。

  • \Azure Caching:Host\Average Secondary Response Time / operation Microsecond

  • \Azure Caching:Host\Total Data Size Bytes

  • \Azure Caching:Host\Total Client Requests

  • \Azure Caching:Host\Total Read Requests

  • \Azure Caching:Host\Total Object Count

  • \Azure Caching:Host\Total Failure Exceptions

  • \Memory\Available MBytes

  • \Process(CacheService)\Page Faults/sec

    • 在 模擬器中執行時,計數器名稱為 \Process(CacheServiceEmulator)\Page Faults/sec

  • \Processor(_Total)\% Processor Time

  • \.NET CLR Memory(_Global_)\% Time in GC

DiagnosticLevel 2 包含下列效能計數器。

  • \Azure Caching:Host\Average Secondary Response Time / operation Microsecond

  • \Azure Caching:Host\Total Data Size Bytes

  • \Azure Caching:Host\Total Client Requests

  • \Azure Caching:Host\Total Read Requests

  • \Azure Caching:Host\Total Object Count

  • \Azure Caching:Host\Total Failure Exceptions

  • \Processor(_Total)\% Processor Time

  • \.NET CLR Memory(_Global_)\% Time in GC

  • \Azure Caching:Host\Total Read Requests /sec

  • \Azure Caching:Host\Cache Miss Percentage

  • \Azure Caching:Host\Total Primary Data Size Bytes

  • \Azure Caching:Host\Total Allocated Directory Count

  • \Azure Caching:Host\Available Cache Item Percentage

  • \Azure Caching:Host\Total Available Cache Item Count

  • \Azure Caching:Host\Total Notification Delivered

  • \Azure Caching:Host\Total Eviction Runs

  • \Azure Caching:Host\Total Memory Evicted

  • \Azure Caching:Host\Total Evicted Objects

  • \Azure Caching:Host\Total Expired Objects

  • \Azure Caching:Host\Total Requests Served

  • \Azure Caching:Host\Total Write Operations

  • \.NET CLR LocksAndThreads(*)\Contention Rate / sec

  • \.NET CLR Memory(*)\% Time in GC

  • \.NET CLR Memory(*)\Gen 0 heap size

  • \.NET CLR Memory(*)\Gen 1 heap size

  • \.NET CLR Memory(*)\Gen 2 heap size

  • \.NET CLR Memory(*)\Large Object Heap size

  • \Memory\Available MBytes

  • \Process(CacheService)\Page Faults/sec

    • 在 模擬器中執行時,計數器名稱為 \Process(CacheServiceEmulator)\Page Faults/sec

  • \Process(*)\Thread Count

  • \Process(*)\Working Set

  • \Process(*)\Virtual Bytes

  • \Process(*)\Elapsed Time

  • \Process(*)\Page Faults/sec

  • \Network Interface(*)\Current Bandwidth

  • \Network Interface(*)\Bytes Total/sec

  • \Azure Caching:Host\Total Connections Count

  • \Azure Caching:Host\Average Quorum Response Time / operation Microsecond

  • \Azure Caching:Host\Total Client Requests /sec

  • \Azure Caching:Host\Total Notification Delivered

  • \Azure Caching:Host\Total Get Misses

  • \Azure Caching:Host\Total Write Operations /sec

DiagnosticLevel 3 和 DiagnosticLevel 4 包含下列效能計數器。

  • \.NET CLR LocksAndThreads(*)\Contention Rate / sec

  • \.NET CLR LocksAndThreads(*)\Current Queue Length

  • \.NET CLR Memory(*)\# Bytes in all Heaps

  • \.NET CLR Memory(*)\# Gen 0 Collections

  • \.NET CLR Memory(*)\# Gen 1 Collections

  • \.NET CLR Memory(*)\# Gen 2 Collections

  • \.NET CLR Memory(*)\% Time in GC

  • \.NET CLR Memory(*)\Gen 0 heap size

  • \.NET CLR Memory(*)\Gen 1 heap size

  • \.NET CLR Memory(*)\Gen 2 heap size

  • \.NET CLR Memory(*)\Large Object Heap size

  • \.NET CLR Exceptions(*)\# of Exceps Thrown

  • \Memory\Available MBytes

  • \Memory\Page Faults/sec

  • \PhysicalDisk(_Total)\% Idle Time

  • \PhysicalDisk(_Total)\Avg.Disk Queue Length

  • \Processor(_Total)\% Privileged Time

  • \Processor(_Total)\% Processor Time

  • \System\Context Switches/sec

  • \System\Processor Queue Length

  • \Process(*)\% Processor Time

  • \Process(*)\Handle Count

  • \Process(*)\Private Bytes

  • \Process(*)\Thread Count

  • \Process(*)\Working Set

  • \Process(*)\Virtual Bytes

  • \Process(*)\Elapsed Time

  • \Process(*)\Page Faults/sec

  • \Process(CacheService)\Page Faults/sec

    • 在 模擬器中執行時,計數器名稱為 \Process(CacheServiceEmulator)\Page Faults/sec

  • \Network Interface(*)\Current Bandwidth

  • \Network Interface(*)\Packets/sec

  • \Network Interface(*)\Bytes Sent/sec

  • \Network Interface(*)\Bytes Received/sec

  • \Network Interface(*)\Bytes Total/sec

  • \System\System Up Time

  • \Azure Caching:Host\Available Cache Item Percentage

  • \Azure Caching:Host\Total Connections Count

  • \Azure Caching:Host\Available Directory Percentage

  • \Azure Caching:Host\Available Memory Percentage

  • \Azure Caching:Host\Average Quorum Response Time / operation Microsecond

  • \Azure Caching:Host\Average Secondary Response Time / operation Microsecond

  • \Azure Caching:Host\Cache Miss Percentage

  • \Azure Caching:Host\Gateway Process Time

  • \Azure Caching:Host\Gateway Failure Percentage

  • \Azure Caching:Host\Request Processing Error Percentage

  • \Azure Caching:Host\Total Allocated Cache Item Count

  • \Azure Caching:Host\Total Allocated Directory Count

  • \Azure Caching:Host\Total Available Cache Item Count

  • \Azure Caching:Host\Total Available Directory Count

  • \Azure Caching:Host\Total Available Memory Bytes

  • \Azure Caching:Host\Total Cache Misses

  • \Azure Caching:Host\Total Cache Misses /sec

  • \Azure Caching:Host\Total Client Requests

  • \Azure Caching:Host\Total Client Requests /sec

  • \Azure Caching:Host\Total Data Size Bytes

  • \Azure Caching:Host\Total Evicted Objects

  • \Azure Caching:Host\Total Eviction Runs

  • \Azure Caching:Host\Total Expired Objects

  • \Azure Caching:Host\Total Failure Exceptions

  • \Azure Caching:Host\Total Failure Exceptions /sec

  • \Azure Caching:Host\Total Memory Evicted

  • \Azure Caching:Host\Total Notification Delivered

  • \Azure Caching:Host\Total Notification Delivered /sec

  • \Azure Caching:Host\Total Notification Poll Requests

  • \Azure Caching:Host\Total Notification Poll Requests /sec

  • \Azure Caching:Host\Total Object Count

  • \Azure Caching:Host\Total Objects Returned

  • \Azure Caching:Host\Total Objects Returned /sec

  • \Azure Caching:Host\Total Primary Data Size Bytes

  • \Azure Caching:Host\Total Get Misses

  • \Azure Caching:Host\Total Get Misses /sec

  • \Azure Caching:Host\Total Get Requests

  • \Azure Caching:Host\Total Get Requests /sec

  • \Azure Caching:Host\Total GetAndLock Requests

  • \Azure Caching:Host\Total GetAndLock Requests /sec

  • \Azure Caching:Host\Total Memory Evicted

  • \Azure Caching:Host\Total Read Requests

  • \Azure Caching:Host\Total Read Requests /sec

  • \Azure Caching:Host\Total Requests Served

  • \Azure Caching:Host\Total Requests Served /sec

  • \Azure Caching:Host\Total Retry Exception

  • \Azure Caching:Host\Total Retry Exception /sec

  • \Azure Caching:Host\Total Secondary Data Size Bytes

  • \Azure Caching:Host\Total Successful GetAndLock Requests

  • \Azure Caching:Host\Total Successful GetAndLock Requests /sec

  • \Azure Caching:Host\Total Write Operations

  • \Azure Caching:Host\Total Write Operations /sec

ClientDiagnosticLevel 1 包含下列效能計數器。

  • \Azure Caching:Client Host\Failure Exceptions

  • \Azure Caching:Client Host\Total Local Cache Hits

  • \Azure Caching:Client Host\Current Server Connections

  • \Azure Caching:Client Host\Average Get Latency / operation Microsecond

  • \Azure Caching:Client Host\Average Put Latency / operation Microsecond

  • \Azure Caching:Client Host\Retry Exceptions

  • \Azure Caching:Client Host\Timeout Exceptions

  • \Azure Caching:Client Host\Requests

  • \Processor(_Total)\% Processor Time

  • \.NET CLR Memory(_Global_)\% Time in GC

  • \Azure Caching:Client(*)\Failure Exceptions

  • \Azure Caching:Client(*)\Total Local Cache Hits

  • \Azure Caching:Client(*)\Current Server Connections

  • \Azure Caching:Client(*)\Average Get Latency / operation Microsecond

  • \Azure Caching:Client(*)\Average Put Latency / operation Microsecond

  • \Azure Caching:Client(*)\Retry Exceptions

  • \Azure Caching:Client(*)\Timeout Exceptions

  • \Azure Caching:Client(*)\Requests

ClientDiagnosticLevel 2、3 和 4 包含下列效能計數器。

  • \Azure Caching:Client Host\Requests

  • \Azure Caching:Client Host\Requests / sec

  • \Azure Caching:Client Host\Server Responses Dropped / sec

  • \Azure Caching:Client Host\Failure Exceptions

  • \Azure Caching:Client Host\Failure Exceptions / sec

  • \Azure Caching:Client Host\Average Get Latency / operation Microsecond

  • \Azure Caching:Client Host\Average Put Latency / operation Microsecond

  • \Azure Caching:Client Host\Average Get Latency (Network) / operation Microsecond

  • \Azure Caching:Client Host\Read Requests

  • \Azure Caching:Client Host\Write Requests

  • \Azure Caching:Client Host\Bytes Received / sec

  • \Azure Caching:Client Host\Bytes Sent / sec

  • \Azure Caching:Client Host\Current Server Connections

  • \Azure Caching:Client Host\Local Cache Filled Percentage

  • \Azure Caching:Client Host\Local Cache Hits Percentage

  • \Azure Caching:Client Host\Total Local Cache Hits

  • \Azure Caching:Client Host\Total Local Cache Objects

  • \Azure Caching:Client Host\Total Notifications Received

  • \Azure Caching:Client Host\Timeout Exceptions

  • \Azure Caching:Client Host\Timeout Exceptions / sec

  • \Azure Caching:Client Host\Retry Exceptions

  • \Azure Caching:Client Host\Retry Exceptions / sec

  • \Azure Caching:Client Host\Total Connection Requests Failed

  • \Azure Caching:Client Host\Network Exceptions

  • \Azure Caching:Client Host\Network Exceptions / sec

  • \Azure Caching:Client Host\Current Waiting Requests

  • \Processor(_Total)\% Processor Time

  • \.NET CLR Memory(_Global_)\% Time in GC

  • \Azure Caching:Client(*)\Requests

  • \Azure Caching:Client(*)\Requests / sec

  • \Azure Caching:Client(*)\Server Responses Dropped / sec

  • \Azure Caching:Client(*)\Failure Exceptions

  • \Azure Caching:Client(*)\Failure Exceptions / sec

  • \Azure Caching:Client(*)\Average Get Latency / operation Microsecond

  • \Azure Caching:Client(*)\Average Put Latency / operation Microsecond

  • \Azure Caching:Client(*)\Average Get Latency (Network) / operation Microsecond

  • \Azure Caching:Client(*)\Read Requests

  • \Azure Caching:Client(*)\Write Requests

  • \Azure Caching:Client(*)\Bytes Received / sec

  • \Azure Caching:Client(*)\Bytes Sent / sec

  • \Azure Caching:Client(*)\Current Server Connections

  • \Azure Caching:Client(*)\Local Cache Filled Percentage

  • \Azure Caching:Client(*)\Local Cache Hits Percentage

  • \Azure Caching:Client(*)\Total Local Cache Hits

  • \Azure Caching:Client(*)\Total Local Cache Objects

  • \Azure Caching:Client(*)\Total Notifications Received

  • \Azure Caching:Client(*)\Timeout Exceptions

  • \Azure Caching:Client(*)\Timeout Exceptions / sec

  • \Azure Caching:Client(*)\Retry Exceptions

  • \Azure Caching:Client(*)\Retry Exceptions / sec

  • \Azure Caching:Client(*)\Total Connection Requests Failed

  • \Azure Caching:Client(*)\Network Exceptions

  • \Azure Caching:Client(*)\Network Exceptions / sec

  • \Azure Caching:Client(*)\Current Waiting Requests

另請參閱

顯示:
© 2014 Microsoft