TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sivasankaran Gurusamy
NA
7
3k
High CPU Utilization in Random Pin Generation
Feb 17 2015 11:49 AM
Hi Team,
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?
System Configuration
1. 16 GB RAM
2. OCTA Core Processor
3. IIS 7.0
4. Development Environment ( Visual Studio 4.0)
Code
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;
Reply
Answers (
2
)
Get Dynamic Data From DataTable
ado.net