R
Ron Mexico
I have written a graphing engine (very similar to what BigCharts.com
offers). Basically, it's an ASPX page that accepts parameters and calls
back-end business objects (dlls) to create a graph. When the graph is
created as a jpeg, it is returned to the browser as binary data. When it is
used at a low volume, it performs great and returns correctly drawn graphs
in a timely manner. However when the amount of traffic is increased to a
high volume, the graphs come back distorted. I've done some research on this
issue and have found that when .NET creates an object in memory, it is not
thread safe. For instance, if an ASPX page gets called several times at
once and each call creates an object called oGraph, it will create several
oGraph objects. However, when an instance of the ASPX page goes to reference
the properties or methods of oGraph, it doesn't care about which instance in
memory that it uses. It will use one that it didn't create. What I end up
with is mutated graphs. For example, if two calls were made simultaneously
to create a 90 day IBM graph and a one day intraday MSFT graph, I will end
up with a graph with IBM as the title and a plot that reflects MSFT intraday
data. Many times it just looks like pieces of one graph drawn on top of the
other. Does anyone know of a way to tell the ASPX page (and the objects it
calls) to 'mind it's own business', so to say, and only use the specific
instances of objects it initiates? I have tried using
System.Threading.Monitor.Enter\Exit on all of my objects and have also tried
the SyncLock blocks, as well. Any help with this would be greatly
appreciated.
offers). Basically, it's an ASPX page that accepts parameters and calls
back-end business objects (dlls) to create a graph. When the graph is
created as a jpeg, it is returned to the browser as binary data. When it is
used at a low volume, it performs great and returns correctly drawn graphs
in a timely manner. However when the amount of traffic is increased to a
high volume, the graphs come back distorted. I've done some research on this
issue and have found that when .NET creates an object in memory, it is not
thread safe. For instance, if an ASPX page gets called several times at
once and each call creates an object called oGraph, it will create several
oGraph objects. However, when an instance of the ASPX page goes to reference
the properties or methods of oGraph, it doesn't care about which instance in
memory that it uses. It will use one that it didn't create. What I end up
with is mutated graphs. For example, if two calls were made simultaneously
to create a 90 day IBM graph and a one day intraday MSFT graph, I will end
up with a graph with IBM as the title and a plot that reflects MSFT intraday
data. Many times it just looks like pieces of one graph drawn on top of the
other. Does anyone know of a way to tell the ASPX page (and the objects it
calls) to 'mind it's own business', so to say, and only use the specific
instances of objects it initiates? I have tried using
System.Threading.Monitor.Enter\Exit on all of my objects and have also tried
the SyncLock blocks, as well. Any help with this would be greatly
appreciated.