Click here to Skip to main content
16,017,151 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am storing the huge dataset in the session variable. which is causing the performance of the application. As the dataset has the information which is specific to the user hence cannot store this huge data in cache object.
Now I am converting this dataset into xml and storing into the session as a string. While retrieving the data I am again converting that xml string into dataset.
will this move help me to improve the performance of the application?
What are other options to reduce the size of the user session and improve performance of the application.

What I have tried:

C#
// Convert dataset to string and storing in the session
Session["UserData"] = Ds.GetXml().ToString();

// Convert string to dataset
   DataSet DS = new DataSet() ;
   stream = new StringReader(xmlData);
   reader = new XmlTextReader(stream);
   DS.ReadXml(reader);
Posted
Updated 27-Nov-16 19:35pm
Comments
Dave Kreskowiak 27-Nov-16 11:53am    
What do you mean by "huge"? How much and what kind of data are you talking about?

There are problems with using the Session object.
Abhijit Parab 28-Nov-16 4:09am    
It is around 194KB per session but when multiple request threads at same instance than it consumes high cpu cycle and slow down the application. I am storing dataset as data in session.
F-ES Sitecore 28-Nov-16 4:29am    
Converting it to string is going to take even more space in the session and the converting to string then back to data is also going to take CPU time so it'll probably end up in worse performance and more memory usage. Leave it as a DataSet, or better still see if you can just not store so much data per person. You never know, reading the data from a database only when you need it might not be so bad in terms of performance.

1 solution

Generally not using XML will improve performance, try using fastJSON[^] for dataset serialization.

Not holding onto "huge" data will be the better way.

Try rethinking what you really need to store, other than the above we cannot help you with the little information you have provided.
 
Share this answer
 
Comments
Abhijit Parab 28-Nov-16 4:11am    
The data in the session is around 194KB but when multiple request threads at same instance than it consumes high cpu cycle and slow down the application.
After converting dataset to json and storing it in the session variable will it help to improve the performance?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900