Distributed Cache (MemCached)

Source: Internet
Author: User
Tags memcached

Recently, I've been looking for a job to get ready. NET basic knowledge, found a lot about the way the value of the page, there is a session, but also found that the session in the actual use of the process has a lot of problems. The most typical and most important bug is that if there are a lot of processes in IIS, there is not enough memory to use the garbage collection mechanism, it will cause the session to be lost. The workaround is that you can store the session in a sate server or SQL Server database, but both of these approaches have the disadvantage of slow processing and the inability to capture the end event. Therefore, I would like to think that there is still a way to solve this problem?

The result is the use of distributed cache (MemCached). So what is distributed caching? What advantages does it have? Here are some tips that I've summarized by looking up data.

What is memcached?
Memcached is a high-performance, distributed memory object caching system developed by Danga Interactive for reducing database load and increasing access speed in dynamic applications.

Second, memcached can cache what?
By maintaining a unified, huge hash table in memory, memcached can be used to store data in a variety of formats, including images, videos, files, and the results of database retrieval.

Three, memcached fast?

Very fast. Memcached uses libevent (using Epoll under Linux if possible) to equalize any number of open links, use non-blocking network I/O, and implement reference counting for internal objects (so objects can be in various states for multiple clients). Use your own page block allocator and hash table, so virtual memory is not fragmented and the time complexity of virtual memory allocation is guaranteed to be O (1).

Danga Interactive developed memcached for the speed of Danga Interactive. Currently, LiveJournal.com has provided up to 20 million page visits per day to 1 million of users. These, however, are done by a cluster of Web servers and database servers. Memcached almost completely abandons the way any data is read from the database, and it also shortens the speed at which the user can view the page, better resource allocation, and access to the database when the memcache fails.

Four, the characteristics of memcached
The memcached cache is distributed and can be accessed simultaneously by multiple users on different hosts, thus solving the limitations of shared memory only for single-machine applications, and less disk overhead and blocking when using databases to do similar things.

Five, memcached has the following characteristics:

1) High performance: When traditional databases face large-scale data access, disk I/O tends to be a performance bottleneck, resulting in excessive response latency. Distributed cache as the storage medium for data objects, the data is stored in key/value form, and the DRAM level reading and writing performance can be obtained in the ideal situation;

2) Dynamic scalability: Supports elastic scaling to provide predictable performance and scalability by dynamically increasing or reducing nodes ' response to changing data access loads, while maximizing resource utilization;

3) High availability: Availability includes both data availability and service availability. High availability based on redundancy, no single point of failure, support for automatic failure detection, transparent failover implementation, The cache service is not interrupted or data is lost due to server failure. Automatically balances data partitioning when dynamically expanding, while ensuring that the cache service is continuously available;

4) Ease of use: provide a single data and management view; API interface is simple, and is not related to the topology, dynamic expansion or failure recovery without manual configuration, automatic selection of backup nodes, most of the cache system provides a graphical management console, easy to unify maintenance;

5) Distributed Code Execution (distributed code Execution): Transfer the task code to each data node in parallel execution, the client aggregation returns results, thus effectively avoiding the movement and transmission of the cached data. Latest Java The data grid specification JSR-347 has been added to the API support for distributed code execution and Map/reduce, and mainstream distributed cache products such as IBM WebSphere EXtreme scale,vmware gemfire,gigaspaces XAP and Red Hat Infinispan also supports this new programming model.

The typical application scenarios of memcached can be divided into the following categories:

1) page caching. Content fragments that are used to cache Web pages, including HTML, CSS, and images, are applied to social networking sites and more;

2) Apply the object cache. The caching system serves as the two level cache of the ORM framework to relieve the load pressure of the database and accelerate the application access.

3) state cache. The cache includes the session state and the state data when the application is scaled out, such data is generally difficult to recover, high availability requirements, and more applications in high-availability clusters;

4) Parallel processing. Usually involves a large number of intermediate calculation results need to be shared;

5) event handling. Distributed cache provides continuous query (continuous query) processing technology for event flow to meet real-time demand;

6) Extreme transaction processing. Distributed cache provides high throughput, low latency solutions for transactional applications, supports high concurrent transaction request processing, and is used in many fields such as railways, financial services, and telecommunications.

Distributed Cache (MemCached)

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.