问题
I have a custom framework with a custom class that handles the database connection, queries, etc. In this database class i've decided to use Memcache to speed up my page response time.
I save the data in Memcache like 'query-' . md5($sql_query) = 'SQL results' and then when i need to query the database if i already have this key in Memcache then i'll do a ->get on it and use that value.
The problem is that it works ok(ish) in the begining but after a period it begins to slow down significantly.
For example the initial load speed without Memcache was:
Server Software: Apache
Server Hostname: www.site.ro
Server Port: 80
Document Path: /
Document Length: 40737 bytes
Concurrency Level: 10
Time taken for tests: 10.299 seconds
Complete requests: 50
Failed requests: 0
Total transferred: 2054600 bytes
HTML transferred: 2036850 bytes
Requests per second: 4.85 [#/sec] (mean)
Time per request: 2059.816 [ms] (mean)
Time per request: 205.982 [ms] (mean, across all concurrent requests)
Transfer rate: 194.82 [Kbytes/sec] received
and with Memcache it's something like this:
Server Software: Apache
Server Hostname: www.site.ro
Server Port: 80
Document Path: /
Document Length: 40737 bytes
Concurrency Level: 10
Time taken for tests: 114.513 seconds
Complete requests: 50
Failed requests: 0
Total transferred: 2054600 bytes
HTML transferred: 2036850 bytes
Requests per second: 0.55 [#/sec] (mean)
Time per request: 18141.600 [ms] (mean)
Time per request: 1814.160 [ms] (mean, across all concurrent requests)
Transfer rate: 22.12 [Kbytes/sec] received
Here is an image with the Memcache admin panel:
top snippet:
Do you have any ideea/suggestions as to what i am i doing wrong or how should i configure Memcache to actually speed up not slow down the application?
来源:https://stackoverflow.com/questions/26866551/why-does-php-memcache-have-a-very-slow-response