How to back up Cached data in Asp.Net MVC applications? - asp.net-mvc-3

I am building an application which builds a cache which is of big size. The cost of building the cache is again if it is lost is huge.
Is there any way to save the cached data in asp.Net MVC3 applications ?

I think you should take another approach. could be, create database views for example
Keep in mind a few things, you can't have cached whole time because the app pool it's gonna recycle, so even you change the time interval, always gonna happen.
plus, changes in your app that can trigger the recycle
What trigger a immediate recycle?
anything changes in:
Web.config
Machine.config
Global.asax
Bin directory
App_Code
Views strong typed
What trigger a delayed recycle?
Occur with changes in .aspx, .cs/.vb files.

Related

Blue Dragon Coldfusion server cache issue

I have an application build in ColdFusion MVC framework "Mach-II" and hosted on blue dragon ColdFusion server.
It causes caching issue. When i added a new page with some contents and load the page than it's working fine. But when i made some changes in the same file and hit it again its not update my changes. Its always showing me the content that i have made in the very first time. Its seems like that the server is caching my page and did not consider further changes. I have tried many solutions but failed to solve the problem.
Please let me know if you have any solution for that.
This is a bit too long for a comment - but it's not much of an answer.
First off, your question is quite broad for StackOverflow. If you aren't looking at the code yourself, and have nothing to show us, there is no guarantee we can help you at all.
It sounds like maybe this service is using query caching - which looks something like this.
<cfquery datasource="CRM" name="testQuery" cachedwithin="#CreateTimeSpan(0,0,30,0)#">
-SQL logic-
</cfquery>
Basically it stores a query's result in memory on the server. It can really help reduce strain on the database. It's possible that they've set a time limit on this caching feature that's longer than you'd like.
If you don't have access to the code, THIS is the issue you want to ask about first.
Edit: It may be entirely different.
https://docs.oracle.com/cd/E13176_01/bluedragon/621/BlueDragon_621_WL_User_Guide.html#_Toc121303111
From source:
Where ColdFusion (5 and MX) defines a ‘template cache” as a place to
holds templates in memory once rendered from source code, BlueDragon
has the same notion but refers to this as the “file cache”. In both
engines, a template once rendered from source will remain in the cache
until the server (or J2EE or .NET web app) is restarted.
The cache size, specified in the Admin Console, indicates how many of
these cached templates to keep. It defaults to 60 but that number may
need to change for your application, depending on how many CFML
templates your application uses. One entry is used for each template
(CFM or CFC file) requested.
It’s very important to understand that this is not caching the OUTPUT
of the page but rather the rendering of the template from source into
its internal objects. One cached instance of the template is shared
among all users in the application.
As in ColdFusion, once the file cache is full (for instance, you set
it to 60 and 60 templates have been requested), then the next request
for a template not yet cached will force the engine to flush the
oldest (least recently used) entry in the cache to make room.
Naturally, if you set this file cache size too low, thrashing in the
cache could occur as room is made for files only to soon have the
flushed file requested again.
It sounds like you might have to either restart the ColdFusion application or clear the Template Cache in the CFAdmin.

Why is pre-compiling my ASP .NET MVC project not improving my first time access speed?

I have tried two things. One is pre-compiling my ASP.NET MVC 3 project using aspnet_compiler, and the other is using RazorGenerator in the project to allow the views to be compiled. Using both methods, I still see that pages in my site are having to compile on the first access. I see csc.exe running on the server when they are first accessed and it doesn't happen the next time. Why are these pre-compiling steps not preventing this and thus letting me have faster first time access?
Pre-compiling an application won't improve the first request startup time because there are still many things that need to happen when the first request arrives:
The Application_Start method executes
Controllers and Views location are retrieved and cached for subsequent requests
...
You could use the AutoStart feature of IIS 7.5 and ASP.NET 4.0 if you want to preload an application in memory when the web server starts. This way the application will be hot and waiting for the first request.

ColdFusion Caching Solutions for Fusebox 4

I have an application that was built using Fusebox 4 with ColdFusion. Can anyone recommend a good caching solution, that is a plugin, which works directly with this older version of the framework?
Another idea I've been tinkering around with is to take the most commonly used queries in the system and applying cachedWithin. The value would be a variable stored in the application scope. Basically anytime we update any of the most commonly accessed tables in the db, we update the application.cachedwithin variable as well. So whenever these tables are updated the data is refreshed. Anything else that isn't used frequently will simply query the DB to get the content.
Also to add to this very simple caching methodology would be to simply store strings, or other frequently used content, directly within the application scope.
This bulk of this application is around 30 pages, comprised of approximately 200 products. So its quite a small website.
Can anyone recommend a good Fusebox 4 cache plugin or confirm if this simple caching methodology is a good idea? If not, could you recommend a simple alternative?
thanks in advance
I would suggest you to use cfcache to store all pages output into statistics HTML files.
Then on any update, you can clear the cache of the updated pages or all the cache:
<cfcache action="flush" />
<cfobjectcache action="clear" />
make sure to disable the urlSessionFormat() in URL.
I'm not sure that you even need to be caching given the size of the site, unless you are getting a huge amount of traffic. If you are currently having performance problems, the first thing to do is make sure that Fusebox is in production mode, so that it isn't recreating the parsed files on each request.
Caching the queries should certainly aid performance - how long are the queries currently taking to execute? With Fusebox 4, it can be problematic to have "Report execution times" turned on in CF when debugging, as it can significantly affect the time the request takes to execute.

How to Increase page loading speed in Zend Framework Application

I have developed application using ZF.The app is little big with a lots of features.
I use Zend_Application(already using autoloader in constructor),Zend_Layout,Zend_view,Zend_form,etc. My current issue is, the page loading is very slow and that too in localhost with XAMP.
I have enabled xdebug, to investigate the issue, got a cachegrind file in "tmp" folder and tried to view it with WinCachegrind software. There i can a see a lot of processes and functions being run for each and every request or page load.
Also, i have installed YSlow add-on for firefox and observed the speed of page loads in seconds...I have compare the speed with ZF and non ZF applications. And from the comparison, the pages for non zf app takes less than 1 sec to load and for the ZF app, it takes atleast 6-7 seconds. What a huge difference.
Main Things happen in the app are :
1) Database connection happens for each request.
2) Im not adding the view to layout explicitly,ZF just appends it automatically, to layout.phtml, based on the action name.
3) Some windows have forms with few drop down boxes which fetches data from the database.
4) Have menus with ACL implimented, before it was loading the privilges from DB for each and every request, but now i have optimized it, so that it will work only duiring the login and rest of the time it will take from the Zend_Registry.
I would like to attach the cachegrind file so that some one can see whats happening in the background, but i cant see an option here for attaching.
Someone please help me to find a solution for this. Any kind of help is really appreciated. Thanks a lot
Let's try to give some hints.
First database connection should happen only once (except if you use several privileges access on the database or several databases). So check that you use Singleton patterns with you Zend_Db_Tables object
Then you do not use Zend_Cache. You should really start to use Zend_Cache and build several cache objects. Let's say for example a File cach, with long term storage, and a memcache or Apc Cache, storing objects. Then use these cache in several layers:
gives the FileCache to Zend_Db_Table (defaultMetaDataCache), this way you will avoid a loot of metadata queries, queries that ask for description of each columns of the tables you use.
Store one or more Acl object (depends on how you use Acl, if you have one big Acl with all rules or several with subsets). And store them in mid-duration caches when they are built.
Think of other usages, detect heavy loops, semi-static contents (like you select lists, how many time should they be considered static?)
Finally, get a whole mental image of how your application engine works, and how your data will grow and be used.You will need that step to use application levels caches in the very best way (for example should some elements be cached for groups of users?, should Acl objects be build for groups, for each user, for everybody, is ther some blocks in the layout that should be rendered the same for everybody?).

What's the best place for a database-backed, memory-resident global cache in an ASP.NET web server?

I have to cache an object hierarchy in-memory for performance reasons, which reflects a simple database table with columns (ObjectID, ParentObjectID, Timestamp) and view CurrentObjectHierarchy. I query the CurrentObjectHierarchy and use a hash table to cache the current parents of each object for quickly looking up the parent object ID, given any object ID. Querying the database table and constructing the cache is a 77ms operation on average, and ideally this refresh occurs only when a method in my database API is called that would change the hierarchy (adding/removing/reparenting an object).
Where is the best place for such a cache, if it must be accessed by multiple ASP.NET web applications, possibly running in different application pools?
Originally, I was storing the cache in a static variable in a C# dll shared by the different web applications. The problem, of course, is that while static variables can be accessed across threads, they cannot be accessed across processes, which is a problem when multiple web-apps are involved (possibly running in separate application pools). As a result... synchronized, thread-safe modifications to the object hierarchy cache in one application are not reflected in other applications, even though they are using the same code-base.
So I need a more global location for this cache. I cannot use static variables (as I just explained), session state (which is basically a per-user store), and application state (needs to be accessible across applications).
Potential places I've been considering are:
Some kind of global object storage within IIS itself, accessible from any thread in any application in any application pool (if such a place exists. Does it?)
A separate, custom web service that manages an exclusive cache.
Right now, I think the BEST solution is SQL CLR integration, because:
I can keep my current design using static variables
It's a separate service that already exists, so I don't have to write a custom one
It will be running in a single process (SQL Server), so the existing lock-based synchronization will work fine
The cache would be setting as close as possible to the data structures it represents!
I would embed the hierarchy-traversing methods in the SQL CLR DLL, so that I could make a single SQL call where I would normally make a regular method call. This all depends on SQL Server running in a single process and the CLR being loaded into that process, which I think is the case. What do you think of this? Can you see anything obviously wrong with this idea that I may be missing? Is this not an awesome idea?
EDIT:
After looking more closely, it seems that different ASP.NET applications actually run in the same process, but are isolated by AppDomains. If I could find a way to share and synchronize data across AppDomains, that would be very very useful. I'm reading about .NET Remoting now.
Microsoft is working on a distributed caching framework: Velocity. However, the latest release is a CTP3 version, so it may not be production ready...

Resources