php memcacheとphp memcachedの違いと関連問題

2902 ワード

1.Php memcacheの問題
1.1分散型問題
php memcacheはデフォルトでインスタンスを自動的に切り替えるため、古いデータが取得され、valueがふらふらしている場合があります.
ネットユーザーが共有する質問:
ここ数日、ある製品を作るときに小さな問題に遭遇しました.現象は奇妙で、製品は2台の分布式memcachedサーバーを使っています.あるカウンタが取り戻した数はたまに間違っていて、最後にphp memcache clientのfailoverメカニズムの上に位置します.
memcached分布環境では,あるkeyがhash計算によりあるmemcached上に割り当てられることを知っている.
php.中身は?allow_failover=1の場合、分散環境で、あるmemcachedに問題が発生すると、自動的に他のmemcachedに試してみて、上記の問題が発生します.だからallow_を設定するfailover=0では、他のmcから取得することなく、取得できない場合に失敗を直接返します.これにより、ネットワーク異常やserverエンド異常を回避するために、インスタンスを頻繁に切り替え、古いデータを取得します.
1.2高さと安定性の問題
新浪微博が述べた教訓:
php memcacheをphp memcachedに置き換えると、高並列安定下で極めて向上する.
さらに機能が多く、エラーコードがより正確です.
Twitterのキャッシュ経験
多層Cacheは、いくつかのcacheノードのダウンタイムの影響を軽減し、読み書きもcacheである.
memcached apiをlibmemcachedに統一的に変更します(マルチ言語でmemcachedにアクセスしやすく、分散など様々なルールが一致します.)
1.3 1秒タイムアウト間隔で問題を修正できません
php memcacheクライアントには1秒超時間間隔で修正できない問題があります.
bool Memcache::connect ( string $host [, int $port [, int $timeout ]] )
3番目のパラメータは本来timeout、単位秒を設定できますが、変更できません.
次の3つのtimeoutを変更する方法が無効であることをテストしました.
1.3.1.memcache api Memcache::setServerParamsでは変更できません.
1.3.2.memcacheソースvi php_を変更memcache.hマクロ定義は変更できません.
1.3.3. php.ini内この構成:default_socket_timeout=60は、このtimeoutに対して無効です.
2.memcacheとmemcachedの比較
Php memcacheという古いクライアントは属性設定の面で設定できることは少ない.
エラーコードの粒度が太く、エラー後の位置決めが難しい.
機能が欠けています
There are primarily two clients used with PHP. One is the older, more widespread pecl/memcache and the other is the newer, less used, more feature rich pecl/memcached.
Both support the basics such as multiple servers, setting vaules, getting values, increment, decrement and getting stats.
Here are some more advanced features and information.
                pecl/memcache       pecl/memcached
First Release Date      2004-06-08      2009-01-29 (beta)
Actively Developed      Yes             Yes
External Dependency     None            libmemcached
Automatic Key Fixup1    Yes             No
Append/Prepend          No              Yes
Automatic Serialzation2 Yes             Yes
Binary Protocol         No              Optional
CAS                     No              Yes
Compression             Yes             Yes
Communication Timeout   Connect Only    Various Options
Consistent Hashing      Yes             Yes
Delayed Get             No              Yes
Multi-Get               Yes             Yes
Session Support         Yes             Yes
Set/Get to a specific server    No          Yes
Stores Numerics         Converted to Strings    Yes

コメント:
1 pecl/memcache will convert an invalid key into a valid key for you. pecl/memcached will return false when trying to set/get a key that is not valid.
2 You do not have to serialize your objects or arrays before sending them to the set commands. Both clients will do
転載は出典を明記してください.http://www.ttlsa.com/html/2467.html