详述Linux系统中Apache网页深入优化

发布时间:2020-06-24 22:00:34 作者:SiceLc
来源:网络 阅读:3900

ab压力测试

ab压力测试工具

ab工具使用

ab测试结果关键参数说明

参数 描述
Server Software http响应数据的头信息
Server Hostname 请求的url中的主机名称
Server Port web服务器软件的监听端口
Document Path 请求的url根的绝对路径
Document Length http响应数据的正文长度
Concurrency Level 并发的用户数
Time taken for tests 所有这些请求被处理完成所花费的时间总和
Complete requests 表示总请求数
Failed requests 失败的请求总数
Total transferred 请求的响应数据长度总和
Requests per second 服务器的吞吐率,每秒处理的请求数
Time per request 用户平均请求等待时间
Time per request 每个请求实际运行时间的平均值
Percentage of the requests served within a certain time (ms) 描述每 个请求处理时间的分布情况

测试实例

[root@localhost bin]# ab -n 20000 -c 500 www.kgc.com/index.html     //使用命令测试
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.kgc.com (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
Completed 16000 requests
Completed 18000 requests
Completed 20000 requests
Finished 20000 requests

Server Software:        Apache
Server Hostname:        www.kgc.com
Server Port:            80

Document Path:          /index.html
Document Length:        68 bytes

Concurrency Level:      500
Time taken for tests:   1.237 seconds
Complete requests:      20000
Failed requests:        0
Total transferred:      7300000 bytes
HTML transferred:       1360000 bytes
Requests per second:    16169.67 [#/sec] (mean)
Time per request:       30.922 [ms] (mean)
Time per request:       0.062 [ms] (mean, across all concurrent requests)
Transfer rate:          5763.60 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    5  60.3      1    1004
Processing:     0   14  49.6      6     808
Waiting:        0   12  49.5      5     808
Total:          1   19  78.2      8    1201

Percentage of the requests served within a certain time (ms)
  50%      8
  66%      9
  75%      9
  80%     10
  90%     13
  95%     17
  98%    211
  99%    406
 100%   1201 (longest request)

Apache工作模式

Apache工作模式介绍

[root@apache1 bin]# ./httpd -l       //查看apache当前工作模式
Compiled in modules:
core.c
mod SO.c
http_ core.c
event.c

event作模式介绍

event工作方式

event参数讲解

event优化建议

<IfModule mpm_event_module>
ServerLimit        1000
StartServers         20
MinSpareThreads          25
MaxSpareThreads          1200
ThreadsPerChild         50
MaxRequestWorkers         2000
MaxConnectionsPerChild     1000
</IfModule>

prefork作模式介绍

prefork工作模式方式

prefork参数讲解

参数 说明
ServerLimit 最大进程数
StartServers 启动的时候创建的进程数量
MinSpareServers 最少空闲进程
MaxSpareServers 最多空闲进程
MaxClients 最多创建多少个子进程用来处理请求
MaxRequestsPerChild 每个进程处理的最大请求数,达到请求数,进程即被销毁,如果设置为0,子进程永远不会结束

prefork优化建议

<IfModule mpm_prefork_module>
   ServerLimit      1000
   StartServers     10
   MinSpareServers    10
   MaxSpareServers    30
   MaxClients        1000
   MaxRequestsPerChild   5000
</IfModule>

worker工作模式介绍

worker工作方式

worker参数讲解

参数 说明
ServerLimit 最大进程数,默认值是"16"
ThreadLimit 每个子进程的最大线程数,默认值是“64”
StartServers 服务器启动时建立的子进程数,默认值是"3"
MaxClients 允许同时接受的最大接入请求数量(最大线程数量)
MinSpareThreads 最小空闲线程数默认值是"75"
MaxSpareThreads 设置最大空闲线程数。默认值是"250"
ThreadsPerChild 每个子进程建立的常驻的执行线程数。默认值是25
MaxRequestsPerChild 设置每个子进程在其生存期内允许伺服的最大请求数量。设置为"0",子进程将永远不会结束

worker优化建议

<IfModule mpm_worker_module>
   ServerLimit       40
   ThreadLimit        200
   StartServers        20
   MaxClients        1000
   MinSpareThreads      25
   MaxSpareThreads      100
   ThreadsPerChild       200
   MaxRequestsPerChild   1000
</IfModule>

Apache目录属性

目录属性参数

参数 作用
Options 设置在特定目录使用哪些特性
AllowOverride 允许存在于.htaccess文件中的指令类型
Require 设置目录的访问控制
Indexes 当用户访问该目录时,但没有指定要访问哪个文件,而且目录下不存在默认网页时,返回目录中的文件和子目录列表
MultiViews 内容协商的多重视图,Apache的一 个智能特性。当访问目录中不存在的对象时
ExecCGI 允许在该目录下执行CGI脚本
FollowSymLinks 在该目录下允许文件系统使用符号连接
Includes 允许服务器端包含功能
IncludesNoExec 允许服务器端包含功能,但禁止执行CGI脚本
All 包含除了MultiViews之外所有特性,如果没有Options语句,默认为All

优化建议

推荐阅读:
  1. Apache网页优化与安全优化(网页压缩;网页缓存;网页防盗
  2. Apache网页优化—网页压缩

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux apache http he inux

上一篇:UE4 退出(关闭)程序 代码

下一篇:Your first iOS app(6)——Tutorial: Storyboards

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》