Mysql High Performance Memcached (1), mysqlmemcached

Source: Internet
Author: User
Tags value store

Mysql High Performance Memcached (1), mysqlmemcached
This article describes how to install and use Memcached.


What is Memcached?
Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database cals, API cals, or page rendering.
Memcached is simple yet powerful. Its simple design promotes quick deployment, deployment of development, and solves extends problems facing large data caches. Its API is available for most popular ages.




Why Use Memcached?
Benefits of using memcached include:
• Because all information is stored in RAM, the access speed is faster than loading the information
Each time from disk.
• Because the "value" portion of the key-value pair does not have any data type restrictions, you can
Cache data such as complex structures, documents, images, or a mixture of such things.
• If you use the in-memory cache to hold transient information, or as a read-only cache for information
Also stored in a database, the failure of any memcached server is not critical. For persistent data, you
Can fall back to an alternative lookup method using database queries, and reload the data into RAM
On a different server.
The typical usage environment is to modify your application so that information is read from the cache
Provided by memcached. If the information is not in memcached, then the data is loaded from
MySQL database and written into the cache so that future requests for the same object benefit from

Cached data.



Case:
Fotolog, as they themselves point out, is probably the largest site nobody has ever heard of, pulling in more page views than even Flickr. fotolog has 51 instances of memcached on 21 servers with 175G in use and 254G available. as a large successful photo-blogging site they have very demanding performance and scaling requirements. to meet those requirements they 've developed a sophisticated approach to using memcached that others can learn from and emulate.

Download Memcached:
Http://www.memcached.org/files/memcached-1.4.21.tar.gz


In RedHat, the system comes with Memcached, which can be installed using yum:
Yum install memcached


You can also download the package for installation, which is described in detail here.


Basic usage:

[root@ogg1 bin]# memcached -hmemcached 1.4.4-p <num>      TCP port number to listen on (default: 11211)-U <num>      UDP port number to listen on (default: 11211, 0 is off)-s <file>     UNIX socket path to listen on (disables network support)-a <mask>     access mask for UNIX socket, in octal (default: 0700)-l <ip_addr>  interface to listen on (default: INADDR_ANY, all addresses)-d            run as a daemon-r            maximize core file limit-u <username> assume identity of <username> (only when run as root)-m <num>      max memory to use for items in megabytes (default: 64 MB)-M            return error on memory exhausted (rather than removing items)-c <num>      max simultaneous connections (default: 1024)-k            lock down all paged memory.  Note that there is a              limit on how much memory you may lock.  Trying to              allocate more than that would fail, so be sure you              set the limit correctly for the user you started              the daemon with (not for -u <username> user;              under sh this is done with 'ulimit -S -l NUM_KB').-v            verbose (print errors/warnings while in event loop)-vv           very verbose (also print client commands/reponses)-vvv          extremely verbose (also print internal state transitions)-h            print this help and exit-i            print memcached and libevent license-P <file>     save PID in <file>, only used with -d option-f <factor>   chunk size growth factor (default: 1.25)-n <bytes>    minimum space allocated for key+value+flags (default: 48)-L            Try to use large memory pages (if available). Increasing              the memory page size could reduce the number of TLB misses              and improve the performance. In order to get large pages              from the OS, memcached will allocate the total item-cache              in one large chunk.-D <char>     Use <char> as the delimiter between key prefixes and IDs.              This is used for per-prefix stats reporting. The default is              ":" (colon). If this option is specified, stats collection              is turned on automatically; if not, then it may be turned on              by sending the "stats detail on" command to the server.-t <num>      number of threads to use (default: 4)-R            Maximum number of requests per event, limits the number of              requests process for a given connection to prevent              starvation (default: 20)-C            Disable use of CAS-b            Set the backlog queue limit (default: 1024)-B            Binding protocol - one of ascii, binary, or auto (default)-I            Override the size of each slab page. Adjusts max item size              (default: 1mb, min: 1k, max: 128m)
Initialize Memcached:

memcached -u root -d -m 512 -p 11211 -l 192.168.56.12[root@ogg1 bin]# ps -ef |grep memroot      4382     1  0 02:01 ?        00:00:00 memcached -u root -d -m 512 -p 11211 -l 192.168.56.12
View the current Memcached status:

[Root @ ogg1 bin] # telnet 192.168.56.12 11211 Trying 192.168.56.12... connected to 192.168.56.12.Escape character is '^]'. statsSTAT pid 4382 STAT uptime 7288 STAT time 1418893354 STAT version 1.4.4STAT pointer_size 64 STAT rusage_user 0.353946 STAT rusage_system 0.379942 STAT curr_connections 5 STAT limit 8 STAT limit 6 STAT limit _get 0 STAT limit _set 0 STAT limit _flush 0 STAT get_hits 0 STAT get_misses 0 STAT delete_misses 0 STAT delete_hits 0 STAT limit 0 STAT limit 0 STAT limit 0 STAT limit 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 144 STAT bytes_written 1732 STAT limit_maxbytes 536870912 STAT accepting_conns 1 STAT limit 0 STAT threads 4 STAT conn_yields 0 STAT bytes 0 STAT curr_items 0 STAT total_items 0 STAT evictions 0END parameter explanation: pid memcache server process IDuptime Server Run seconds time server current unix timestamp version memcache version pointer_size pointer size of the current operating system (32-bit systems are generally 32bit) cumulative user time of the rusage_user process the cumulative system time of the rusage_system process the number of items currently stored on the curr_items server total_items Total number of items stored after the server is started bytes the number of bytes occupied by items stored on the server curr_connections total number of connections total_connections the number of connections that have been opened since the server was started connection_structures the number of connections allocated by the server pai_get get command (obtained) total number of requests pai_set set command (SAVE) total number of requests get_hits total number of hits get_misses total number of missed calls evictions the number of items deleted to get idle memory (the space allocated to memcache must be deleted after it is full to get space allocation by deleting the old items to the new items) bytes_read total number of bytes read (number of request bytes) bytes_written total number of sent bytes (number of results bytes) limit_maxbytes memory size (bytes) allocated to memcache threads current number of threads




Related Article

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.