开发者社区 > 云原生 > 中间件 > 正文

Tengine+xquic+tongsuo+qat可以实现异步模式吗?

Tengine+xquic+tongsuo+qat可以实现异步模式吗?就是openssl的async job

展开
收起
三分钟热度的鱼 2024-02-01 16:22:26 47 0
2 条回答
写回答
取消 提交回答
  • 面对过去,不要迷离;面对未来,不必彷徨;活在今天,你只要把自己完全展示给别人看。

    Tengine+xquic+tongsuo+qat可以实现异步模式。在Tengine中,可以通过使用ngx.location.capturengx.location.content_by_lua_block等指令来实现异步请求。同时,结合xquic协议,可以实现更高效的传输。

    具体实现步骤如下:

    1. 安装Tengine、xquic、tongsuo和qat模块。
    2. 在Tengine配置文件中,配置xquic、tongsuo和qat模块。
    3. 编写Lua脚本,使用ngx.location.capturengx.location.content_by_lua_block实现异步请求。

    以下是一个简单的示例:

    http {
        # 加载xquic、tongsuo和qat模块
        load_module modules/ngx_http_xquic_module.so;
        load_module modules/ngx_http_tongsuo_module.so;
        load_module modules/ngx_http_qat_module.so;
    
        server {
            listen 443 ssl http2;
            server_name example.com;
    
            # 配置SSL证书和密钥
            ssl_certificate /path/to/cert.pem;
            ssl_certificate_key /path/to/key.pem;
    
            location /async {
                content_by_lua_block {
                    local res = ngx.location.capture("/sync", { method = ngx.HTTP_GET, args = { key = "value" } })
                    ngx.say("Async response: ", res.body)
                }
            }
    
            location /sync {
                content_by_lua_block {
                    ngx.say("This is a synchronous response")
                }
            }
        }
    }
    

    在这个示例中,我们创建了两个location,一个是/async,用于处理异步请求;另一个是/sync,用于处理同步请求。当访问/async时,Tengine会异步地调用/sync,并将结果返回给客户端。这样,我们就实现了类似openssl的async job的异步模式。

    2024-02-02 14:23:47
    赞同 展开评论 打赏
  • https://github.com/alibaba/tengine/issues/1907

    这个issue有回复 。此回答整理自钉群“Tengine和Tengine-Ingress开源交流群”

    2024-02-01 16:40:48
    赞同 展开评论 打赏
问答标签:
问答地址:

为企业提供高效、稳定、易扩展的中间件产品。

相关电子书

更多
阿里七层流量入口Tengine硬件加速探索之路 立即下载
阿里Tengine直播最佳实践 立即下载
阿里Tengine网关最佳实践 立即下载