.NETGURU
File System as a cache mechanism
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.performance.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

John Linn (VIP)
In the journey of finding ways to scale our application with my current hardware, I've been playing around with using our servers hard disk as a means of caching information.

We have a LOT of content that doesn't change very much and is guarenteed to be used every single page view (template information for hundreds of templates, 'whose online' counts, custom navigation, etc). Under load, there is way too much % of CPU going to these "framework" items and as we add web machines to the farm, the overall RPS for each machine drops. Up until now, we've used Cache for these items, but we are now having problems with memory consumption over these hundreds of templates (and I want to scale to thousands of templates).

So I've worked up a system where the unchanging information is written out to disc after the application is first loaded, and then subsequent reads come from the disk. If a change is made to any of the disk cached information, I simply delete the file through UI tools. Each machine is on DFS, so when the text file is deleted/updated, it gets copied over to the other web servers. So far, it's proven to work very nicely, because on simple pages there is a slightly increased RPS rate. On more complex pages there is a much greater RPS rate. And most importantly, the RPS doesn't decrease as we add servers to the farm.

I understand that disk IO still isn't as fast as memory cache and there will be bottlenecks. But the way I see it, I am eliminating a single point of contention in the DB server and can scale the overall RPS of my app by simply adding smaller servers to the web farm and using their disk's IO.

My questions:
1) Is this a sound design?
2) Can I rely on DFS to control the removal/updating of the cached files?
3) Under a couple of occurances of heavy load, we've gotten some File IO "file is in use" expections when trying to remove a file to be deleted. For removal, we use the static methods of File.Delete and Directory.Delete. To create the files we use File.CreateText and to read the files, we use StreamReader. Is there a way to lock a file that is to be manipulated eliminate this issue (like application.lock)?

Thanks a lot!

JL
Reply to this message...
 
    
Alvin Bruney [MVP]
you should look into fragment caching for the static stuff. basically, it
re-implements internally what you have coded by hand without using I/O
access.

[Original message clipped]

right, because of concurrency you may trying to massage a file that is in
use.
One technique to over come this delete problem is to first try to delete the
file, if it fails because it is in use - hot, then you rename the file and
then delete both instances - hot delete.

finally, is this a bonafide webfarm, or you mean that it is a bunch of
servers hooked together?

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"John Linn" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
John Linn (VIP)
Alvin,

[Original message clipped]

We load our user controls via LoadControl and cast them as a custom class all of our controls inherit. Since adding OutputCache directive to a user control effectively changes the class to PartialCachingControl, I've not put too much effort into figuring out a solution involving fragment caching.

And fragment caching still caches to RAM, right? I would still worry about memory issues over thousands on entries.

[Original message clipped]

Interesting, I will play around with this.

[Original message clipped]

I am not sure what makes a bonafide webfarm, so I am guessing not. =) We have web servers that are "connected" through Active Directory DFS and a shared IP via Network Load Balancing.

Thanks,
JL
Reply to this message...
 
    
Alvin Bruney [MVP]
[Original message clipped]

right, actually there is no way to cache a control per appdomain which is
really what you are after. even with fragment caching, the control cache is
created for every requesting page.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"John Linn" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
John Linn (VIP)
Exactly and that's why we wanted to use disk to cache. Because with DFS we can in essence share cached information across appdomains.

So far, the exceptions are rare and the RPS are much improved, so I hope by the time we run out of disk IO bandwidth, we can either add more web servers or get a dedicated "content" DB.

Thanks for your time, Alvin.

JL

"Alvin Bruney [MVP]" wrote:

[Original message clipped]

Reply to this message...
 
 
System.IO.Directory
System.IO.File
System.IO.StreamReader
System.Web.UI.PartialCachingControl




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification