NumberOfReplayThreads
I’m attempting to replace a trace that ran for 50 minutes I want the replay to simulate as close as possible to the original. I’m not sure but I was thinking that increasing the number of threads would facilitate this. During the original collection there were anywhere between 700-1000 users. Is there a best way to simulate this? I’m also not sure if I’m using the best replay mode considering what I’m attempting to do.
using System;
using System.Data;
using System.Collections;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Trace;
class Program
{
static void Main(string[] args)
{
TraceReplayOptions to = new TraceReplayOptions();
TraceReplay tr = new TraceReplay();
TraceFile tf = new TraceFile();
to.NumberOfReplayThreads = 1000;
to.Mode = ReplayMode.ConnectionLevelSync;
tf.InitializeAsReader(@"C: \tracesTest\tracesTest\bin\Debug\test.trc");
tr.Source = tf;
tr.Connection = new SqlConnectionInfo("test");
tr.ReplayEvent += new ReplayEventHandler(tr_ReplayEvent);
tr.Start();
Console.WriteLine(Environment.NewLine + "Press any key to continue.");
Console.ReadKey();
}
static void tr_ReplayEvent(object sender, ReplayEventArgs args)
{
Console.WriteLine("--- Record number: " + args.RecordNumber + " ---");
for (int i = 0; i < args.CurrentRecord.FieldCount; i++)
Console.WriteLine(args.CurrentRecord
.ToString());Console.WriteLine();
}
}
Answers
- I was unable to get this to work via VB.Net, however I used RML to replay the trace and I was able to get the closest load.
- Marked As Answer byDBAJDS Thursday, October 22, 2009 1:17 PM
All Replies
Hi DBAJDS,
I am not sure what's your means for "as close as possible to the original", but if you want the replay to simulate the connection number, I think your way is work. The replay mode you have chosen will put the event from different connection to the different thread. But since the replay is not do under a distribute enviornment, so it can not simulate the situation that these connections come at the same time. So, it not suggested to use to much threads.
Regards.
Chao
If you are replaying on SQL Server 2008, you better limit the threads under 512 (the upper limit you can set in Profiler.exe). 1000 sometimes will cause an exception. Actually too many threads doesn't help. If SQL Server 2005, limit the threads under 64.- I was unable to get this to work via VB.Net, however I used RML to replay the trace and I was able to get the closest load.
- Marked As Answer byDBAJDS Thursday, October 22, 2009 1:17 PM


