In the previous article, the need for a tomcat cluster has been clarified, primarily from high availability and high concurrency considerations. In general, the Tomcat cluster is built using a pre-set nginx or Apache as a reverse proxy to forward the request to back-end tomcat. Using the Tomcat cluster will inevitably lead to session data sharing issues. How to solve this problem? Can be achieved with memcached.Main content
Test the throughput rate of a single tomcat
Build a apache+
Way:First, Telnet access to the memcached cache system (mainly for teaching, not discussed)telnet 127.0.0.1 11211 = telnet IP address port numberStoring data in memcachedAdd Username 0 5 = + add: Adding commandsUsername:key's name (is stored in key/value)0: Marked, usually without tube60: How long the cache, more than the time automatically deleted, units (seconds) s5: Indicates the size of the data put inNote: If a key already exists, then adding dat
Debian8 (amd64) install and deploy Memcached management tool MemAdmin
Directory1. Introduction to memadmin tools2. Install nginx and php Environments3. memadmin tool deployment4. simple use of memadmin tools5. Additional configuration optimization6. Summary
1. Introduction to memadmin toolsMemAdmin is a visualized Memcached management and monitoring tool. It is d
divided into several chunk memory blocks (chunks in different slab are not the same size)Memcached maintains a memory allocation information table, which writes data to the slab partition central area that has the most chunk size and data size, which can reduce memory wasteTip: Similar to disk Inode,block7, memcached deletion principle and delete mechanism? Memcached
How to use:
Memcached
Copy the Code code as follows:
$cache = new Cache_memcache ();$cache->addserver (' www1 ');$cache->addserver (' www2 ', 11211,20); This server has double the memory, and gets double the weight$cache->addserver (' www3 ', 11211);Store some data in the cache for ten minutes$cache->store (' My_key ', ' foobar ', 600);Get it out of the cache againEcho ($cache->fetch (' My_key '));
File cache
Copy the Code code as follows:
$cache =
How can I change the default cache time of memcached ?, Memcached Cache
When we use the memcached extension of php to add data to memcached, there are two methods for data validity. For example.
AsSet a UNIX timestamp or an integer in seconds (time difference from the current time) to indicate the data expiration t
up in MC driven by app and passed to Ms as parameter.
At the same time, Ms use is lazy substitution method, MS will not open an additional process to real-time monitoring of the outdated KV and delete, but when and only when the new to insert the data, and at this time there is no extra space to put, before the removal action.
Vi. code Examples
Memcached Cache Utility Class Memcached.java
Package com.memc
-tool command, you can see that each item occupies a size (chunk size) gap of 1.25
Command: # memcached-tool 127.0.0.1:11211 Display
memcached How to expire data
Lazy Expiration
Memcached internally does not monitor whether the record is out of date, but instead looks at the timestamp of the record at get and checks whether the record is out
the record is out of date, but instead looks at the timestamp of the record at get and checks whether the record is out of date. This technique is called lazy (lazy) expiration. As a result, memcached does not consume CPU time on outdated monitoring.
Lru
Memcached takes precedence over the space of a record that has timed out, but even so, ther
1, ready to install software memcached and libevent (I am the latest version under the official website libevent-2.0.21-stable.tar.gz and memcached-1.4.21.tar.gz)2, Installation Libevent1) Unzip the fileTAR-ZXVF libevent-2.0.21-stable.tar.gz2) Specify the installation path./configure--prefix=/opt/3) InstallationMakeMake install 4) test whether the installation is successfulLs-al/opt/lib | grep libevent3, i
Respect knowledge, reprinted please indicate this article from: programming artist poechant csdn blog http://blog.csdn.net/poechant
1. Non-cas
First, let's look at a memcached program instance that is not CAS. For more information about the prototype of the instance, see the previous blog.
Program instance:
package com.sinosuperman.memcached;import java.io.IOException;import java.net.InetSocketAddress;import net.spy.memcached.MemcachedClient;public
1, memcached is how to work.
The magic of memcached comes from the two phase hash (two-stage hash). Memcached is like a huge hash table that stores a lot of The client can store the data on multiple sets of memcached. When querying for data, the client first refers to the node list to compute the hash value (phase one
Memcached is a high-performance, distributed memory object caching system developed by Dangainteractive, and how best to use memcached to improve site performance? Let's have a look.I. Introduction of MemcachedMemcached is often used to speed up the processing of applications, where we will focus on best practices for deploying it in applications and environments. This includes the flexible distribution of
;array (' 192.168.254.213 ', ' root ', ' 1 ', ' Mydz '),
' Slave_1 ' =>array (' 192.168.254.144 ', ' root ', ' 1 ', ' mydz ')//flexibility to add multiple slave servers
);
?>
The Memcached itself starts with the following sequence in the main function of MEMCACHED.C:
1. Call Settings_init () to set initialization parameters2. Set the setting value by reading the parameters from the start command3. Set LIMIT parameter4. Start Network socket
Martin Brown, freelance writer and freelance Martin Brown has been a professional writer for more than seven years. He is the author of a wide range of books and articles. He specializes in a variety of development languages and platforms-perl, Python, Java, JavaScript, basic, Pascal, Modula-2, C, C ++, REBOL, gawk, shellscript, windows, Solaris linux, BEOs, Mac OS/X, etc, it also involves web programming, system management, and integration. Martin is a Microsoft theme expert (SME) and regular c
Install and configure Memcached source code in CentOS 6.6
Host environment: CentOS 6.6 x86_64
1. Install Memcached
1. Because Memcached depends on the libevent library and uses it for Socket processing, we need to install the libevent library. Here I will use yum to install it.
Yum install libevent
2, download memcached
I. If an official method is used, each parameter and server IP are configured in the Web. config. Such as: The generic class is used, and the component automatically calls the configuration inside the Web. config.Using system;using system.collections.generic;using system.linq;using system.web;using Enyim.Caching;using enyim.caching.configuration;using enyim.caching.memcached;///Two. If you do not want to configure the Web. config, use the following generic class.Using system;using system.collect
to their advantages.
PHP has an extension to operate on Memcached. It provides a set of functions to operate on the Memcached server. they are simply divided into the following classes:
1. Memcached connection functions (connect, pconnect)
2. memcahced operation functions (set, get, delete, replace, flush)
3. multi-server configuration function (addServer)
4. s
Memcached is a cache, so data is not permanently stored on the server, which is the precondition for introducing memcached into the system.This article introduces the data deletion mechanism of memcached and the latest development direction of memcached-binary protocol (binary Protocol) and external engine support.
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.