转自:http://blog.monitis.com/index.php/2011/07/05/25-apache-performance-tuning-tips/
1. Remove unused modules – save memory by not loading modules that you do not need, including but not limited to mod_php, mod_ruby, mod_perl, etc.
2. Use mod_disk_cache NOT mod_mem_cache - mod_mem_cache will not share its cache amongst different apache processes, which results in high memory usage with little performance gain since on an active server, mod_mem_cache will rarely serve the same page twice in the same apache process.
3. Configure mod_disk_cache with a flat hierarchy – ensure that you are using CacheDirLength=2 and CacheDirLevels=1 to ensure htcacheclean will not take forever when cleaning up your cache directory.
4. Setup appropriate Expires, Etag, and Cache-Control Headers – to utilize your cache, you must tell it when a file expires, otherwise your client will not experience the caching benefits.
5. Put Cache on separate disk – place your cache on a separate physical disk for fastest access without slowing down other processes.
6. Use Piped Logging instead of direct logging – directly logging to a file has issues when you want to rotate the log file. It must restart apache to use the next log file. This will cause significant slowness for your users during the restart. Particularly if you are using Passenger or some other app loader.
7. Log to a different disk than disk serving pages – put your logs on physically different disks than the files you are serving.
8. Utilize mod_gzip/mod_deflate – gzip your content before sending it off and then the client will ungzip upon receipt, this will minimize the size of file transfers, it generally will help all user experience.
9. Turn HostnameLookups Off – stop doing expensive DNS lookups. You will rarely ever need them and when you do, you can look them up after the fact.
10. Avoid using hostname in configs – if you have HostnameLookups off, this will prevent you from having to wait for the DNS resolve of the hostnames in your configs, use IP addresses instead.
11. Use Persistent Connections - Set KeepAlive On and then set KeepAliveTimeout and KeepAliveRequests. KeepAliveTimeout is how long apache will wait for the next request, and KeepAliveRequests is the max number of requests for a client prior to resetting the connection. This will prevent the client from having to reconnect between each request.
12. Do Not set KeepAliveTimeout too high – if you have more requests than apache children, this setting can starve your pool of available clients.
13. Disable .htaccess - i.e. AllowOverride None This will prevent apache from having to check for a .htaccess file on each request.
14. Allow symlinks – i.e. Options +FollowSymLinks -SymLinksIfOwnerMatch. Otherwise, apache will make a separate call on each filename to ensure it is not a symlink.
15. Set ExtendedStatus Off - Although very useful, the ExtendedStatus will produce several system calls for each request to gather statistics. Better to utilize for a set time period in order to benchmark, then turn back off.
16. Avoid Wildcards in DirectoryIndex – use a specific DirectoryIndex, i.e. index.html or index.php, not index
OS Specifics
17. Increase Swappiness – particularly on single site hosts this will increase performance. On linux systems increase /proc/sys/vm/swappiness to at least 60 if not greater. This will try to load as many files as possible into the memory cache for faster access.
18. Increase Write Buffer Size – increase your write buffer size for tcp/ip buffers. On linux systems increase /proc/sys/net/core/wmem_max and /proc/sys/net/core/wmem_default. If your pages fit within this buffer, apache will complete a process in one call to the tcp/ip buffer.
19. Increase Max Open Files – if you are handling high loads increase the number of allowed open files. On linux, increase /proc/sys/fs/file-max and run ulimit -H -n 4096.
Application Specifics
20. Setup Frontend proxy for images and stylesheets – allow your main web servers to process the application while images and stylesheets are served from frontend webservers
21. Use mod_passenger for rails – mod_passenger is able to share memory and resources amongst several processes, allowing for faster spawning of new application instances. It will also monitor these processes and remove them when they are unnecessary.
22. Turn off safe_mode for php – it will utilize about 50-70% of your script time checking against these safe directives. Instead configure open_base_dir properly and utilize plugins such as mod_itk.
23. Don’t use threaded mpm with mod_php – look at using mod_itk, mod_php tends to segfault with threaded mpm.
24. Flush buffers early for pre-render - it takes a relatively long time to create a web page on the backend, flush your buffer prior to page completion to send a partial page to the client, so it can start rendering. A good place to do this is right after the HEAD section – so that the browser can start fetching other objects.
25. Use a Cache for frequently accessed data - memcached is a great for frequently used data and sessions. It will speed up your apache render time as databases are slow.
相关推荐
为了提高其性能,以下25个优化技巧将有助于最大化Apache的工作效率: ...以上就是25个Apache性能优化技巧,通过这些方法,可以显著提升Apache服务器的处理能力和响应速度,确保网站和服务的高效运行。
以上25个技巧涵盖了Apache服务器、操作系统以及应用程序三个层面,它们旨在帮助Web开发者和系统管理员实现更高效的Apache性能优化,提升网站的整体运行效率。通过实践和调整,你可以根据自己的具体需求找到最适合的...
apache性能优化技巧
### 软件工程与软件性能优化技巧 #### 第1章 软件性能优化概述 **软件性能优化定义:** 软件性能优化是指通过对软件系统的设计、实现和部署等方面的改进来提升系统的性能,包括但不限于响应速度、吞吐量以及并发...
1.Zend Performance Suite简介...zend出品的ZendPerformanceSuite,这是一个Apache服务器的性能测试和优化的工具。可以在它的主页注册并且免费下载。并且得到一个协议文件。下载的软件包中有两个文件:主程序:ZendPerf
本篇文章将全面解析Tomcat性能优化的各个方面,帮助开发者们理解并掌握优化技巧,提升服务器的运行效率。 一、JVM配置优化 1. 内存设置:合理调整JVM的堆内存大小(Xms, Xmx)可以避免频繁的垃圾回收,提高性能。...
这个"高性能Apache Ignite完整版"的文档很可能包含了这些主题的深入讲解,包括概念介绍、配置指南、最佳实践、案例研究和可能的性能优化技巧。通过阅读这份资料,开发者和架构师可以全面了解如何利用Apache Ignite...
下面我们将深入探讨各个组件的优化技巧。 **Linux优化** Linux作为基础操作系统,其性能直接影响到整个LAMP环境。优化Linux通常涉及调整内核参数、关闭不必要的服务和优化I/O。例如,升级内核到2.4或更高版本可以...
Apache性能优化是网站管理员和运维工程师在搭建高效、稳定的服务环境中不可或缺的技能之一。特别是在Windows Server 2003系统中,Apache的性能优化显得尤为重要。以下是对文档中提到的Apache性能优化方法的详细说明...
总结来说,Tomcat性能优化是一个复杂的过程,需要结合实际情况,对每个组件和参数进行细致的调整和测试。通过本专题课程的学习,可以系统地理解Tomcat的工作原理,掌握优化技巧,从而达到提升应用性能的目的。在生产...
5. **性能优化策略**:通过JMeter测试,开发者可以识别性能瓶颈,例如数据库查询慢、服务器配置不当或代码效率低等问题。优化策略可能包括调整服务器配置、优化数据库查询、缓存策略改进、代码重构等。 6. **测试...
8. **安全防护与性能优化**:介绍防止DDoS攻击的方法,以及如何调整Nginx配置以优化性能。 通过阅读本书,读者不仅可以了解Nginx的基本原理,还能掌握实际操作中的技巧和最佳实践,从而在项目中成功实现Nginx替换...
书中有详细的配置示例和性能优化技巧。 5. **反向代理与负载均衡**:Nginx强大的反向代理功能可以将请求分发到不同的服务器,实现负载均衡。书里会介绍多种负载均衡策略,如轮询、权重分配、最少连接等。 6. **SSL...
### 18个网站优化技巧:首页响应慢与首页速度优化 #### 一、引言 随着互联网技术的发展,用户对网页加载速度的要求越来越高。快速的页面加载不仅能够提升搜索引擎排名,还能显著改善网站转化率及用户体验。然而,...
保持所有组件(操作系统、Apache、MySQL、PHP)的最新状态,确保安全性和性能优化。 通过上述优化策略,可以有效地提升LAMP服务器的性能,应对高并发访问和大数据量处理,确保Web应用程序的稳定高效运行。在实施...
通过这样的课程设计,学生能够深入理解Linux操作系统和Apache服务器的交互,掌握性能分析和优化技巧,这对于未来从事Web服务器管理或相关IT工作有着重要的实践意义。总结部分通常会强调学习收获,指出存在的问题,...