我在1个月前将Zend Framework添加到我的php项目中。 我正在使用Zend_Measure和Zend_Locale将数字格式化为良好的语言环境。
我使用PHP 5.3与APC和Zend Framework 1.11。
从数据库导出原始数据时遇到了一个主要问题。 排除可忽略不计的mysql查询时间,带有记录格式的php导出每1000条记录需要3.5秒。 所有这些时间都花在Zend_Locale_Format::toNumber() 。 我怎样才能提高性能呢?
这个基准测试是在我自己的计算机上完成的(Macbook pro i5)。 在我们的生产服务器上,每1000条记录需要70秒! 此服务器是2GB rackspaceCloud云服务器,带有centos,只运行我们的Web应用程序。
macbook和rackspace服务器性能之间有20个因素。 我的macbook是如此强大吗? 我不这么认为......
UPDATE
在进行一些分析之后,似乎瓶颈是Zend_Cache_Backend_File->_fileGetContents 。 它默认使用Zend_Cache_Backend_File。 如何配置Zend Framework以使用Zend_Cache_Backend_Apc或Zend_Cache_Backend_TwoLevels ? 它可能会改善性能......
I added Zend Framework to my php project 1 month ago. I am using Zend_Measure and Zend_Locale for formatting the numbers to the good locale.
I am using php 5.3 with APC and Zend Framework 1.11.
I have a major issue with the export of raw data from my database. Excluding the mysql query time which is negligible the php export with formatting of the records takes 3.5 seconds per 1000 records. All this time is spend in Zend_Locale_Format::toNumber(). How can I improve the performance of this?
This benchmark has been done on my own computer (Macbook pro i5). On our production server it take 70 seconds per 1000 records!!! This server is a 2GB rackspaceCloud Cloud server with centos and only our web application running.
There is a 20 factor between the macbook and the rackspace server performance. Is my macbook so powerful? I don't think so...
UPDATE
After doing some profiling it appear that the bottleneck is Zend_Cache_Backend_File->_fileGetContents. It use by default Zend_Cache_Backend_File. How can I configure Zend Framework to use Zend_Cache_Backend_Apc or Zend_Cache_Backend_TwoLevels? It could maybe improve the performance...
最满意答案
您是否为Zend_Locale设置了全局缓存? 检查此文档页面并滚动到底部。
另外,检查您的APC设置。 我自己不使用APC,但是当缓存大小太小时,XCache会出现性能问题。 这也可能是您的配置问题。
要配置Zend_Locale和Zend_Local_Format使用的缓存,请使用Zend_Locale::setCache($cache)和Zend_Locale_Format::setOptions(array('cache' => $adapter)) 。 可以在手册中找到。
Have you setup the global cache for Zend_Locale? Check this doc page and scroll to the bottom.
Also, check your APC settings. I don't use APC myself but have had performance issues with XCache when the cache size was too small. This could also be an issue for your configuration.
To configure the cache used by Zend_Locale and Zend_Local_Format use Zend_Locale::setCache($cache) and Zend_Locale_Format::setOptions(array('cache' => $adapter)). As can be found in the manual.
更多推荐
发布评论