使用 ab 命令对 http 服务进行压测

ab命令全称为:Apache bench 。是Apache自带的压力测试工具。ab命令非常实用,它不仅可以对Apache服务器进行网站访问压力测试,也可以对或其它类型的服务器进行压力测试。可以测试安装Web服务器每秒种处理的HTTP请求。 使用 Go 创建一个简单的 http 接口 package main import ( "log" "net/http" ) func main() { http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello World")) }) err := http.ListenAndServe(":8888", nil) if err != nil { log.Fatalf("ListenAndServe: %v", err) } } 使用 ab 命令进行压测 # 并发 1 00 个连接,共 10000 个请求 ab -n 10000 -c 100 http://localhost:8888/hello 结果: This is ApacheBench, Version 2.3 <$Revision: 1901567 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.

READ MORE

使用certbot

1 dnf install certbot 2 yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 3 dnf install certbot 4 dnf install python3-certbot-nginx 5 dnf install nginx 6 nginx 7 systemctl stop oracle-cloud-agent 8 systemctl disable oracle-cloud-agent 9 systemctl stop oracle-cloud-agent-updater 10 systemctl disable oracle-cloud-agent-updater 11 systemctl stop firewalld.service 12 systemctl disable firewalld.service 13 certbot --nginx -d bark.greycode.top 14 history

READ MORE

Docker 客户端(Linux)配置代理 pull 镜像

原因 身处墙国,拉取镜像非常慢,所以要设置代理来提升拉取镜像的速度。 设置方法 创建文件夹 $ sudo mkdir -p /etc/systemd/system/docker.service.d 新建配置文件 $ sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf 填入代理配置: [Service] Environment="HTTP_PROXY=http://127.0.0.1:7890" Environment="HTTPS_PROXY=http://127.0.0.1:7890" Environment="NO_PROXY=your-registry.com,10.10.10.10,*.example.com" 如果你自己建了私有的镜像仓库,需要 dockerd 绕过代理服务器直连,那么配置 NO_PROXY 变量,多个 NO_PROXY 变量的值用逗号分隔,而且可以使用通配符(*),极端情况下,如果 NO_PROXY=*,那么所有请求都将不通过代理服务器。如果不需要可以直接不设置这个变量 重启服务 $ sudo systemctl daemon-reload $ sudo systemctl restart docker 检查配置 $ sudo systemctl show --property=Environment docker [sudo] password for zheng: Environment=HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890 设置成功🎉

READ MORE

Nginx Process Model

Introduction Nginx adopts a unique master and multi workers process pool mechanism, which guarantees stable operation and flexible configuration of Nginx. Usually, Nginx will start a master process and multiple worker processes to provide external services. The master process, known as the monitoring process, did not handle specific TCP/HTTP requests and received only the Unix signal. Worker processes compete equally for accepting client connections, executing the main business logic of Nginx, and Using epoll, kqueue, and other mechanisms to process TCP/HTTP requests efficiently.

READ MORE

OpenResty 安装入门教程

方法1: [推荐] 源码编译安装 去下载页面下载源码包,然后执行下面的命令进行解压,编译和安装 tar -xvf openresty-VERSION.tar.gz cd openresty-VERSION/ ./configure -j2 make -j2 sudo make install # better also add the following line to your ~/.bashrc or ~/.bash_profile file. export PATH=/usr/local/openresty/bin:$PATH 方法2: 在 ArchLinux 安装 在官方预编译包列表中,没有编译 ArchLinux 的包,所以我们可以直接使用 yay 包管理器来安装,可以看AUR地址 首先要在电脑上安装 yay 包管理器,然后执行下面的命令进行安装: yay -S openresty 等命令执行完,按提示在你的环境变量文件中添加 OpenResty 的安装路径,就添加下面这一行到你的环境变量配置文件中 export PATH=/opt/openresty/bin:$PATH 然后激活一下环境变量,就安装成功了 OpenResty 命令介绍 ╰─$ sudo openresty -h [sudo] password for zheng: nginx version: openresty/1.21.4.1 Usage: nginx [-?hvVtTq] [-s signal] [-p prefix] [-e filename] [-c filename] [-g directives] Options: -?

READ MORE