我在Apacheconfiguration8gb的RAM 1and1.com虚拟服务器上遇到服务器超载的问题。 服务器一旦达到100多个活跃用户(根据谷歌分析)在select时间变得非常缓慢。 我已经完成了包围和loadimpacttesting,并对httpd.conf文件进行了一些configuration更改,但是我不知道是否足够。 也许我只需要更多像16GB的内存或我错过了什么? 我知道我可以优化编程,但我不明白它将如何大幅度提高性能。 有趣的是,在过载期间,并行内存使用率只显示10-20%,但网站太慢了! 帮帮我!
Avg. site file size is 1.5MB (We have lots of pictures) Avg. load time: 1.8s (during normal days) - 1,600 page views, 270 highest sessions p/h
这是一个非常缓慢的服务器日的分析统计:
Highest sessions per hour: 420 - 700 Total sessions: 4,300 - 37,000 Page views: 25,300 - 361,500 Avg. Session duration: 9min
由1and1提供的服务器数据:
Webspace: 200GB RAM: 8GB Unlimited Traffic: yes Operating System: CentOS 6 minimal system (64-bit) cpu cores: 8 Processors: 4 Processor: AMD Opteron(tm) Processor 6378
在http.conf
Timeout 75 KeepAlive On MaxKeepAliveRequests 500 KeepAliveTimeout 3 <IfModule prefork.c> StartServers 8 MinSpareServers 5 MaxSpareServers 20 ServerLimit 220 MaxClients 220 MaxRequestsPerChild 5000 </IfModule>
my.conf
max_allowed_packet = 1G max_connections = 500 max_user_connections = 500 thread_cache_size = 500 query_cache_type = 1 query_cache_size = 128M sort_buffer_size = 2M tmp_table_size = 32M read_buffer_size = 128k read_rnd_buffer_size = 256k join_buffer_size = 128k table_definition_cache = 400 table_open_cache = 400 key_buffer_size = 500M max_heap_table_size = 64M innodb_buffer_pool_size = 500M innodb_additional_mem_pool_size = 20M innodb_file_per_table = 1 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 12M innodb_log_file_size = 256M
难道我做错了什么? 我感谢所有的帮助!
你需要看的第一件事就是确定你的瓶颈在哪里。
一般来说,这些性能问题将在应用程序中,而不是Web服务器configuration。
一旦你了解了瓶颈,你可以借助你的networking服务器软件来缓解它(确切的方法取决于你正在运行的应用程序代码以及你如何将它附加到你的web服务器上,但是有很多有关从FastCGI或mod_passenger获得最高性能的mod_passenger ),但只有这样才能在那里完成。
总结:不要从Web服务器开始,首先要跟踪瓶颈并修复它 – 如果您发现在Web服务器上有什么可以帮助的地方,那么尝试一下,但是不太可能修复应用程序的性能问题。