openresty say_hello 性能测试

openresty

route:get("/say_hello", function(self)

    ngx.say('hello')

end)

测试,注意关闭 #lua_code_cache off;

$ ./wrk -t12 -c100 -d30s http://localhost:6699/say_hello
Running 30s test @ http://localhost:6699/say_hello
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     8.91ms   26.32ms 361.12ms   93.81%
    Req/Sec     3.48k     1.49k   19.27k    81.68%
  1228717 requests in 30.10s, 250.71MB read
Requests/sec:  40823.76
Transfer/sec:      8.33MB

spring boot

@RequestMapping(value = "/say_hello")
    public String sayHello(){
        return "hello";
    }

测试

$ ./wrk -t12 -c100 -d30s http://localhost:9000/web/say_hello
Running 30s test @ http://localhost:9000/web/say_hello
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    22.53ms   48.40ms 636.73ms   90.86%
    Req/Sec     1.06k   424.26     4.11k    69.68%
  377705 requests in 30.08s, 53.02MB read
Requests/sec:  12558.31
Transfer/sec:      1.76MB

大概是 spring boot 的4倍

转载于:https://my.oschina.net/yangjiandong/blog/651422

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
`ngx_upstream_module` 是 OpenResty 中的一个模块,它提供了对 upstream 的支持。Upstream 是一个概念,用于表示一组后端服务器。在使用 upstream 时,客户端的请求会被反向代理到一个或多个后端服务器上进行处理。 `ngx_upstream_module` 提供了一些方法和指令,可以动态地管理 upstream 中的服务器,包括添加、删除、修改服务器等操作。常用的指令包括: - upstream:定义一个 upstream。 - server:定义一个服务器,包括地址和端口等信息。 - keepalive:设置连接池的大小。 - least_conn:使用最少连接数的负载均衡算法。 - ip_hash:使用 IP 地址进行哈希的负载均衡算法。 常用的方法包括: - ngx.upstream.get_servers(name):获取一个 upstream 中所有的服务器。 - ngx.upstream.add_server(name, server, weight):向一个 upstream 中添加服务器。 - ngx.upstream.remove_server(name, server):从一个 upstream 中删除服务器。 - ngx.upstream.set_peer_down(name, server):将一个服务器标记为不可用。 - ngx.upstream.set_peer_up(name, server):将一个服务器标记为可用。 在使用 `ngx_upstream_module` 时,需要在编译 OpenResty 时包含 `--with-http_upstream_module` 选项。可以通过以下命令检查当前 OpenResty 是否已经安装了 `ngx_upstream_module` 模块: ```shell $ /path/to/openresty/nginx/sbin/nginx -V 2>&1 | grep -o with-http_upstream_module ``` 需要将 `/path/to/openresty` 替换为实际的 OpenResty 安装路径。如果输出 `with-http_upstream_module`,则说明已经安装了 `ngx_upstream_module` 模块。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值