做一个ASP.NET MVC应用程序的Web农场就绪 [英] Make an ASP.NET MVC application Web Farm Ready

查看:281
本文介绍了做一个ASP.NET MVC应用程序的Web农场就绪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么将是使ASP.NET MVC应用程序的Web农场准备最有效的方式。

What will be the most efficient way to make an ASP.NET MVC application web-farm ready.

更重要的是分享当前用户的信息(上下文)和(不那么重要)缓存的对象,如查询项目(美国,街道类型,县等)。

Most importantly sharing the current user's information (Context) and (not so important) cached objects such as look-up items (States, Street Types, counties etc.).

我听到/读取内存缓存,但还没有看到关于如何实现并测试它的简单适用的方法(文档)。

I have heard of/read MemCache but haven't seen a simple applicable way (documentation) on how to implement and test it.

推荐答案

请求上下文结果
击中Web场的任何请求被通过一个可用的IIS服务器提供服务。上下文被创建并有全请求被由同一个服务器提供服务。所以上下文不应该是一个问题。请求是无国籍执行管线,因此不需要以任何方式或形式的其他服务器共享数据。它会从一开始就由同一台机器最终送达。结果
用户信息从一个cookie读取和服务于该请求的服务器处理。这要看那么如果你的地方缓存完整的用户对象。

Request context
Any request that hits a web farm gets served by an available IIS server. Context gets created there and the whole request gets served by the same server. So context shouldn't be a problem. A request is a stateless execution pipeline so it doesn't need to share data with other servers in any way shape or form. It will be served from the beginning to the end by the same machine.
User information is read from a cookie and processed by the server that serves the request. It depends then if you cache complete user object somewhere.

会议结果
如果你使用的TempData 字典你应该知道,它的内部存储会话字典。在服务器场,这意味着你应该使用其他手段,而不是是InProc会话,因为他们不能跨越农场IIS服务器之间共享。您应该配置其他会话管理器,要么使用DB或他人(国家服务器等)。

Session
If you use TempData dictionary you should be aware that it's stored inside Session dictionary. In a server farm that means you should use other means than InProc sessions, because they're not shared between IIS servers across the farm. You should configure other session managers that either use a DB or others (State server etc.).

缓存结果
当涉及到缓存这是一个不同的故事。为了使它尽可能高效的高速缓存应该也送达。默认情况下它不是。但看缓存它几乎意味着当没有缓存应该读取并存储在缓存中。所以,如果一个特定的服务器场服务器没有一些缓存对象,将创建它。随着时间的推移他们都将缓存一些共享公共使用的数据。结果
或...你可以使用库例如的memcached (正如你所提到它),利用共享缓存。上有净如何使用它的几个例子。

Cache
When it comes to cache it's a different story. To make it as efficient as possible cache should as well be served. By default it's not. But looking at cache it barely means that when there's no cache it should be read and stored in cache. So if a particular server farm server doesn't have some cache object it would create it. In time all of them would cache some shared publicly used data.
Or... You could use libraries like memcached (as you mentioned it) and take advantage of shared cache. There are several examples on the net how to use it.

但是,这些解决方案都带来的几件事情(如网络和第三工艺处理和数据获取等),如果没有其他额外开销。因此,默认缓存是最快的,如果你需要明确地共享缓存,然后决定之一。不共享缓存,除非确有必要。

But these solutions all bring additional overhead of several things (like network and third process processing and data fetching etc.) if nothing else. So default cache is the fastest and if you explicitly need shared cache then decide for one. Don't share cache unless really necessary.

这篇关于做一个ASP.NET MVC应用程序的Web农场就绪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆