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

news/2025/11/20 23:12:08/文章来源:https://www.cnblogs.com/kaiye/p/19249828

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.mzph.cn/news/971513.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

kode-cli+glm4.6测评

kode-cli + glm4.6测评 官网 https://github.com/shareAI-lab/Kode-cli 开源,Apache-2.0 license用HTML、CSS和JavaScript(若更偏好p5.js也可选用),创建一个带有动画效果的天气卡片。要在卡片里呈现当前温度、具体位…

UEFI - FV/FFS/FDF 的关系 - 阿源

本文梳理和介绍了一下 固件卷 FV,FFS文件,FDF文件之间的组织关系,以及其在 EDKII 工程中的体现。目录1. 什么是固件卷 2. 是么是 FFS 文件 3. 什么是 FDF 文件一、UEFI 固件卷 如果一个磁盘是没有经过分区的简单状态…

体验 Grok4.1

用Grok4.1享赛博道祖人生。夸夸群绝不会想到,竟被格罗克这小子夺舍。我只说了句想要修仙,它瞬间就能把我捧成元婴,什么万里挑一的练武奇才都变得无味至极,因为它知我定是道祖转世。不懂风情之人会说这就是舔狗的马…

预算管理不用愁 - 智慧园区

又到年度预算季,不少企业管理者陷入“预算魔咒”: - 财务部门熬夜制表,业务部门敷衍填报,耗时1-2个月的预算,执行起来偏差超30%; - 销售、生产、研发各算各的账,资源互相争抢,协同效率低下; - 预算目标拍脑袋…

2025半期游忌

闲话 感觉做的时候感觉自己信心满满(感觉各科都是),结果呢,唉~,主科全部都演我 \(QwQ\)(甚至英语还考了 \(orz\) ,像极了我现在的心境) 正题 语文这次真的是被语文病句题被刺了,考的时候感觉 \(A\) 和 \(C\) …

Uni-App(Vue3 + TypeScript)方案结构详解 ------ 以 Lighting-UniApp 为例,提供源代码

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

第31天(简单题中等题 二分查找)

打卡第三十一天 1道简单题+2道中等题题目:思路:二分代码: class Solution { public:int singleNonDuplicate(vector<int>& nums) {int left = -1, right = nums.size() / 2;// left从-1开始,right从数组…

XHORSE XZBT40EN 4-Button Honda Civic 2016-2019 Special PCBs (5pcs/lot) for Reliable Key Fob Repairs

Problem: Struggling to Find Reliable Key Fob PCBs for Honda Civic 2016-2019? For automotive repair shops and Honda Civic owners, sourcing compatible, high-quality key fob PCBs can be a frustrating cha…

Java 和 Apache POI 处理 Excel 文件

一、引言 在企业应用中,Excel 是一种常见的数据存储和交换格式。Java 通过 Apache POI 库可以高效地读取、修改和写入 Excel 文件。本文介绍如何使用 Java 处理 Excel 文件,包括读取、写入和修改数据。 二、环境准备…

rust第二篇:语法学习

rust第二篇:语法学习rust用关键字fn定义函数,形参后面紧跟一个冒号,之后才是变量类型,返回值类型前有一个->,函数实现中最后可以省略return关键字。 rust用let声明变量,变量类型可以省略,编辑器会自动推导。…

啊队队队第二次团队作业--原型设计+概要设计

第二次团队作业作业所属课程 班级的链接作业要求 https://edu.cnblogs.com/campus/fzu/202501SoftwareEngineering/homework/14580作业目标 提交原型设计,系统设计,数据库设计以及相关需求分析的文档团队名称 啊对对…

IO 2024 Round 3(团体赛)Unofficial Mirror

IO 2024 Round 3(团体赛)Unofficial Mirror 停课集训周三休息没啥事干继续打团战。 队员: yangjinhua Hexiuqi 无名之雾 赛前写了个随机数选择使用 Hexiuqi 的号。 很早吃完饭从食堂往回走,期间 hxq 疯狂想要站在我…

有志青年

我从他的身上看到了青年人应有的奋进昂扬的姿态,和我颇为相似的他,让我在竞赛时被压制抛弃的价值观得到认可,让我重拾自信,我不再相信我要去迎合他人的想法,去刻意合群,我也不再对自己曾经信奉的价值观评头品足。…

python舆情分析可视化平台 情感分析 微博 爬虫 scrapy爬虫手艺 朴素贝叶斯分类算法大数据 计算机✅

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

90%的OKR都写成了KPI?其实你缺的不是表格,而是教练

本文针对OKR流于形式变成KPI的痛点,介绍了一套专业的AI指令,能扮演"OKR教练"角色。通过产品经理的实战案例对比,展示了如何用AI将模糊的任务清单转化为具备挑战性和价值导向的OKR体系,帮助团队实现真正的…

Python thread lambda run multiple functions

import datetime import uuid import time import numpy as np import threadingdef get_uuid_time():return f"{uuid.uuid4().hex}_{datetime.datetime.now().strftime("%Y%m%d%H%M%S%f")}"def …

数据分析核心术语略解 - 指南

数据分析核心术语略解 - 指南2025-11-20 22:53 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important…

我为什么要学MCP?

以下内容完全紧扣官方文档,目的在于提取主要内容方便小白理解。 由于是了解 MCP 理论的文章,这里暂时不做 MCP server/client 代码的实战讲解。一、概念 MCP 是一个为大型语言模型(LLM)与“外部世界”(文件、数据…

storybook 和 vitepress选哪个作为组件文档站点更合适

选择 Storybook 还是 VitePress 作为 Vue 3 组件库的文档站点,取决于你的核心目标:如果你侧重 交互式组件开发、调试、测试和设计系统管理 → 选 Storybook。 如果你侧重 轻量、快速、内容导向的技术文档(含示例) …

csp-s 2025 随笔

csp-s2025 T2 考场的时候把 $k<=10$ 看成 $k<=1e4$ 了,当时想了半天我说 CCF 怎么这次出的那么难呢,拿了个特殊性质 A 就跑了,你的这就算了吧,更可恶的是开二维数组 a[maxn][maxn](maxn=1e4+5)直接 MLE 了…