Learning, By the way translation, there are incorrect places welcome correction, reprint please indicate the source of http://cnblogs.com/xuf22
1. What is velocity?
Official Address: http://www.microsoft.com/download/en/details.aspx? Id = 2517
"Velocity" is a high-speed, "scalable in-memory" cache for all data sources. By using this cache, you can reduce unnecessary data source access requests and greatly improve applications.ProgramPerformance. By using distributed cache applications, application requests with increasing throughput can be satisfied. "Velocity" is distributed in a high-speed cache group without human interference, thus reducing the complexity of Server Load balancer. Later release renamed 【Appfabric]
Ii. cache Concept
1. Basic Concepts
1.1 physical concepts
"Velocity" is a cluster of multiple application cache services that can communicate with each other and are unified. The main components of the physical model include cache server, cache host Windows Service, cache cluster, powershell-based Cache Management tool, cluster configuration storage location and cache client.
Cache host(Cache host ):
"Velocity" runs on one or more Windows Services as a service. These services are cache master services. The host running the master cache service is called a cache server. You can still run other programs, such as web services, on a host that has "velocity" installed. However, only one "velocity" instance can be installed on a host.
The cache service host and data source host are preferably in the same domain. The cache host server runs under the network service account and caches the high-speed cache authentication creden。 under various operation scopes on the master service. "Velocity" uses a low-Permission network service account to effectively reduce the damage caused by malicious attacks.
Cache Cluster(Cache cluster ):
A cache cluster is a circular solution composed of one or more cache master services to jointly store and distribute data. Store data in the memory to reduce the response time of the request data. The Operation and Control of a cluster is managed by "cluster management role", which includes the following three points:
1. Keep the cache cluster running
2. monitor all cache hosts in the cache Cluster
3. Help cache hosts join cache Clusters
Cluster configuration storage Zone(Cluster configuration storage location)
Each time a cluster is started, the configuration information must be retrieved from the storage location in the cluster configuration. The following table shows two possible methods:
Powershell-based management tools(Powershell-based Cache administration tool)
Cache Client(Cache client)
"Velocity" distributed cache cluster is designed for application servers in the enterprise data center and deployed in the enterprise firewall. Any cached applications running on the server are collectively referred to as cache clients.
1.2 Logical Model
Logically, velocity is divided into: (named caches) cache naming (I really don't know how to translate this.), (Regions) cache domain and (cached objects) cache object.
Named caches:
Is a distributed cache storage unit formed by the configuration in the memory. You can configure one or more name caches in one application. Each name caches is not affected by other configurations. In this way, you can configure multiple name caches according to program requirements, and each name caches uses different cache policies.
As shown in: Name caches is distributed across each cache host. If you do not specify a name for the cache, your data will be stored under the default "default" cache name.
All caches are defined by cluster configurations. Use the powershell cache management tool to create or reconfigure the cache. Some settings can only be configured when cache is created for the first time. For exampleNew-Cache
Command to enable high availability or notification. Other settings can be changed later, but the entire cache cluster may need to be restarted.
Regions:
Regions is a logical cache storage domain (it can be understood as a namespace ). Regions is optional, not created through configuration, you mustCodeCreate with the createregion function. You can use regions to find all the cache objects under the region. To provide this additional search function, objects in a region are limited to a single cache host. Therefore, applications that use this data cannot achieve the scalability advantage of distributed cache. On the contrary, if you do not specify a region and cache object, otherwise, you can load balance all cache hosts in the cluster.
Caches objects:
The data retrieved from the cache is of the system. Object Type and needs to be converted to obtain its original type. When an object exists with caches, caches associates the version, key, and tag of the object.
1.3 Programming)
When the data does not exist in your client cache, You need to load it again from the caches host. The client uses the datacache class to add the client cache.
Cache Policy (Caching Strategy)
The application is designed to still run normally when no cache exists, because the cache is not permanently valid and there is always a possibility of being invalid or nonexistent. The high availability of velocity can effectively prevent the problems caused by the failure of individual hosts in the cluster. However, if there are too many hosts in the cluster, velocity will still be suspended (equivalent to disk raid, if it breaks down, you can run it ).
There are many other causes that the program cannot find the cache: the cache may have expired or been removed, the cache server may have been restarted, and the cache host service may have been restarted, or the cache cluster may have been accidentally restarted. Therefore, make sure that the application can still access the positive data and run properly without caching.
Cache Client)
To store data in the cache, you can use the getcache method to return a datacache object. The instance after the datacache object is instantiated is called the cache client. There are many options to configure the behavior of the cache client, either programmatically or using the application configuration file, or both.
The following code demonstrates the read/write cache of datacache
Datacache demo // Each application has a similar getcache method call Datachefactory mycachefactory = New Datacachefactory (); datacache catalog = mycachefactory. getcache (" Catalog "); // One cache client saves an object to the catalog named "toy101" Catalog. Put (" Toy101 ", New Toyobject (" Toy101 "," Playschool ")); // The same or different cache client retrieves the object Toyobject toy = (toyobject) catalog. Get (" Toy101 "); // The same or a different cache client removes the object Catalog. Remove (" Toy101 ");
1.4 Configuration Model)
Velocity supports many cache configurations. The configuration can be divided into three levels: application level, cache host level, and cache cluster level. Velocity also provides configurations for specifying and storing cache clusters and client applications.
Application configuration)
Each cache client of velocity must have a cache client configuration. You can specify the configuration in the Code or in the. config file of the application. If both methods are specified, the configuration in the Code overwrites the configuration in the configuration file.
The application settings include the unique configuration that can communicate with the cache hosts, and the local cache configuration must be specified.
Cache Host Configuration)
Each slow storage volume is configured through the distributedcache.exe.configfile. distributedcache.exe. config is automatically created when velocity is installed. This configuration is required for the cache service to run. Generally, you do not need to modify this configuration.
Cluster configuration)
All cache hosts in the cluster service must be configured with the cluster communication permission. The cluster configuration specifies the configuration of cache hosts and named caches. The cluster service configuration is specified when the first cluster cache host is installed, and then the cache host will be automatically synchronized from this host when it is installed.
The cluster configuration has two available options.
Storage Type |
Storage location |
Cluster Management |
SQL Server compact data file |
Shared network folder |
Lead hosts |
SQL Server database |
SQL Server |
SQL Server (default) or lead hosts |
Technorati label: Classified cache-Velocity