在重负载Web服务器上缓存数据 [英] Caching Data on a Heavy Load Web Server

查看:146
本文介绍了在重负载Web服务器上缓存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个网络应用程序,在每个网页上请求从当前登录的用户的数据库中获取用户数据。

I currently have a web application which on each page request gets user data out of a database, for the currently logged in user.

此网络应用程序可能有大约30万个并发用户。

This web application could have approximately 30 thousands concurrent users.

我的问题是,最好是缓存这个。例如在C#中使用 System.Web.HttpRuntime.Cache.Add

My question is would it be best to cache this. For example in C# using System.Web.HttpRuntime.Cache.Add

或者这会削弱服务器内存存储在内存中最多有3万个用户对象?

or would this cripple the servers memory storing up to 30 thousand user objects in the memory?

最好不要缓存,只是从每个请求的数据库中获取所需的数据?

Would it be better to not cache and just get the required data from the database on each request?

推荐答案

在这个规模,你需要一个显式的缓存和缩放策略。一起缓存高速缓存不同于规划明确的策略。一起缓存缓存将失败。

At that scale you need an explicit caching and scaling strategy. Hacking together a cache is different from planning an explicit strategy. Hacking together a cache will fail.

缓存是高度的,取决于数据。数据是否频繁更改?你要有什么比率的读写?您如何扩展数据库?如果Web场中的服务器具有不同的数据值,会发生什么情况?缓存一致性是否至关重要?

Caching is highly dependent upon the data. Does the data change frequently? What ratio of reads-to-writes are you going to have? How are you going to scale your database? What happens if the servers in your web farm have different values for the data? Is cache consistency critical?

您最终可能会遇到几种不同类型的缓存:

You'll probably end up with several different types of caching:


  1. IIS静态缓存

  2. ASP.Net缓存

  3. 您的应用程序中的LRU缓存。

  4. 内存分布式缓存,如MemCacheD。

  5. 浏览器中的HTTP缓存。

  1. IIS Static Caching
  2. ASP.Net Caching
  3. An LRU cache in your app.
  4. An in-memory distributed cache such as MemCacheD.
  5. HTTP caching in the browser.

此外,如果您要提供静态数据(图片,CSS,Javascript等),您需要集成CDN交付。这是与AWS S3或Azure存储容易做。

Also, if you're serving static data (Images, CSS, Javascript, etc) you'll want to integrate with a CDN for delivery. This is easy do with with AWS S3 or Azure Storage.

您还需要确保计划如何从开始扩展。您可能需要使用 Elastic Bean Stalk Azure的网站基础设施

You'll also want to make sure you plan how to scale out from the get-go. You'll probably want to deploy to a cloud provider such as AWS with Elastic Bean Stalk or Azure's Websites Infrastruture.

这篇关于在重负载Web服务器上缓存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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