caching data on server in windows application in c#
-
Hi, We have a windows app which is installed in many systems..and the server is resided on different PC..so whenever users loading the app due to many hits to server..the application is becoming very slow.. so i tried to use caching the data ..with expiration..(as we dont have any db changes during expiration time..) i tried the below article which was posted in codeproject... "http://www.codeproject.com/KB/cs/webservicecache.aspx" but this article explains to cache data locally..but i need o cache the data in the server...so that eventhough many users run the app the load will be less... Please help me regarding the same..
-
Hi, We have a windows app which is installed in many systems..and the server is resided on different PC..so whenever users loading the app due to many hits to server..the application is becoming very slow.. so i tried to use caching the data ..with expiration..(as we dont have any db changes during expiration time..) i tried the below article which was posted in codeproject... "http://www.codeproject.com/KB/cs/webservicecache.aspx" but this article explains to cache data locally..but i need o cache the data in the server...so that eventhough many users run the app the load will be less... Please help me regarding the same..
try some other techniques
-
try some other techniques
-
Hi, We have a windows app which is installed in many systems..and the server is resided on different PC..so whenever users loading the app due to many hits to server..the application is becoming very slow.. so i tried to use caching the data ..with expiration..(as we dont have any db changes during expiration time..) i tried the below article which was posted in codeproject... "http://www.codeproject.com/KB/cs/webservicecache.aspx" but this article explains to cache data locally..but i need o cache the data in the server...so that eventhough many users run the app the load will be less... Please help me regarding the same..
pradeep455 wrote:
but this article explains to cache data locally..but i need o cache the data in the server...so that eventhough many users run the app the load will be less...
That won't help much; database-servers are optimized to return data as fast as possible from their datastore. You'd still have the same amount of network-traffic, and the extra caching-application might consume CPU-time that the database-server wants, moving the delay from one application to another. Caching on the client side will remove the need to transport the data over the network and moves some work from the server to the local machine. That's the way to go, unless you have a server that never runs into capacity-problems. A simple way to achieve this is to synchronize the database from the server with a local copy. I'd only sync the readonly data; lookuplists do better when local, especially if required often. Or, if you have those in a real
List
, serialize them after retrieving them once, save it locally, and deserialize from the local path the next time your app starts.Bastard Programmer from Hell :suss:
-
Hi, We have a windows app which is installed in many systems..and the server is resided on different PC..so whenever users loading the app due to many hits to server..the application is becoming very slow.. so i tried to use caching the data ..with expiration..(as we dont have any db changes during expiration time..) i tried the below article which was posted in codeproject... "http://www.codeproject.com/KB/cs/webservicecache.aspx" but this article explains to cache data locally..but i need o cache the data in the server...so that eventhough many users run the app the load will be less... Please help me regarding the same..
Let me get this right - you have a WinForms/WPF application that connects to a server to retrieve data and manipulate it. You want to retrieve information from the server and use it locally, but you think you will get better performance if you retrieve it from a cache at the server end. Have I understood your requirements properly? What I am unclear about here, is whether the remote machine is merely a database server, or whether it has web services that serve up the data. The client side architecture is greatly affected by this fact. If the remote PC is merely a database, then you should just retrieve the data and do any caching locally. It is possible that you are issuing slowdown problems because you are trying to run an enterprise database on a simple PC, and have other issues because of that design. If the remote PC is a web service (whether or not served up by WCF), then it could make sense to cache the data at the server side. Unfortunately, we cannot offer any more detailed help because you have not offered sufficient detail as to what your architecture actually is.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Hi, We have a windows app which is installed in many systems..and the server is resided on different PC..so whenever users loading the app due to many hits to server..the application is becoming very slow.. so i tried to use caching the data ..with expiration..(as we dont have any db changes during expiration time..) i tried the below article which was posted in codeproject... "http://www.codeproject.com/KB/cs/webservicecache.aspx" but this article explains to cache data locally..but i need o cache the data in the server...so that eventhough many users run the app the load will be less... Please help me regarding the same..
pradeep455 wrote:
installed in many systems.
please define "many". does the app run fine when there is only one or two clients active? :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Please use <PRE> tags for code snippets, they improve readability.
CP Vanity has been updated to V2.3 -
Let me get this right - you have a WinForms/WPF application that connects to a server to retrieve data and manipulate it. You want to retrieve information from the server and use it locally, but you think you will get better performance if you retrieve it from a cache at the server end. Have I understood your requirements properly? What I am unclear about here, is whether the remote machine is merely a database server, or whether it has web services that serve up the data. The client side architecture is greatly affected by this fact. If the remote PC is merely a database, then you should just retrieve the data and do any caching locally. It is possible that you are issuing slowdown problems because you are trying to run an enterprise database on a simple PC, and have other issues because of that design. If the remote PC is a web service (whether or not served up by WCF), then it could make sense to cache the data at the server side. Unfortunately, we cannot offer any more detailed help because you have not offered sufficient detail as to what your architecture actually is.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Yes the remote PC is a webservice(serve up the data) ,and the clients are consuming the webservice.. and as u said(caching on server) if this is the case please let me know how to cache on the server..(in webservice)
You have hosted this in a web server then? If so, you simply need to use a pattern like this:
private MyData GetData()
{
HttpCache myCache = HttpContext.Current.Cache;
MyData data = myCache["MyData"];
if (data == null) return GetDataAndStoreInCache();
return data;
}private MyData GetAndStoreInCache()
{
// Do something to get the data.
MyData data = RetrieveDataHere();
HttpContext.Current.Cache.Insert("MyData", data, null, DateTime.Now.AddHours(6), TimeSpan.Zero);
return data;
}Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Hi, We have a windows app which is installed in many systems..and the server is resided on different PC..so whenever users loading the app due to many hits to server..the application is becoming very slow.. so i tried to use caching the data ..with expiration..(as we dont have any db changes during expiration time..) i tried the below article which was posted in codeproject... "http://www.codeproject.com/KB/cs/webservicecache.aspx" but this article explains to cache data locally..but i need o cache the data in the server...so that eventhough many users run the app the load will be less... Please help me regarding the same..
It depends on what the problem is. On a previous job, I had a number of clients (five or so, but could be more) that had to access the same data repeatedly (every minute or so) as they monitored the status of the running system. Because the data required a fair bit of calculation and aggregation I chose to have a Windows Service produce an XML file with the results that the clients could then download at their leisure. The Service ran on a fifteen-second cycle and produced one of ten files (e.g. SystemStatus.0.xml -- SystemStatus.9.xml) and when it was done it wrote the name of the latest file to the database for the clients to read.
-
Hi, We have a windows app which is installed in many systems..and the server is resided on different PC..so whenever users loading the app due to many hits to server..the application is becoming very slow.. so i tried to use caching the data ..with expiration..(as we dont have any db changes during expiration time..) i tried the below article which was posted in codeproject... "http://www.codeproject.com/KB/cs/webservicecache.aspx" but this article explains to cache data locally..but i need o cache the data in the server...so that eventhough many users run the app the load will be less... Please help me regarding the same..
pradeep455 wrote:
Please help me regarding the same..
First step is to actually determine what is causing the slow down. Attempting to guess bottlenecks is unlikely to be successful. Did you actually measure the time it took for various parts of your application and server?
-
You have hosted this in a web server then? If so, you simply need to use a pattern like this:
private MyData GetData()
{
HttpCache myCache = HttpContext.Current.Cache;
MyData data = myCache["MyData"];
if (data == null) return GetDataAndStoreInCache();
return data;
}private MyData GetAndStoreInCache()
{
// Do something to get the data.
MyData data = RetrieveDataHere();
HttpContext.Current.Cache.Insert("MyData", data, null, DateTime.Now.AddHours(6), TimeSpan.Zero);
return data;
}Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Thanks for ur reply... i need to use this code snippet in webservice code right...? using HttpContext.Current.Cache instead of HttpRuntime.cache or Microsoft.ApplicationBlocks.cache is better? Correct me if im wrong..pls let me know which is better to use.. -- Modified Thursday, May 26, 2011 2:08 AM
-
Thanks for ur reply... i need to use this code snippet in webservice code right...? using HttpContext.Current.Cache instead of HttpRuntime.cache or Microsoft.ApplicationBlocks.cache is better? Correct me if im wrong..pls let me know which is better to use.. -- Modified Thursday, May 26, 2011 2:08 AM
You would be OK using HttpRuntime.Cache. Basically, HttpContext.Current.Cache is a version of HttpRuntime.Cache. In fact, all that HttpContext.Current.Cache really does is pass the request onto HttpRuntime.Cache (the big difference being that HttpRuntime.Cache is available for all cases, so you can even use it in a console application if you want). My sample wasn't meant to be used literally, rather it was to demonstrate some possible techniques. As it stands, it's not a totally robust situation as you could enter a situation where between the time of the lookup and the insert into the cache, another process inserts the data into the cache. If you code this robustly, you need to take this into account.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility