Page 1 of 1

Performance, multithreading and webservices

Posted: Wed Nov 15, 2006 6:57 pm
by 9637821
We have a .NET web form that uses TeeChart .NET control to create charts. Data comes from a webservice. We tried stress testing the page and it can handle 18 charts / second. During that time the entire web site that includes the charts is almost unresponsive, as if IIS is waiting for the chart to complete and then serve additional requests.

The delay is from the webservice, because when creating charts with dummy data, the performance is 50 charts / second.

Is there a way for the chart to NOT delay the whole IIS web site when it is waiting for data from the web service?

Posted: Thu Nov 16, 2006 9:27 am
by narcis
Hi realize,

Can you please read this topic, specially Norbert's message and my reply about threads? Does this apply to your application? I mean, could it be that your threads don't leave enough time for the charts to paint themselves and thus they seem to be unresponsive?

Posted: Thu Nov 16, 2006 11:34 am
by 9637821
I read it but I am not sure it helps. Let me rephrase:

* We have a dll that creates charts (teechart)
* This dll is called by a web page in .NET
* The web page feeds TeeChart with data. If, for any reason, the data feed is delayed, and another page calls TeeChart dll to create a chart, does teechart have to wait for process 1 to finish before executing process 2 ?

Posted: Fri Nov 17, 2006 12:25 pm
by narcis
Hi realize,

We guess this is the same as threading, basically add data to the serise, wait for the chart to finish drawing it, and then add new data, etc.

What you could do is putting a flag, set to false, in the BeforeDraw event and in the AfterDraw event set it to true. Then you know that if the flag is true new data can be added.

Posted: Tue Nov 21, 2006 1:53 pm
by 9637821
So TeeChart is not multithreaded?

Posted: Wed Nov 22, 2006 8:50 am
by Chris
Hello,

Representing data graphically, that is, drawing data as a chart, is a time consuming process. TeeChart needs to be given time to complete this process, which in a multi-threaded environment means not giving it more data until it has finished painting the last dataset it has been given. The way to check if a TeeChart is painting or not is a flag in the BeforeDraw and AfterDraw events, a flag we could internalise as a property but which would do exactly the same.

You might consider caching charts in your application so that the same chart doesn't have to be created time and time again. In this way new charts are created only when the data has changed, greatly reducing the load on the TeeChart routines.

Posted: Fri Nov 24, 2006 1:12 pm
by 9637821
I'll try to explain one last time... Sorry if I am not able to make myself clear...

Lets say that teechart needs 10 secs to get data (because data is coming from a remote web service (Stage A).
When this data comes, it needs 1 second to draw the chart (Stage B).

I understand that it cannot draw a second chart during stage B. But can it draw a second chart during stage A? If yes, how?

I hope I explined it right now :)

Posted: Fri Nov 24, 2006 2:58 pm
by narcis
Hi realize,


You can try using TeeChart's AutoRepaint property:

Code: Select all

tChart1.AutoRepaint = false; 
Random r = new Random(); 
for(int i = 0; i <500; i++) 
{
      tChart1[0].Add (i,r.Next(800),Color.Blue); 
} 
tChart1.AutoRepaint = true; 
tChart1.Refresh(); 
Before loading data (Stage A) you set data-loading chart's AutoRepaint to false and set it back to true when the chart being drawn has finished this process, on its AfterDraw event.

Posted: Thu Nov 30, 2006 12:37 pm
by 9637821
We are not talking about a Win32 application.
We are talking about a web site with 500+ concurrent users

Posted: Wed Dec 20, 2006 1:18 pm
by narcis
Hi realize,

The tecnique in the code snippet I posted is not dependent on WinForms. Its WebForms equivalent would be:

Code: Select all

			Steema.TeeChart.Chart ch1 = WebChart1.Chart;

			ch1.AutoRepaint = false;

			Random r = new Random();
			for (int i = 0; i < 500; i++)
			{
				ch1[0].Add(i, r.Next(800), System.Drawing.Color.Blue);
			}
			ch1.AutoRepaint = true;
			ch1.Invalidate();
Anyway, it's not a problem if you want TeeChart to draw another chart while you're waiting for the data. You can collect the data into a dataset, which may take some time, and in the meantime, you can draw a chart. Then, when the dataset is complete, you can assign it as a datasource of your series and get it drawn. TeeChart doesn't have to wait for the data to arrive, you can get a dataset to wait for it to arrive and use the TChart to do whatever you like in the meantime.