Page 1 of 1

Caching with Memcache taking time

Posted: Fri Jan 18, 2013 6:42 am
by rediff
Hi,

I am trying to setup WURFL API v1.4.4 and when chose caching as memcache it is taking much time to respond but this issue was not seen when file was chosen as caching.

Useragent queried: Mozilla/5.0 (Linux; U; Android 2.3.4; en-gb; GT-S5830 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
$wurflConfig->cache('memcache', array('host' => "127.0.0.1",'port'=>'11211','namespace'=>'wurfl','expiration' => 36000));
Calls made to memcache
[Fri Jan 18 17:04:10 2013] [error] [client xx.xx.xx.xx] WURFL_:wurfl:UserAgentHandlerChain
[Fri Jan 18 17:04:10 2013] [error] [client xx.xx.xx.xx] WURFL_:wurfl:FCACHE_WURFL_WURFL_LOADED
[Fri Jan 18 17:04:32 2013] [error] [client xx.xx.xx.xx] WURFL_:wurfl:FCACHE_generic
[Fri Jan 18 17:04:32 2013] [error] [client xx.xx.xx.xx] WURFL_:wurfl:FCACHE_WURFL_LAST_MODIFICATION_TIME
[Fri Jan 18 17:04:32 2013] [error] [client xx.xx.xx.xx] WURFL_:wurfl:FCACHE_WURFL_XML_INFO
[Fri Jan 18 17:04:32 2013] [error] [client xx.xx.xx.xx] WURFL_:wurfl:f8fa37d97aa8866fb092964065242ed7
[Fri Jan 18 17:04:32 2013] [error] [client xx.xx.xx.xx] WURFL_:wurfl:DEV_samsung_gt_s5830_ver1_suban23

As you can see it is taking 22seconds between FCACHE_WURFL_WURFL_LOADED and FCACHE_generic

Re: Caching with Memcache taking time

Posted: Fri Jan 18, 2013 10:16 am
by kamermans
Does this happen on every request, or just the first request? Also, are you on linux, and which versions of PHP and Memcache are you running, and how much Memcache memory is available? Are you using File for persistence and Memcache for cache?

Re: Caching with Memcache taking time

Posted: Sat Jan 19, 2013 12:53 am
by rediff
Yes am installing on Linux with PHP 5.2.13. with file for persistence and memcache for cache.

Memcache memory in my development environment is set to 250MB which I increased to 1024MB and this issue is resolved.

What is the memory size we need to set so that we will not encounter issue like this in future?

Re: Caching with Memcache taking time

Posted: Sat Jan 19, 2013 10:20 pm
by kamermans
Thanks for the reply. I imagine the issue is that your cache is also being used by other systems and other data is forcing WURFL data out of memcache while it's being loaded or something similar. Technically, this should not be a problem since all the cache lookups will be misses (obviously not ideal), then the requests will go to the filesystem. I'll need to try to reproduce the problem with different amounts of memcache memory to be sure, but I imagine 50MB would store all the WURFL devices with plenty of room for cache requests. Note that we will be adding a feature in the next minor release to allow to specify which WURFL capabilities are loaded. If you choose to load only those capabilities that you need, the memory usage can be significantly decreased.

Re: Caching with Memcache taking time

Posted: Sat Jan 19, 2013 11:03 pm
by rediff
Memcache is not used for any other applications and also it was restarted before the testing. I will also try and simulate the same again.

Also we are just using 5 capabilities and would love to have that update sooner so that it will not unnecessarily use up memory.

We will be using membase/couchbase for our production environment and we have created a bucket of 4GB to be on safer side.

Re: Caching with Memcache taking time

Posted: Sun Jan 20, 2013 8:48 pm
by kamermans
The capability filter has not yet been ported to this API, but I can send you the pre-release including the filter later this week if you'd like.