![Apache 性能帮助](https://linux22.com/image/545113/Apache%20%E6%80%A7%E8%83%BD%E5%B8%AE%E5%8A%A9.png)
最近我的(基于 Linux centOS 的)Web 服务器出现了性能问题。服务器上所有网站的响应时间都非常慢,而之前,页面加载速度要快得多。我运行了 eAccelerator、gzip 压缩内容、优化了 mysql 查询和其他标准优化流程,我确保这些流程都已实施。我查看了 apache 统计数据,看看在性能方面是否出现了问题,我是否应该关注一些问题(例如请求率)?非常感谢大家的帮助,因为我在这方面没有经验!
Maximum connect burst length: 0
Total: connections 1 requests 1 replies 1 test-duration 1.512 s
Connection rate: 0.7 conn/s (1511.9 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 1511.9 avg 1511.9 max 1511.9 median 1511.5 stddev 0.0
Connection time [ms]: connect 32.3
Connection length [replies/conn]: 1.000
Request rate: 0.7 req/s (1511.9 ms/req)
Request size [B]: 79.0
Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 1409.5 transfer 70.2
Reply size [B]: header 262.0 content 17425.0 footer 2.0 (total 17689.0)
Reply status: 1xx=0 2xx=1 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.35 system 1.02 (user 23.1% system 67.5% total 90.6%)
Net I/O: 11.5 KB/s (0.1*10^6 bps)
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
编辑:我还在服务器上运行了 mysqltuner,看看是否有可以改进的地方——我可以做几件事。
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.92-community
[!!] Switch to 64-bit OS - MySQL cannot currently use all of your RAM
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB +Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 111M (Tables: 662)
[--] Data in InnoDB tables: 10M (Tables: 468)
[!!] Total fragmented tables: 114
-------- Security Recommendations -------------------------------------------
[OK] All database users have passwords assigned
-------- Performance Metrics -------------------------------------------------
[--] Up for: 4d 7h 19m 52s (2M q [5.717 qps], 94K conn, TX: 3B, RX: 208M)
[--] Reads / Writes: 82% / 18%
[--] Total buffers: 58.0M global + 4.4M per thread (400 max threads)
[OK] Maximum possible memory usage: 1.8G (84% of installed RAM)
[OK] Slow queries: 0% (22/2M)
[OK] Highest usage of available connections: 3% (14/400)
[OK] Key buffer size / total MyISAM indexes: 16.0M/63.2M
[OK] Key buffer hit rate: 99.5% (1M cached / 8K reads)
[OK] Query cache efficiency: 91.9% (1M cached / 1M selects)
[!!] Query cache prunes per day: 17638
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 43K sorts)
[!!] Temporary tables created on disk: 48% (205K on disk / 420K total)
[OK] Thread cache hit rate: 99% (14 created / 94K connections)
[!!] Table cache hit rate: 3% (1K open / 28K opened)
[OK] Open file limit used: 51% (1K/2K)
[OK] Table locks acquired immediately: 99% (184K immediate / 184K locks)
[!!] InnoDB data size / buffer pool: 10.4M/8.0M
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Enable the slow query log to troubleshoot bad queries
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries without LIMIT clauses
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
query_cache_size (> 16M)
tmp_table_size (> 16M)
max_heap_table_size (> 16M)
table_cache (> 1024)
innodb_buffer_pool_size (>= 10M)
答案1
您的系统是否依赖于多个数据库事务?
如果您确实进行了所有性能优化,但您的网站速度却变慢了,那么也可能是因为数据库越来越大,用户群与数据库成比例地减少(例如,您的网站变得越来越受欢迎),并且需要更多时间来运行相同的进程,因此您在较小的数据库上执行。
对于一个普通的网站,当数据库增长到 200MB 以上时,其性能会缓慢下降,需要更多的内存和稍微不同的索引策略。
您可以使用 Pingdom 等工具(它们有免费帐户)来监控您网站的正常运行时间和响应时间,然后您可以找到瓶颈,评估正在发生的事情。此外,您的系统上的平均负载是多少?
你每天有多少访客?一年前有多少访客?可能会有差异。