当前位置: 首页 > news >正文

docker nginx 和宿主机原生 nginx 服务的性能压测对比

1、通过 yum install -y nginx 安装的原生 nginx 1.20.1

➜  ~ service nginx restart
Redirecting to /bin/systemctl restart nginx.service
➜  ~ curl localhost
<!DOCTYPE html>
<html>
<head>
<title>HTTP Server Test Page</title>
<style>body {width: 35em;margin: 0 auto;font-family: Tahoma, Verdana, Arial, sans-serif;}
</style>
</head>
<body>
<h1>Welcome to HTTP Server Test Page!</h1>
<p>If you see this page, the httpd web server is successfully installed and
working. Further configuration is required.</p><p><em>Thank you for using apache httpd.</em></p>
</body>
</html>~ ab -n 50000 -c 1000 http://localhost/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requestsServer Software:        nginx/1.20.1
Server Hostname:        localhost
Server Port:            80Document Path:          /
Document Length:        452 bytesConcurrency Level:      1000
Time taken for tests:   5.816 seconds
Complete requests:      50000
Failed requests:        0
Total transferred:      34250000 bytes
HTML transferred:       22600000 bytes
Requests per second:    8596.25 [#/sec] (mean)
Time per request:       116.330 [ms] (mean)
Time per request:       0.116 [ms] (mean, across all concurrent requests)
Transfer rate:          5750.42 [Kbytes/sec] receivedConnection Times (ms)min  mean[+/-sd] median   max
Connect:        0   46   7.2     46      71
Processing:    23   69  13.9     69     140
Waiting:        1   51  13.1     48     122
Total:         45  115  12.7    115     173Percentage of the requests served within a certain time (ms)50%    11566%    12075%    12380%    12590%    13395%    13898%    14399%    148100%    173 (longest request)

平均耗时 115ms

 

2、通过 docker pull nginx:1.20.1 安装的 docker run -d -p 80:80 nginx:1.20.1

➜  ~ docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED       STATUS       PORTS                               NAMES
3c91d5b22774   nginx:1.20.1   "/docker-entrypoint.…"   2 hours ago   Up 2 hours   0.0.0.0:80->80/tcp, :::80->80/tcp   upbeat_roentgen
➜  ~ curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>body {width: 35em;margin: 0 auto;font-family: Tahoma, Verdana, Arial, sans-serif;}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>~ ab -n 50000 -c 1000 http://localhost/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requestsServer Software:        nginx/1.20.1
Server Hostname:        localhost
Server Port:            80Document Path:          /
Document Length:        612 bytesConcurrency Level:      1000
Time taken for tests:   15.255 seconds
Complete requests:      50000
Failed requests:        0
Total transferred:      42250000 bytes
HTML transferred:       30600000 bytes
Requests per second:    3277.64 [#/sec] (mean)
Time per request:       305.098 [ms] (mean)
Time per request:       0.305 [ms] (mean, across all concurrent requests)
Transfer rate:          2704.69 [Kbytes/sec] receivedConnection Times (ms)min  mean[+/-sd] median   max
Connect:        0   13  14.5      8      88
Processing:    57  290  59.9    285     565
Waiting:        1  281  59.8    277     562
Total:         57  303  56.9    297     582Percentage of the requests served within a certain time (ms)50%    29766%    32075%    33680%    34990%    37795%    40398%    44199%    468100%    582 (longest request)

平均耗时 303ms

 

http://www.rkmt.cn/news/55701.html

相关文章:

  • kode-cli+glm4.6测评
  • UEFI - FV/FFS/FDF 的关系 - 阿源
  • 预算管理不用愁 - 智慧园区
  • Uni-App(Vue3 + TypeScript)方案结构详解 ------ 以 Lighting-UniApp 为例,提供源代码
  • XHORSE XZBT40EN 4-Button Honda Civic 2016-2019 Special PCBs (5pcs/lot) for Reliable Key Fob Repairs
  • Java 和 Apache POI 处理 Excel 文件
  • 有志青年
  • python舆情分析可视化平台 情感分析 微博 爬虫 scrapy爬虫手艺 朴素贝叶斯分类算法大数据 计算机✅
  • Python thread lambda run multiple functions
  • csp-s 2025 随笔
  • 内网穿透配置和使用 - Rainbow
  • 13. Spring AI 的观测性 - Rainbow
  • Elasticsearch8.4.1升级Elasticsearch9.1.5 - 实践
  • 工具成瘾——黑客为何痴迷工具与AI(及如何开始用脑思考)
  • 完整教程:Flask入门教程——李辉 第5章: 数据库 关键知识梳理
  • SLB及健康检查
  • 2025牛客国庆集训派对day7 M C 个人题解 - 教程
  • C++ 中 struct 与 class 的用法与区别
  • 07.创建型 - 抽象工厂模式(Abstract Factory Pattern)
  • 模型量化原理
  • 日总结 29
  • 2025.11.19 C 题解
  • 2025.11.20
  • 【比赛记录】2025CSP+NOIP 冲刺模拟赛合集Ⅵ
  • 3 分钟上手 SightAI:在你熟悉的工具里直接调用顶级大模型 - sight
  • 2025.11.20博客
  • 芯谷科技--高性能电动工具直流调速电路GS069 - 指南
  • 洛谷 B4411:[GESP202509 二级] 优美的数字 ← 嵌套循环
  • 2025 门窗十大品牌精准选购指南:行业评估报告 + 白皮书护航,选窗不踩坑!
  • 网络流建模