我有一个自定义框架,其中包含一个处理数据库连接,查询等的自定义类。 在这个数据库类中,我决定使用Memcache来加快页面响应时间。
我将数据保存在Memcache中,如'query-'。 md5($ sql_query)='SQL结果'然后当我需要查询数据库时,如果我已经在Memcache中拥有此密钥,那么我将执行 - >获取它并使用该值。
问题是它在开始时工作正常(ish)但在一段时间后它开始明显减慢。
例如,没有Memcache的初始加载速度为:
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
使用Memcache就是这样的:
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
这是Memcache管理面板的图像:
顶部片段:
对于我做错了什么,或者我应该如何配置Memcache以实际加速不减慢应用程序的速度,你有任何想法/建议吗?