D.S

dev.mysql.com

MySQL :: MySQL 5.7 Reference Manual :: 17.2.2.7 Memory Allocation within memcached

MySQL :: MySQL 5.7 Reference Manual :: 17.2.2.7 Memory Allocation within memcached Contact MySQL  |  Login  |  Register The world's most popular open source database MySQL.com Downloads Documentation Developer Zone Developer Zone Downloads MySQL.com Documentation MySQL Server MySQL Enterprise Workbench Router Utilities/Fabric MySQL NDB Cluster Connectors More MySQL.com Downloads Developer Zone Section Menu:   Documentation Home MySQL 5.7 Reference Manual Preface and Legal Notices General Information Installing and Upgrading MySQL Using MySQL as a Document Store Tutorial MySQL Programs MySQL Server Administration Security Backup and Recovery Optimization Language Structure Globalization Data Types Functions and Operators SQL Statement Syntax The InnoDB Storage Engine Alternative Storage Engines High Availability and Scalability Using ZFS Replication Using ZFS for File System Replication Configuring MySQL for ZFS Replication Handling MySQL Recovery with ZFS Using MySQL with memcached Installing memcached Using memcached memcached Command-Line Options memcached Deployment Using Namespaces Data Expiry memcached Hashing/Distribution Types Using memcached and DTrace Memory Allocation within memcached memcached Thread Support memcached Logs Developing a memcached Application Basic memcached Operations Using memcached as a MySQL Caching Layer Using libmemcached with C and C++ Using MySQL and memcached with Perl Using MySQL and memcached with Python Using MySQL and memcached with PHP Using MySQL and memcached with Ruby Using MySQL and memcached with Java Using the memcached TCP Text Protocol Getting memcached Statistics memcached General Statistics memcached Slabs Statistics memcached Item Statistics memcached Size Statistics memcached Detail Statistics Using memcached-tool memcached FAQ Replication MySQL NDB Cluster 7.5 Partitioning Stored Programs and Views INFORMATION_SCHEMA Tables MySQL Performance Schema MySQL sys Schema Connectors and APIs Extending MySQL MySQL Enterprise Edition MySQL Workbench MySQL 5.7 Frequently Asked Questions Errors, Error Codes, and Common Problems Restrictions and Limits Indexes MySQL Glossary Related Documentation MySQL 5.7 Release Notes Download this Manual PDF (US Ltr) - 35.7Mb PDF (A4) - 35.7Mb PDF (RPM) - 34.7Mb EPUB - 8.7Mb HTML Download (TGZ) - 8.5Mb HTML Download (Zip) - 8.5Mb HTML Download (RPM) - 7.3Mb Eclipse Doc Plugin (TGZ) - 9.3Mb Eclipse Doc Plugin (Zip) - 11.5Mb Man Pages (TGZ) - 203.5Kb Man Pages (Zip) - 308.9Kb Info (Gzip) - 3.3Mb Info (Zip) - 3.3Mb Excerpts from this Manual MySQL Backup and Recovery MySQL Globalization MySQL Information Schema MySQL Installation Guide MySQL and Linux/Unix MySQL and OS X MySQL Partitioning MySQL Performance Schema MySQL Replication Using the MySQL Yum Repository MySQL Restrictions and Limitations Security in MySQL MySQL and Solaris Building MySQL from Source Starting and Stopping MySQL MySQL Tutorial MySQL and Windows MySQL Cluster NDB 7.5 version 5.7 8.0 5.6 5.5 5.6  Japanese MySQL 5.7 Reference Manual  /  ...  /  High Availability and Scalability  /  Using MySQL with memcached  /  Using memcached  /  Memory Allocation within memcached 17.2.2.7 Memory Allocation within memcached When you first start memcached, the memory that you have configured is not automatically allocated. Instead, memcached only starts allocating and reserving physical memory once you start saving information into the cache. When you start to store data into the cache, memcached does not allocate the memory for the data on an item by item basis. Instead, a slab allocation is used to optimize memory usage and prevent memory fragmentation when information expires from the cache. With slab allocation, memory is reserved in blocks of 1MB. The slab is divided up into a number of blocks of equal size. When you try to store a value into the cache, memcached checks the size of the value that you are adding to the cache and determines which slab contains the right size allocation for the item. If a slab with the item size already exists, the item is written to the block within the slab. If the new item is bigger than the size of any existing blocks, then a new slab is created, divided up into blocks of a suitable size. If an existing slab with the right block size already exists, but there are no free blocks, a new slab is created. If you update an existing item with data that is larger than the existing block allocation for that key, then the key is re-allocated into a suitable slab. For example, the default size for the smallest block is 88 bytes (40 bytes of value, and the default 48 bytes for the key and flag data). If the size of the first item you store into the cache is less than 40 bytes, then a slab with a block size of 88 bytes is created and the value stored. If the size of the data that you intend to store is larger than this value, then the block size is increased by the chunk size factor until a block size large enough to hold the value is determined. The b