Verbesserung von Performance und Monitoring
Neue Performance-Metriken in `EDMIService` hinzugefügt, inkl. Felder für Job-Dauer, langsame Queries und Timestamps. `ServiceStatusResponse` um diese Metriken erweitert. `DatatableJob` optimiert: `<DisallowConcurrentExecution>` hinzugefügt, Logging für langsame Queries (>10s) und Jobs (>30s) verbessert, sowie Gesamt-Dauer-Messung integriert. `Scheduler` nutzt nun dedizierte MSSQL-Instanz zur Entkopplung von Datenbankoperationen. Thread-Pool-Größe reduziert und gestaffeltes Starten von INIT-Jobs eingeführt. Connection-Strings in `WindowsService` angepasst: `ApplicationName` spezifisch gesetzt und `MaxPoolSize` erhöht. Allgemeine Logging-Verbesserungen für bessere Skalierbarkeit und Stabilität.
This commit is contained in:
@@ -1,20 +1,13 @@
|
||||
Option Explicit On
|
||||
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Language.Utils
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Imports Quartz
|
||||
|
||||
Public Class DatatableJob
|
||||
<DisallowConcurrentExecution> Public Class DatatableJob
|
||||
Implements IJob
|
||||
|
||||
|
||||
|
||||
Private Const COMMAND_SQL_TIMEOUT = 240
|
||||
|
||||
Private _MSSQL As MSSQLServer
|
||||
|
||||
Public Function Execute(context As IJobExecutionContext) As Task Implements IJob.Execute
|
||||
Dim oJobData = context.MergedJobDataMap
|
||||
Dim oLogConfig As LogConfig = oJobData.Item("LogConfig")
|
||||
@@ -26,7 +19,8 @@ Public Class DatatableJob
|
||||
Dim oResult As New JobResult()
|
||||
|
||||
oLogger.Info("Running Datatable Job [{0}]/[{1}]", context.JobDetail.Key, oCronJobTitle)
|
||||
|
||||
Dim oJobStopWatch As New Stopwatch() ' ← Gesamt-Messung für den gesamten Job
|
||||
oJobStopWatch.Start()
|
||||
Try
|
||||
Dim oMSSQL As MSSQLServer = oJobData.Item("MSSQL")
|
||||
Dim oCronSQL As String = $"SELECT * FROM TBAPPSERV_CRON_DETAIL WITH (NOLOCK) WHERE CRON_ID = {oCronJobId}"
|
||||
@@ -46,16 +40,23 @@ Public Class DatatableJob
|
||||
oLogger.Debug("Datatable Name: {0}", oDatatableName)
|
||||
oLogger.Debug("Connection Id: {0}", oConnectionId)
|
||||
|
||||
oStopWatch.Start()
|
||||
oStopWatch.Restart()
|
||||
|
||||
Dim oConnectionString = oMSSQL.Get_ConnectionStringforID(oConnectionId)
|
||||
Dim oDecryptedConnectionString = MSSQLServer.DecryptConnectionString(oConnectionString)
|
||||
Dim oConnectionString As String = oMSSQL.Get_ConnectionStringforID(oConnectionId)
|
||||
|
||||
Dim oTable = oMSSQL.GetDatatableWithConnection(oSQL, oDecryptedConnectionString, COMMAND_SQL_TIMEOUT)
|
||||
Dim oTable = oMSSQL.GetDatatableWithConnection(oSQL, oConnectionString, COMMAND_SQL_TIMEOUT)
|
||||
oTable.TableName = oDatatableName
|
||||
|
||||
oStopWatch.Stop()
|
||||
oLogger.Debug("[Time] Getting Data From DB: {0}ms", oStopWatch.ElapsedMilliseconds)
|
||||
Dim oQueryMs = oStopWatch.ElapsedMilliseconds
|
||||
|
||||
' ✅ Schwellwert-Warnung: Query dauert länger als 10s
|
||||
If oQueryMs > 10000 Then
|
||||
oLogger.Warn("⚠ SLOW QUERY [{0}] | Datatable=[{1}] | Duration=[{2}ms] | SQL=[{3}]",
|
||||
oTitle, oDatatableName, oQueryMs, oSQL.Substring(0, Math.Min(200, oSQL.Length)))
|
||||
Else
|
||||
oLogger.Debug("[Time] Getting Data From DB: {0}ms", oQueryMs)
|
||||
End If
|
||||
oStopWatch.Restart()
|
||||
|
||||
Dim oView As DataView = Nothing
|
||||
@@ -107,7 +108,15 @@ Public Class DatatableJob
|
||||
|
||||
' Das Ergebnis speichern
|
||||
context.Result = oResult
|
||||
oLogger.Info("✔✔ Fetched [{0}] Datatables ✔✔", oResult.Tables.Count)
|
||||
oJobStopWatch.Stop()
|
||||
' ✅ Gesamt-Performance-Log pro Job-Ausführung
|
||||
Dim oTotalMs = oJobStopWatch.ElapsedMilliseconds
|
||||
If oTotalMs > 30000 Then
|
||||
oLogger.Warn("⚠ SLOW JOB [{0}] | Tables=[{1}] | TotalDuration=[{2}ms]",
|
||||
oCronJobTitle, oResult.Tables.Count, oTotalMs)
|
||||
Else
|
||||
oLogger.Info("✔✔ Fetched [{0}] Datatables in [{1}ms] ✔✔", oResult.Tables.Count, oTotalMs)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
oLogger.Error(ex)
|
||||
|
||||
Reference in New Issue
Block a user