nginx+memcached Cache Design

Source: Internet
Author: User

Single page Caching scheme

Single-Static page caching

Problem solving Scenario

The common cache design uses System.Web.Cache in memory and is efficient to reduce the stress of database access. But in addition to the web to get data, there are rendering page rendering, the generation of HTML many features are consumption performance. There is also a need for a cache at the Web layer, while the flexible design, application code does not require big changes.

Architecture

Client Access /report

Nginx receives the request, determines whether the memcached exists with the URL of the Key, the presence of direct return does not pass through IIS, does not exist, is uploaded to IIS, and is saved in memacched

Advantage:memcached performance, easy to deploy the cluster. It is easier to manage than static generation and does not generate disk IO. Flexible design, application code does not require any modification.

Problem: Save page Default 1m limit,key maximum length 256 bits, longest expires 30 days

Cache policy: Passive expiration (design fixed expiration time), background thread update requires updated URL, add #refresh配置成自动触发更新to URL

Test results:



DEMO:

1. Installing memcached

Unzip, run memcached.exe-d install in CMD after running successfully installed the memcached service in the Windows service , start it.

You can determine if the installation started successfully by Telnet 127.0.0.1 11211

2. Run a ASPNET Web site

The URL of the /report path under the page we will cache thes

3. Run nginx (windows for test environment, compile with VC2010)

Unzip, Configure the Conf nginx.conf in the current directory

Among them proxy_pass http://localhost:48273/Report/; For the back-end IIS proxy address, modify the port to the actual address

CMD running nginx.exe will start nginx

4. Access http://localhost:81/Report/View cache effects


Extended:

The presence of personal information on the page can use CSI technology (the page uses Ajax to call personal information data) or use ESI tags to configure the vanish server to resolve the next re-parsing

Required tests for Windows versions Nginx and memcached

Http://files.cnblogs.com/files/yuzukwok/NginxMemcached%E8%BD%AF%E4%BB%B6.rar

nginx+memcached Cache Design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.