好物优选点击查看详情 京东购买

暂无内容

AdockerofLAMP&WordPress优化

项目描述:

项目描述: Docker基于LXC实现了把lamp+wordpress架构封装到一个完整的文件系统中,docker提供了所需的一切代码,运行环境等。由于docker使用独立于主机的文件系统,可以确保架构在不同的主机环境中仍然保持运行环境不变,这样为整个架构服务的迁移提供了极大的便捷性。WordPress是使用PHP语言开发的博客平台,支持PHP和MySQL数据库的服务器上架设。lamp是一个使用apache为web服务器,PHP负责解释动态请求,MySQL提供用户数据服务,正好完全兼容wordpress对PHP和MySQL的需求。 

nginx提供缓存提升性能

lamp+wordpress架构:172.25.254.110

nginx反响代理服务器:172.25.254.11

在lamp架构上,做虚拟主机服务:00.wordpress.com和01.wordpress.com两个站点维护不同用户的wordpress博客,主页内容复杂度完全一致!

测试思路:使用nginx反响代理服务器对01.wordpress.com做缓存处理。00.wordpress.com不做任何处理。

nginx服务器(172.25.254.11)配置文件修改的核心文件:

 proxy_cache_path /nginx/cache2 levels=1:2:1 keys_zone=coco:20m max_size=1g; location / { proxy_pass http://01.wordpress.com; proxy_cache coco; proxy_cache_valid 200 304 1d; proxy_buffering on; }

nginx服务器添加了域名解析:

[root@localhost nginx]# cat /etc/hosts | grep 172.25.254.110 172.25.254.110 wordpress wordpress.com 00.wordpress.com 01.wordpress.com

由于00.wordpress.com没有nginx缓存,此时进行进行压力测试:

测试1

[root@localhost nginx]# ab -n 100 -c 10 http://00.wordpress.com/wordpress/ This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ ​ Benchmarking 00.wordpress.com (be patient).....done ​ ​ Server Software: Apache/2.4.6 Server Hostname: 00.wordpress.com Server Port: 80 ​ Document Path: /wordpress/ Document Length: 53724 bytes ​ Concurrency Level: 10 Time taken for tests: 40.266 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 5401300 bytes HTML transferred: 5372400 bytes Requests per second: 2.48 [#/sec] (mean) Time per request: 4026.628 [ms] (mean) Time per request: 402.663 [ms] (mean, across all concurrent requests) Transfer rate: 131.00 [Kbytes/sec] received ​ Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.5 0 5 Processing: 464 3920 653.2 4028 5041 Waiting: 247 3618 602.1 3717 4699 Total: 465 3920 653.2 4028 5041 ​ Percentage of the requests served within a certain time (ms) 50% 4028 66% 4186 75% 4248 80% 4310 90% 4460 95% 4653 98% 4938 99% 5041 100% 5041 (longest request) ​

测试2

加大压力:

[root@localhost nginx]# ab -n 300 -c 20 http://00.wordpress.com/wordpress/ This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ ​ Benchmarking 00.wordpress.com (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Finished 300 requests ​ ​ Server Software: Apache/2.4.6 Server Hostname: 00.wordpress.com Server Port: 80 ​ Document Path: /wordpress/ Document Length: 53724 bytes ​ Concurrency Level: 20 Time taken for tests: 127.063 seconds Complete requests: 300 Failed requests: 0 Write errors: 0 Total transferred: 16203900 bytes HTML transferred: 16117200 bytes Requests per second: 2.36 [#/sec] (mean) Time per request: 8470.856 [ms] (mean) Time per request: 423.543 [ms] (mean, across all concurrent requests) Transfer rate: 124.54 [Kbytes/sec] received ​ Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 1.9 0 23 Processing: 523 8342 1326.9 8176 12541 Waiting: 300 7815 1257.2 7690 12020 Total: 523 8343 1327.1 8176 12541 ​ Percentage of the requests served within a certain time (ms) 50% 8176 66% 8398 75% 8635 80% 8953 90% 10095 95% 10488 98% 11265 99% 12439 100% 12541 (longest request)

真实服务器的链接状态:

[root@wordpress conf.d]# netstat -at| awk '{print $6} '| sort | uniq -c 1 established) 23 ESTABLISHED 1 Foreign 6 LISTEN 136 TIME_WAIT [root@wordpress conf.d]# top -n 1 ​ top - 03:04:32 up 9:04, 3 users, load average: 19.38, 7.83, 4.40 //可以看到,cpu负载特别的大

nginx服务器通过反响代理将访问172.25.254.11的请求发送给01.wordpress.com/wordpress。然后在nginx服务器的/nginx/cache2目录内进行缓存。

测试3

[root@localhost cache2]# ab -n 100 -c 10 http://172.25.254.11/wordpress/ This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ ​ Benchmarking 172.25.254.11 (be patient).....done ​ ​ Server Software: nginx/fsx-1.1.0 Server Hostname: 172.25.254.11 Server Port: 80 ​ Document Path: /wordpress/ Document Length: 53739 bytes ​ Concurrency Level: 10 Time taken for tests: 0.010 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 5403300 bytes HTML transferred: 5373900 bytes Requests per second: 9575.79 [#/sec] (mean) Time per request: 1.044 [ms] (mean) Time per request: 0.104 [ms] (mean, across all concurrent requests) Transfer rate: 505282.02 [Kbytes/sec] received ​ Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 0 Processing: 0 1 0.2 1 1 Waiting: 0 1 0.2 1 1 Total: 1 1 0.1 1 1 ​ Percentage of the requests served within a certain time (ms) 50% 1 66% 1 75% 1 80% 1 90% 1 95% 1 98% 1 99% 1 100% 1 (longest request)

在nginx服务器上查看缓存:

[root@localhost cache2]# pwd /nginx/cache2 [root@localhost cache2]# tree . ├── 0 │ └── 9f │ └── d │ └── d5fafe70f4ca172905b6a443fce7d9f0 └── e └── d9 └── c ​ 6 directories, 1 file

测试4

[root@localhost cache2]# ab -n 1000 -c 100 http://172.25.254.11/wordpress/ This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ ​ Benchmarking 172.25.254.11 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests ​ ​ Server Software: nginx/fsx-1.1.0 Server Hostname: 172.25.254.11 Server Port: 80 ​ Document Path: /wordpress/ Document Length: 53739 bytes ​ Concurrency Level: 100 Time taken for tests: 0.119 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 54033000 bytes HTML transferred: 53739000 bytes Requests per second: 8369.04 [#/sec] (mean) Time per request: 11.949 [ms] (mean) Time per request: 0.119 [ms] (mean, across all concurrent requests) Transfer rate: 441605.86 [Kbytes/sec] received ​ Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 0.8 1 4 Processing: 2 10 1.9 11 12 Waiting: 0 7 2.4 7 11 Total: 5 11 1.4 12 13 ​ Percentage of the requests served within a certain time (ms) 50% 12 66% 12 75% 12 80% 12 90% 12 95% 12 98% 12 99% 12 100% 13 (longest request)

测试5

不断进行添加压力:此时的链接为10000,并发为1000

[root@localhost cache2]# ab -n 10000 -c 1000 http://172.25.254.11/wordpress/ This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ ​ Benchmarking 172.25.254.11 (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests ​ ​ Server Software: nginx/fsx-1.1.0 Server Hostname: 172.25.254.11 Server Port: 80 ​ Document Path: /wordpress/ Document Length: 53739 bytes ​ Concurrency Level: 1000 Time taken for tests: 1.967 seconds Complete requests: 10000 Failed requests: 0 Write errors: 0 Total transferred: 540330000 bytes HTML transferred: 537390000 bytes Requests per second: 5084.35 [#/sec] (mean) Time per request: 196.682 [ms] (mean) Time per request: 0.197 [ms] (mean, across all concurrent requests) Transfer rate: 268283.84 [Kbytes/sec] received ​ Connection Times (ms) min mean[+/-sd] median max Connect: 0 83 270.1 0 1008 Processing: 13 44 90.4 19 827 Waiting: 0 43 90.5 18 827 Total: 14 127 343.9 19 1835 ​ Percentage of the requests served within a certain time (ms) 50% 19 66% 24 75% 33 80% 43 90% 91 95% 1051 98% 1427 99% 1436 100% 1835 (longest request)

Requests per second:每秒接收的请求数

Time per request:每个请求被处理用时

Transfer rate:响应速率

Total transferred:总共获取数据两

可以看到有无缓存,天差地别!!!也算是对lamp+wordpress的一个性能提升。

原文链接:https://blog.csdn.net/fsx2550553488/article/details/82034889

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享