We have an application for Random Pin Generation. As per business requirement, we have to support 12 concurrent user transactions at a time. Where in each user will attempt to generate 1 lakh Pins during each transaction. During this activity, application server's CPU utilization reached maximum limit.
We identified, random number generation task is what consuming maximum system resources ( 70 %). please advise where we need betterment to fix this issue? Should we need to find solution in IIS side or Application level?
1. 16 GB RAM
2. OCTA Core Processor
3. IIS 7.0
4. Development Environment ( Visual Studio 4.0)
List<string> lstpins = null;
lstpins = new List<string>();
for (int i = 1; i <= qty; )
{
double dlRnd = rnFirst.NextDouble();//with seed
if (dlRnd < 0.0001)
{
dlRnd += 0.012;
}
string strRndFirstDgt = dlRnd.ToString().Substring(2, iFirstPinLng);
//----Second Rnd ------ 0.6 91979 52919 26617
double dlSecondRnd = rnSecond.NextDouble(); //Without Seed. 58535 03461 123
if (dlSecondRnd < 0.0001)
{
dlSecondRnd += 0.012;
}
string strRndSecondLastsixDgt = dlSecondRnd.ToString().Substring(dlSecondRnd.ToString().Length - iSecondPinLng, iSecondPinLng);
string conCan = strRndFirstDgt + strRndSecondLastsixDgt;
long temp;
temp = Convert.ToInt64(conCan) + DateTime.Now.Ticks; //addition to pin+ datetime Ticks
int intRndThird = rnThird.Next(1, 10);//To avoid the prefix value 0's;
string conCanRnd = intRndThird.ToString() + (temp.ToString().Substring(temp.ToString().Length - pinLength, pinLength - 1));
string sessionconcatpins = stInt + conCanRnd.ToString(); // Append Concurent User Hit Count in to PINS
if (!string.IsNullOrEmpty(sessionconcatpins.Trim()))
{
if (!lstpins.Contains(sessionconcatpins))
{
lstpins.Add(sessionconcatpins);
i++;
}
}
if (i % 100 == 0)
{
lngDateTicker = DateTime.Now.Ticks;
strSeedLastNineDgt = lngDateTicker.ToString().Substring(7, 9);
rnFirst = new Random(Convert.ToInt32(strSeedLastNineDgt));
}
}
Thread.Sleep(100);
return lstpins;