{"action":"created","issue":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/10343","labels_url":"https://api.github.com/repos/phalcon/cphalcon/issues/10343/labels{/name}","comments_url":"https://api.github.com/repos/phalcon/cphalcon/issues/10343/comments","events_url":"https://api.github.com/repos/phalcon/cphalcon/issues/10343/events","html_url":"https://github.com/phalcon/cphalcon/issues/10343","id":76059663,"number":10343,"title":"Libmemcached cache\\backend performance regression","user":{"login":"patrick-zippenfenig","id":11670456,"avatar_url":"https://avatars.githubusercontent.com/u/11670456?v=3","gravatar_id":"","url":"https://api.github.com/users/patrick-zippenfenig","html_url":"https://github.com/patrick-zippenfenig","followers_url":"https://api.github.com/users/patrick-zippenfenig/followers","following_url":"https://api.github.com/users/patrick-zippenfenig/following{/other_user}","gists_url":"https://api.github.com/users/patrick-zippenfenig/gists{/gist_id}","starred_url":"https://api.github.com/users/patrick-zippenfenig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrick-zippenfenig/subscriptions","organizations_url":"https://api.github.com/users/patrick-zippenfenig/orgs","repos_url":"https://api.github.com/users/patrick-zippenfenig/repos","events_url":"https://api.github.com/users/patrick-zippenfenig/events{/privacy}","received_events_url":"https://api.github.com/users/patrick-zippenfenig/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-05-13T17:19:18Z","updated_at":"2015-09-10T10:18:35Z","closed_at":"2015-09-09T14:54:24Z","body":"Hi!\r\n\r\ntl;dr: please disable \"statKey\" (storing ALL keys) per default\r\n\r\nI just spend 6 hours debugging a performance regression in memcache. One of three memcached servers updated keys at to up 130Mbit/s. In the last couple of days totals >5TB. Network bandwidth showed an odd pattern:\r\n![unknown-3](https://cloud.githubusercontent.com/assets/11670456/7615862/abea6010-f9a0-11e4-9ec1-7ed83f21a8f6.jpeg)\r\n\r\n\r\nI suspected the issue anywhere but in phalcon as it is a quite complex webapplication with a lot of objects in memcached. I started logging cache set/get's, changed cache keys to prevent possible uneven distribution, binary protocol, compression, implemented persistent memcached connections, analysed access-logs, etc.\r\n\r\nAfter tcp_dump'ing memcache packets and analysing traffic flow I recognised \"_PHCM\" was updated very frequently. A quick look at [libmemcached.zep#L87](https://github.com/phalcon/cphalcon/blob/master/phalcon/cache/backend/libmemcached.zep#L87) reveals: \"statKey\" feature is enabled per default. Every updated key is stored as an entry in memcached to enable ````$cache->flush()```` capabilities. ````\"statKey\" => \"\"```` solved the issue, dropped load by half, freed a few GB of memory (memcache+php) and reduced network bandwidth to a regular level.\r\nPhalcon queried \"_PHCM\" for each ````$cache->save()````, added the modified key and stored it again in \"_PHCM\". After some time time an internal limit was hit, crashed and it started all over again (see bandwidth graph).\r\n\r\nI doubt that any application use ````flush()```` in production. I would like to request to disable this behaviour per default in all cache backends. An exception is already thrown in ````flush()```` if \"statKey\" is disabled.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/comments/139197169","html_url":"https://github.com/phalcon/cphalcon/issues/10343#issuecomment-139197169","issue_url":"https://api.github.com/repos/phalcon/cphalcon/issues/10343","id":139197169,"user":{"login":"sergeyklay","id":1256298,"avatar_url":"https://avatars.githubusercontent.com/u/1256298?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeyklay","html_url":"https://github.com/sergeyklay","followers_url":"https://api.github.com/users/sergeyklay/followers","following_url":"https://api.github.com/users/sergeyklay/following{/other_user}","gists_url":"https://api.github.com/users/sergeyklay/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeyklay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeyklay/subscriptions","organizations_url":"https://api.github.com/users/sergeyklay/orgs","repos_url":"https://api.github.com/users/sergeyklay/repos","events_url":"https://api.github.com/users/sergeyklay/events{/privacy}","received_events_url":"https://api.github.com/users/sergeyklay/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T10:18:35Z","updated_at":"2015-09-10T10:18:35Z","body":"One of my node (frontend) after disabling statsKey\r\n![selection_009](https://cloud.githubusercontent.com/assets/1256298/9785858/2380e952-57be-11e5-99f0-3bb3e0b6fb10.png)"}}