![background image](http://html1.mh-extra.com/html/oracle/5-0/5-0_reference-manual_16461962688.webp)
Mysqlnd query result cache plugin (
mysqlnd_qc
)
2668
is_select( CREATE TABLE test(id INT)): do not cache
is_select( INSERT INTO test(id) VALUES (1), (2), (3)): do not cache
is_select( SELECT id FROM test WHERE id = 1): cache
is_select( SELECT id FROM test WHERE id = 1): cache
is_select( SELECT * FROM test): cache
Cache put: 2
Cache hit: 1
The examples callback tests if a statement string matches a pattern. If this is the case, it either returns
TRUE
to cache the statement using the global default TTL or an alternative TTL.
To minimize application changes the callback can put into and registered in an auto prepend file.
20.7.7.4.6. Slam defense
Copyright 1997-2012 the PHP Documentation Group. [2230]
A badly designed cache can do more harm than good. In the worst case a cache can increase
database server load instead of minimizing it. An overload situation can occur if a highly shared cache
entry expires (cache stampeding).
Cache entries are shared and reused to a different degree depending on the storage used. The default
storage handler stores cache entries in process memory. Thus, a cache entry can be reused for the
life-span of a process. Other PHP processes cannot access it. If Memcache is used, a cache entry can
be shared among multiple PHP processes and even among multiple machines, depending on the set
up being used.
If a highly shared cache entry stored, for example, in Memcache expires, many clients gets a cache
miss. Many client requests can no longer be served from the cache but try to run the underlying query
on the database server. Until the cache entry is refreshed, more and more clients contact the database
server. In the worst case, a total lost of service is the result.
The overload can be avoided using a storage handler which limits the reuse of cache entries to few
clients. Then, at the average, its likely that only a limited number of clients will try to refresh a cache
entry concurrently.
Additionally, the built-in slam defense mechanism can and should be used. If slam defense is activated
an expired cache entry is given an extended life time. The first client getting a cache miss for the
expired cache entry tries to refresh the cache entry within the extended life time. All other clients
requesting the cache entry are temporarily served from the cache although the original
TTL
of the
cache entry has expired. The other clients will not experience a cache miss before the extended life
time is over.
Example 20.312. Enabling the slam defense mechanism
mysqlnd_qc.slam_defense=1
mysqlnd_qc.slam_defense_ttl=1
The slam defense mechanism is enabled with the PHP configuration directive
mysqlnd_qc.slam_defense
. The extended life time of a cache entry is set with
mysqlnd_qc.slam_defense_ttl
.
The function
mysqlnd_qc_get_core_stats
returns an array of statistics. The statistics
slam_stale_refresh
and
slam_stale_hit
are incremented if slam defense takes place.
It is not possible to give a one-fits-all recommendation on the slam defense configuration. Users are
advised to monitor and test their setup and derive settings accordingly.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...