当前位置: 首页 > 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.jsqmd.com/news/46037/

相关文章:

  • kode-cli+glm4.6测评
  • UEFI - FV/FFS/FDF 的关系 - 阿源
  • 体验 Grok4.1
  • 预算管理不用愁 - 智慧园区
  • 2025半期游忌
  • Uni-App(Vue3 + TypeScript)方案结构详解 ------ 以 Lighting-UniApp 为例,提供源代码
  • 第31天(简单题中等题 二分查找)
  • XHORSE XZBT40EN 4-Button Honda Civic 2016-2019 Special PCBs (5pcs/lot) for Reliable Key Fob Repairs
  • Java 和 Apache POI 处理 Excel 文件
  • rust第二篇:语法学习
  • 啊队队队第二次团队作业--原型设计+概要设计
  • IO 2024 Round 3(团体赛)Unofficial Mirror
  • 有志青年
  • python舆情分析可视化平台 情感分析 微博 爬虫 scrapy爬虫手艺 朴素贝叶斯分类算法大数据 计算机✅
  • 90%的OKR都写成了KPI?其实你缺的不是表格,而是教练
  • Python thread lambda run multiple functions
  • 我为什么要学MCP?
  • storybook 和 vitepress选哪个作为组件文档站点更合适
  • csp-s 2025 随笔
  • wps禁止更新
  • 消费电子的可创作内容已经不属于可持续性竭泽而渔
  • 内网穿透配置和使用 - Rainbow
  • Swift 快速上手
  • [ARC195D] Swap and Erase 分析
  • 20251118 正睿
  • 13. Spring AI 的观测性 - Rainbow
  • Elasticsearch8.4.1升级Elasticsearch9.1.5 - 实践
  • 为什么大型炼钢厂(宝武、鞍钢、首钢等)都离不开时序数据库?
  • 第一次随笔测试
  • 20251120周四日记