MySQL Forums
Forum List  »  Quality Assurance

Re: My MySQL DB is unable to process 4+ requests at a time!
Posted by: Mahesh V S
Date: January 16, 2012 05:13AM

Here is my C# code
-----------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Configuration;
using System.Threading;

namespace MySQLDBLoadTestApp
{
class Program
{
static void Main(string[] args)
{

Console.WriteLine("Enter # of threads");
String noThread = Console.ReadLine();

if(String.IsNullOrEmpty(noThread))
noThread = "1";

int threadCnt = Int32.Parse(noThread);

for(int i=0 ; i< threadCnt ; i++)
{
Thread t1 = new Thread(loadTester);
t1.Start();
}


// loadTester();

Console.Read();
}

private static void loadTester()
{
MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings["connectionString"]);

connection.Open();

MySqlTransaction txn = connection.BeginTransaction();

try
{

int count = Int32.Parse(ConfigurationManager.AppSettings["commandCount"]);

for (int i = 1; i <= count; i++)
{
MySqlCommand command = connection.CreateCommand();
String commandText = ConfigurationManager.AppSettings[("command" + i)];

command.CommandText = commandText;

DateTime start = DateTime.Now;
Console.WriteLine("Start : " + commandText + " @ " + start);
command.ExecuteNonQuery();
DateTime end = DateTime.Now;
Console.WriteLine("End : " + commandText + " @ " + end + " Took (sec):" + end.Subtract(start).Seconds);
}

txn.Commit();

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
txn.Rollback();
}
finally
{
connection.Close();
}
}
}
}

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: My MySQL DB is unable to process 4+ requests at a time!
1006
January 16, 2012 05:13AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.