Cache vs Session, Application state for datagrid

M

marina.sukhnev

Hi Guys,

I have a question,what is the best way to preserve dataset in web
application:
Cache object,Session or Application state.
From perfomance,scalability point of view?
Any ideas?

Thanks,

Marina
 
E

Elton Wang

Hi Marina,

First of all, let's see the difference between SessionState and
ApplicationState. When you store data in Session, it is only available for
one user Session (even when a user open a new browser by clicking desktop
icon or Start -> Programs -> browser menu in same computer, it starts a new
Session.) On the other hand, data in ApplicationState can be accessed cross
sessions in the application. Hence, if you want the data to be shared for
different users, use Application, otherwise use Session.

Secondly, let's see Cache. It has the same scope as Application. And it also
has some other feathers, such as, CacheDependency (e.g. some file or files),
expiry date time, time span, and so on.

Thirdly, advantages of using them are good performance (it cuts
communication between web server and database) and sharing data cross pages.
Disadvantages are consuming web server memory resource (when in user and
data intensive application, it causes server dead soon) and out of time data
(so you might need some refresh events).

HTH
 
M

Marisha

Thank you Elton for quick response,

I was testing Session and Cache objects with my dataset,that bound to
datagrid,when I load some item that has 950 rows and try to do some
operations like edit,delete,update,very soon I'm getting Out of Memory
Exception,means server crushes,till I reset IIS.
Which refresh events did you mean?
Do you have some suggestions,is 950 rows too much to handle?

Thanks a lot,

Marina
 
E

Elton Wang

Normally, it should handle much more than 900 rows data.



However, from user perspective, do you think it is good idea to edit 900
rows of data in one page?



To be able to refresh the cache data based on the fact that someone else has
changed a row in the database. Programmers have resorted to a few different
techniques to accomplish this, such as writing a trigger that updates a file
when the table or view changes, or refreshing the cache every so often
whether the database has changed or not. There is no straightforward way the
register for database notifications until the SqlClient
SqlNotificationRequest and SqlDependency classes in ADO.NET 2.0.



HTH
 
M

Marisha

Elton,
User edits only couple rows out of 900 and it is a radical example,in
most cases the grid has 20-50 rows of data,then it is not a problem.
But i have couple items that have bulky data such as 500+ items and
only there the problem occurs.I refresh my cache every time i
add,delete,update some records of the grid,but it doesn't help.
I tried it on two servers and both of them throw the same exception .

Marina
 
M

Marisha

Elton,
User edits only couple rows out of 900 and it is a radical example,in
most cases the grid has 20-50 rows of data,then it is not a problem.
But i have couple items that have bulky data such as 500+ items and
only there the problem occurs.I refresh my cache every time i
add,delete,update some records of the grid,but it doesn't help.
I tried it on two servers and both of them throw the same exception .

Marina
 
M

Marisha

Elton,
User edits only couple rows out of 900 and it is a radical example,in
most cases the grid has 20-50 rows of data,then it is not a problem.
But i have couple items that have bulky data such as 500+ items and
only there the problem occurs.I refresh my cache every time i
add,delete,update some records of the grid,but it doesn't help.
I tried it on two servers and both of them throw the same exception .

Marina
 
E

Elton Wang

How about to use ViewState to save dataset? In your worst scenario, if it's
900 rows, datagrid viewstate is about 1.5 mb. DataSet occupies about 1 mb in
viewstate. So totally about 2.5 mb.
 
M

Marisha

Oh,I'm over it already.
I used ViewState,and then the page won't load at all,it will hang even
for 50-70 rows in datagrid.
When I realized that I can use Cache object or session state,I thought
all my problems are resolved,but apparently I still have them with
bulky data in datagrid...
 
E

Elton Wang

If traffic between Web server and Database server is not very busy, try
directly query data from database every time. And using paging (in datagrid
and from stored procedure) to limit data amount.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top