简体   繁体   English

高性能PHP

[英]High Performance PHP

I am about to launch a CodeIgniter web application. 我将启动一个CodeIgniter Web应用程序。 Any recommendations on what I should do to maximize performance of my application? 关于如何使应用程序性能最大化的建议? I'm thinking memcached and an accelerator (though I am not sure which one). 我在想内存缓存和加速器(尽管我不确定是哪一个)。 Suggestions? 建议?

memcached is great, if you need more datatypes Redis is a great alternative too. memcached很棒,如果您需要更多的数据类型, Redis也是很好的选择。 An Opcode cache like APC could help. APC这样的操作码缓存可能会有所帮助。 PHP 5.3.3's new SAPI ( FPM ) could help a lot if you don't want to go with the traditional mod_php way. 如果您不想使用传统的mod_php方式,PHP 5.3.3的新SAPI( FPM )可能会mod_php

You can use an accelerator, like APC. 您可以使用加速器,例如APC。 Any sort of caching will help if its applied in the right area's. 如果将其应用于正确的区域,则任何类型的缓存都将有所帮助。

I would suggest you profile your code runtime using Xdebug and Webgrind in order to find out where its running slowly, and go from there with any optimisations. 我建议您使用Xdebug和Webgrind对代码运行时进行概要分析,以便找出运行缓慢的位置,然后进行任何优化。

You can also do things like move things in your htaccess to the server config and disable htaccess, so that the server isn't wasting time looking in every directory for them. 您还可以执行一些操作,例如将htaccess中的内容移动到服务器配置并禁用htaccess,这样服务器就不会浪费时间在每个目录中查找它们。

To maximize performance, minimizing database requests you must. 为了最大化性能,必须最小化数据库请求。 Denormalize tables before you hack on memory caches. 在骇入内存缓存之前对表进行规范化。 And more importantly run your application through xdebug first, to check out the cachegrind output. 而且更重要的是, 首先通过xdebug运行您的应用程序,以检出cachegrind输出。

Performance is a very broad term. 性能是一个非常宽泛的术语。 As caching is not the only issue. 因为缓存不是唯一的问题。 You need to make sure that you have a good database design and structure and that you are querying it in an appropriate and efficient manner. 您需要确保您具有良好的数据库设计和结构,并以适当有效的方式查询它。

Also you might want to consider profiling, before you go on to caching, to see if it is indeed faster then regeneration. 另外,在继续进行缓存之前,您可能需要考虑进行概要分析,以查看它是否确实比重新生成更快。

Edit: 编辑:

Have a look at the following benchmarks from AventLabs 看看AventLabs的以下基准测试

您可以同时使用两者是最简单的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM