Oracle 5.0 Reference Manual page 2688

Table of Contents

Advertisement

is_select(
is_select(
is_select(
is_select(
is_select(
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
to cache the statement using the global default TTL or an alternative TTL.
TRUE
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
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
slam_stale_refresh
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.
Mysqlnd query result cache plugin (mysqlnd_qc)
CREATE TABLE test(id INT)): do not cache
INSERT INTO test(id) VALUES (1), (2), (3)): do not cache
SELECT id FROM test WHERE id = 1): cache
SELECT id FROM test WHERE id = 1): cache
mysqlnd_qc_get_core_stats
and
slam_stale_hit
SELECT * FROM test): cache
returns an array of statistics. The statistics
are incremented if slam defense takes place.
2668
of the
TTL

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents