C# - Is Possible To Share HttpRuntime.Cache Between Multiple Web Servers
Nov 10, 2010
We have a web application that is storiing all site data in HttpRuntime.Cache. We now need to deploy the application across 2 load balanced web servers. This being the case, each web server will have its own cache, which is not ideal because if a user requests data from webserver1 it will be cached, but there next request might go to webserver2, and the data that their previous request cached won't be available. Is it possible to use a shared-cache provider to share the HttpRuntime.Cache between the two web servers or to replecate the cache between them, so that the same cache will be available on both web servers?
View 4 Replies
Similar Messages:
Aug 15, 2010
I have a website setup like this:
/Web --this is the client facing site /Web/Admin --this is the backend system and is setup as a Virtual Application
I'm using HttpRuntime.Cache for caching calls to the database. What I want to be able to do is clear something that is cached on the /Web site from the /Web/Admin site. It appears though that HttpRuntime.Cache is a single instance per application.
View 2 Replies
Mar 17, 2010
Can multiple SSRS share the same DB? We're getting into an SSRS customization scenario, which may adversely affect our existing SSRS features, and I wanted to see if it was possible.
View 1 Replies
Mar 12, 2010
I have a bunch of EC2 servers that are load balanced. Some of the servers are not sharing session, and users keep getting logged in and out. How can I make all the server share the one session, possibly even using a partitionresolver solution
public class PartitionResolver : System.Web.IPartitionResolver
{
private String[] partitions;
public void Initialize()
{
// create the partition connection string table
// web1, web2
partitions = new String[] { "192.168.1.1" };
}
public String ResolvePartition(Object key)
{
String oHost = System.Web.HttpContext.Current.Request.Url.Host.ToLower().Trim();
if (oHost.StartsWith("10.0.0") || oHost.Equals("localhost"))
return "tcpip=127.0.0.1:42424";
String sid = (String)key;
// hash the incoming session ID into
// one of the available partitions
Int32 partitionID = Math.Abs(sid.GetHashCode()) % partitions.Length;
return ("tcpip=" + partitions[partitionID] + ":42424");
}
}
View 1 Replies
Feb 24, 2010
We are using HttpRuntime.Cache API in an ASP.NET to cache data retrieved from a database.
For this particular application, our database queries feature a LOT of parameters, so our cache keys look something like this:
table=table1;param1=somevalue1;param2=somevalue2;param3=somevalue3;param4=somevalue4;param5=somevalue5;param6=somevalue6... etc...
we have so many parameters that the cache key is several hundred characters long. is there a limit to the length of these cache keys? Internally, it is using a dictionary, so theoretically the lookup time should be constant. However, I wonder if we have potential to run into some performance/memory problem.
View 1 Replies
Mar 27, 2011
I have a SharePoint 2010 Farm and want to use object caching for my own custom objects.
Since it's an ASP.net Application at it's core, I could use HttpRuntime.Cache. On the other hand, SharePoint 2010 offers it's own SPCache.
Why would I choose SPCache over the HttpRuntime.Cache one?
View 2 Replies
Apr 22, 2010
I am new in Asp.net MVC but i really like it. I always prefer flexible authentication systems, on the other hand security is very important issue too. So i looked for some sipmle way to store current loged "user id/user name" in server side. I think that "HttpRuntime.Cache" can be a answer. So i write simple test project Of course this code is is not complete.
[Code]....
View 6 Replies
Jan 29, 2010
what the default serialization used by the ASP.net HttpRuntime.Cache is? Is it Binary, XML, something else?
I am populating a generic List with multiple objects of the same custom type. The custom type is a POCO, there is nothing special about it. All of its properties are public with { get; set; }, it is public, it has no inheritance, it has no interfaces. In fact it is much less complicated than many other objects which we are caching which work without issue. I have tried adding the [Serializable] attribute to the custom class and it has no effect.
I add the list to the cache with a unique key. The list has been verified as populated before it is inserted into the cache, the objects in the list have been verified as populated as well. But when the list is pulled back out of the cache it is an empty list (NOT NULL), it simply has no items in it. This means that the list is being added to the cache and is retrievable but for some reason the cache is having issues serializing the objects in the list.
I just find this freaky weird since I have another list of custom objects which are much more complicated (consisting of Inheritance, Interfaces, and also containing Properties which are generic lists of other complex objects) and the caching of those lists work without issue.
Both the working and non-working list are being managed in C# classes outside of the ASP.net user controls which consume the cached data. Both of these cache handling classes call the exact same Cache Manager class singleton instance which wraps the HttpRuntime.Cache to provide typed methods for pull and pushing objects into the cache.
Here is the class
[code]....
View 2 Replies
Oct 19, 2010
I've been experimenting with caching objects with HttpRuntime.Cache and I was generally under the impression that if I "added" something to the cache like this:
HttpRuntime.Cache.Insert("Test", "This is a test!", null,
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(FileChanged));
that the "NotRemovable" and "NoExpiration" flags would keep the object in-memory for the duration of the application. But was finding that at the end of certain page requests, the HttpRuntime.Cache would be completely empty!
Tracing thru and setting a breakpoint inside my Callback "FileChanged" I could see that indeed something was "removing" my object (and every other object in the cache), but I couldn't figure out why. So eventually, I started disabling other things that I thought might affect this subsystem.
Eventually, I commented out the line:
WebConfigurationManager.OpenWebConfiguration("~").Save;
I had been mostly retrieving data from "web.config" in the AppSettings region, but occasionally writing back to AppSettings and saving the changes using the above command. I knew from reading that the "web.config" is cached, but saving my changes back to it shouldn't flush all of HttpRuntime.Cache, right?
EDIT:
I've made this super reproducible if wants to try this on their own machine. (I'm running VS2008 Pro w/ MVC2 targeting .NET 3.5) Just start up a new MVC2 project and paste the following into the HomeController over whatever is already there:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Configuration;
using System.Configuration;........
Start-up the app in debug mode. Click on the "About" link. This loads a string into the Cache. Click on the "Home" link. String is pulled from the Cache and stuck in ViewMessage dictionary. Some key/value pair is written to web.config and saved. String from cache should appear on the Home page. Click on the "Home" link again. String should be pulled from the cache, but it's not. Stop program. Comment out the 3 lines that start with "Config". Restart the program. Try steps 1 thru 4 again. Notice how the HttpRuntime.Cache has not been emptied.
View 1 Replies
Feb 2, 2010
Is there a way of creating a hash key that can be used by our different servers for decrypting connection strings in web.config, and how would I do that?
View 1 Replies
Nov 12, 2010
My servers are behind F5 load balancer, I wanna use HttpRuntime.Cache in my web application but I didn't find out the way for to use that method for those using network load balancing server. Or can we store that HttpRuntime.Cache to sql server like the session we do in web.config file?
View 4 Replies
Nov 19, 2010
I am trying to remove the cache using the HttpRuntime.Cache.Remove(key) but invain. I wonder what are the best practices for using HttpRuntime.Cache.
View 2 Replies
Jul 23, 2010
We are working on a web application that is distributed across 3 load-balanced web servers. A lot of the data we retreive via NHibernate is stored in System.Web.Caching.Cache.
System.Web.Caching.Cache does a lot to increase the responsiveness of an application, but there are a few issues that we don't exactly know how to resolve, such as
when a user requests data on server1 that data is cached on server1, but for their next request, the load balancer might direct them to server2. That data they requested on server1 is no longer available, and server2 will have to request it from the database again. If the user does something on server1 to invalidate the cached data, the cache is flushed on server1. However the original cache is still available on server2 & server3, so when the user submits a subsequent request and they're directed to either of the other servers, they are going to be presented with invalid data.We have applications that update data (such as performance data) on a regular basis. When the performance data is updated we want to flush this from the cache so when a user requests the data again, they're presented with the latest data. How can we get these applications to flush the cache on 3 web servers?
What are the best ways to resolve these issues?
Should we have cache stored on a separate server such as we could to for HttpContext.Session with a SessionState server?
Is there a way for us to set a Cache Dependency on the Cache in the other 2 servers?
Is it possible for us to implement a Cache Dependency on the actual database tables or rows? When these change the cache is flushed? -- or could we set up a database trigger to flush the cache somehow?
View 2 Replies
Mar 24, 2010
We have a CMS system and in the production mode a number of servers only have read-only access to the content (with a few exceptions) and the editors for the site work on the content on servers behind it (which are not available to the public).
We're caching the content quite a long time on the front servers, but sometimes we want the content the editors publish to be available for visitors instantly. What is best practice for invalidating the cache in those cases?
View 2 Replies
Mar 19, 2010
I would like to create a web application that gives an overview of all latests builds of a Team Foundation Server (TFS). The original idea was to simply query the TFS for all these builds and display the results using html. Now the problem is that this is just too slow. It takes around a minute to get the required informtion. I can't inluence this, it is just given. So I came up with the idea of caching. I could cache all results for a certain period of time and then invalidate the cache but as soon as the cache expires someone that uses the application will have to wait again which is not that nice.
The Team Foundation Server is able to notify whenever a new build is available. So basically the idea is that the application could react on that notification. In order to be notified I have to write a web service and register it with the TFS. That worked pretty well so far. The web service is now notified whenever a new build is done. Now I would like to connect my web application to the web service and whenever the web service is notified by the TFS update the cache of the web application. Here starts the problem. How can this be achieved? First I thought that the web service could fire a .NET event and the web application could react on that event but that does not seem to be possible. The next idea was that both the web service and the web application could use the same cache. The web service could then directly update the cache with the build information it receives from the Team Foundation Server but I am not even sure if this works.
Can a web service and a web application share the same cache? The web service doing something like Cache.Add("key", buildInfo) and the web application buildInfo = Cache["key"]. If not what other approach could be used to solve such a scenario?
View 4 Replies
Oct 27, 2010
I have one website over at utopiapimp.com. The website is used for a popular web based game. Some company internets don't allow the website to be accessed so I opened up another domain at utopiashrimp.com. Same website but a different iss application. Both have same database backends. They also both sit on the same virtual machine. I put my brand new code on shrimp and solve bugs with that code. I host the solid code on pimp. So I can't just forward the shrimp domain to pimp because I need a test bed.
The problem is that they don't share the same application cache. So my question is, can two websites share the same application cache? I really need to figure this out. I would rather not create a webservice and or a handler that one website needs to hit to change the cache on the other application.
View 2 Replies
Feb 26, 2010
I've got a web application that runs of a state server. It looks like soon it may need to distributed and there will be two web servers behind a load balancer.
This works great for session state but my next challenge is Cache
My application leverages heavily of cache. I understand ASP.Net 4.0 will be offering more here but nothing much has been said about the how too.
There are two challenges that I face
1). Each webserver will have its own copy of cache whereas it would be more efficient to put this to a third server the same as session state is put to state server.
2). The real challenge is keeping cache in sync if a simple dataset derived from the database is changed my code dumps that cache item and reloads the cache. That's all well on one webserver but webserver number two wont know to drop that particular cache item and reload it. This could cause some unexpected problems in the application.
For scenario number 2 I could attempt to do some smart coding so server number two knows to dump the cache and reload it.
My guess is someone else has already been here before and there's probably a better implementation approach rather than writing extra code.
Does anyone know how I could achieve the goal of keeping Cache in sync between multiple webservers or even better farm Cache management to another server?
View 2 Replies
Dec 9, 2010
Imagine a website where individual clients can see each-other's presence - like a social network or a chatroom.
For example:
Client1 connects to my website.The back-end C# code updates a static field to indicate Client1's presence.
Client2 connects to my website.Will the back-end C# code for the second request see the information stored in the static field from the first request? Is there anything I need to do to guarantee that these seperate instances of my ASP application are sharing static data?
View 4 Replies
Mar 6, 2010
I see a ton of questions about uploading multiple files, but none about uploading a single file to multiple servers, so here goes... I have an ASP.NET app that will be running on two load balanced servers, and I would like to allow users to upload files and have them end up on both servers. What is the cleanest way to do this? I am using IIS 6 btw. Some ideas that come to mind are:
1) Use a virtual directory that points to some shared location that both servers can access. Will there be any access issues if the application runs at Network Service? I'm assuming the application will need to run as a user account that exists on the shared location machine. How should the permissions be set for this?
2) It would be nice if I could via jQuery post the request to both of my servers, referencing them by their port numbers. Even though the servers are on the same domain, this violates the same origin policy, right? Is there another solution I'm overlooking? How do other sites do this?
View 4 Replies
Mar 7, 2011
I have two applications with a single domain name ([URL] and [URL]). First one has been developed in .NET 2 and the other one with .NET 4. I have configured web.config as these steps:
1- I've set the same machine key for both of them.
2- I've set the coockie name.
3- I've set the domain name to "domain.com".
4- Also, I've set hardcoded coockie domain name to "domain.com" .
Everything was working fine when both of them were running on a single web server. Recently, I've been asked to move test.domain.com to another server. After moving, authentication ticket is not valid on the second server. I tested both of them on a single server again and everything was workinh fine, but in two servers users can't acces to test.domain.com. (Authentication Ticket is invalid)
Edited: The second server is a virtual (VMWare) server. I don't have any problem in physical servers. I checked the server's time to be synchronized. I also used fiddler to see if the server does not get the auth ticket and ther ticket is sent to the 2nd server. Note: Servers are located in different networks and maybe proxy or firewall causes this (I've no idea)
View 3 Replies
Jan 30, 2010
How do i store same file into multiple servers? My scenario is explained below Administrator module resides in production server ( "cccc" domain) which is accessible only within my company. Common module resides in DMZ and can be accessed by internet users. I have written a program to upload a .xls file to both the servers. My program is in administrator module and resides in cccc domain. I could upload the file to the server in my company but i cant upload it in DMZ. Following is the code to upload to ccc domain
FileInput.PostedFile.SaveAs(Server.MapPath("..TU" & ServerFileName))
Followins is the code to upload to dmz
FileInput.PostedFile.SaveAs("http://grtr/" & "/TU/" & ServerFileName) I will get the serverfilename using file upload control
View 4 Replies
May 17, 2010
We have built an asp.net application according to 3 tier architecture, but Data Tier and Application logic lies on the same server. Our client needs that to be deployed in 2 different servers. Only front end in web server DAL & BLL in app server. Database is in different server. All 3 servers are at different physical locations. How can we commuicate between these servers and our applicaton tiers? is there any option in IIS so that we can deploy only back end code in another server? what is the best approach to communicate between different application tiers when they are physically apart?
View 2 Replies
Feb 7, 2011
We have an IVR product that reads a configuration database for callflow information. I am writing a tool for our implementation team that will allow them to add/delete/update the data in the configuration database. Once the tool is in production, the implementer will use only the production release of the tool to modify the configuration database in all four of the IVR regions (Dev, QA, Cert, and Prod). Each region has its own database with identical schemas. The tool has 'tabs' across the top for each region. If a user is currently working in the Dev region and clicks the QA tab, how do I switch my connection from the Dev db server to the QA db server?
View 3 Replies
Mar 28, 2011
A friend and I manage a large website for a company. The site is build using Visual Studio 2005 and is a series of nested web applications run inside a master application employing nested master pages. Currently we have to manually move files around folders and FTP them to various servers and I am looking for a way to be able to manage the deployment end of the site in a more automated fashion. I'd like to be able to work on my local version of a project and once I'm done be able to hit one button and publish the site to our internal testing server and then when testing is complete hit another button to deploy it to the live web servers. Right now we have to manually navigate the windows folders and copy pages, css files, images, swfs, etc and FTP them manually. The driver for this is that we have a new junior develop starting and want to remove the manual aspect in advance of him starting.
View 1 Replies
Jan 13, 2010
how can I synchronize sessionID over multiple second-domain servers? For example, I've got servers(you can log-in into server swarm at any of these), [URL], [URL], [URL] and if you log in at one of them, the login information (+anything else) should persist along them. How can I provide SessionID to other domains? (session itself is stored on sql server shared across the services).
View 2 Replies