6

ngx_lua vs Go

 2 years ago
source link: https://fann.im/blog/2015/11/07/ngx_lua-vs-go/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

ngx_lua vs Go

Nov 7, 2015

由于移动互联网的火爆,前后端分离的开发模式越来越流行:后端通过 API 提供数据,前端 native or web 做数据展示交互。那么谁能把吐数据这件事做的又快又好,谁就比较适合做服务端应用开发。

2011年我们开始用 OpenResty(ngx_lua) 作为服务端应用解决方案,最近一个项目换用 Go,简单做个对比:

ngx_lua:

  1. 快,和 nginx 简直绝配,尤其是分执行阶段进行操作
  2. 同步方式写异步非阻塞,相比 Node.js 回调,代码体验好
  3. 但还不够好,欠缺在开发效率,社区丰富程度,我们这些使用者也有责任
  4. Lua 语言非常棒,简单高效,但相较于其他语言这些年进步太慢
  5. LuaJIT 让性能爆表,但只兼容到 Lua 5.1,见过很多因为用错版本而引发错误。原开发者不再继续维护,转有 CloudFlare 接手,后续有一定不确定性 via
  6. nginScript 现在和 ngx_lua 完全没有可比性,未来很难说,毕竟有官方支持,加上 js 一统江湖的趋势
  7. nginx 本身主要处理 HTTP 业务,适用范围相对有限,不过现在有了 TCP Proxy,后面想象力也会很大。
  1. 学院派看 Go 语言的设计有很多缺陷,但从工程的角度,简单,规范,标准库丰富
  2. 开发效率高,自测性能在 ngx_lua 70% 左右,大多数情况下完全够用
  3. goroutine + channel,同步方式写异步
  4. 方便的工具链,go fmt/doc/test/pprof
  5. 跨平台编译,单二进制文件,部署方便
  6. 虽然有 go get,但一开始没有原生包管理是很大的失败,现在社区已经分裂出 godep/govender/nut/gb/glide/gopkg.in 等等

Was this page helpful?


Recommend

  • 148
    • pkxpp.github.io 7 years ago
    • Cache

    Notepad++配置lua环境

    Notepad++配置lua环境

  • 14

    基于ngx_lua模块的waf开发实践 zhangsan

  • 7

    ngx_lua_waf适应多站点情况的研究 zhangsan

  • 16
    • blog.huoding.com 5 years ago
    • Cache

    关于OpenResty里的ngx.on_abort

    关于 OpenResty 里的 ngx.on_abort ,官方文档里是这样说明的: Registers a user Lua function as the callback which gets called automatically...

  • 28
    • www.cnblogs.com 4 years ago
    • Cache

    ngx_align 值对齐宏

    ngx_align 值对齐宏 ngx_align 为nginx中的一个值对齐宏。主要在需要内存申请的地方使用,为了减少在不同的 cache line 中内存而生。 // d 为需要对齐的 // a 为对齐宽度,必须为 2 的幂 // 返回对齐值 #define ngx...

  • 17

    Example of Angular 4 Pagination Using ngx-pagination This tutorial help to implement Angular 4 pagination into HTML table using ngx-pagination.I will demonstrate how to implement HTML listing with pagination us...

  • 19
    • www.digitalocean.com 3 years ago
    • Cache

    How To Use ngx-translate with Angular

    Tutorial How To Use ngx-translate with Angular Angular Introduction At some point,...

  • 4
    • nginx.org 3 years ago
    • Cache

    Module ngx_http_ssl_module

    Module ngx_http_ssl_module The ngx_http_ssl_module module provides the necessary support for HTTPS. This module is not built by default, it should be enabled with the --with-http_ssl_module configu...

  • 3
    • www.jansora.com 2 years ago
    • Cache

    Openresty 常用的 ngx 包和方法

    openresty 都有哪些 ngx 包或方法 OpenResty 是一个基于 Nginx 和 LuaJIT 的 Web 平台,提供了大量的模块和库以便开发高性能的 Web 应用。以下是一些常见的 OpenResty 与 Nginx 相关的 ngx 模块和方法: ngx_http_lua_mo...

  • 14
    • nginx.org 1 year ago
    • Cache

    Module ngx_http_proxy_module

    Module ngx_http_proxy_module The ngx_http_proxy_module module allows passing requests to another server. Example Configurationlocation / { proxy_pass http://localhost:8000; pro...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK