• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

kingluo/luajit.io: luajit io framework

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

kingluo/luajit.io

开源软件地址(OpenSource Url):

https://github.com/kingluo/luajit.io

开源编程语言(OpenSource Language):

Lua 100.0%

开源软件介绍(OpenSource Introduction):

luajit.io

Introduction

Pure Lua IO framework, with C efficiency due to its simple but powerful design, and, of course, thanks to luajit, the perfect JIT engine. The HTTP Server is out-of-the-box, which simulates the functionalities and performance of nginx and ngx_lua. Moreover, it could be used to develop generic TCP/UDP server.

Why reinvent the wheel? Well, the nginx and ngx_lua is renowned at efficiency and extensible, but they are written in C language, so you need to be as smart as the authors to contribute codes. What if the core is written in pure lua language, but without any efficiency tradeoff? Then not only the web apps are extensible, but also the server core is extensible at ease by any levels of developers!

The Luajit is a perfect JIT engine to improve lua performance, so with dedicated and luajit-oriented design, the luajit.io would reassemble the advantages of nginx and ngx_lua, but provides extra benefit: simple and extensible at the core.

See the http://luajit.io for demo.

API compatible with ngx_lua (Work In Progress)

It provides seamless ngx_lua API, so third-party openresty libraries could be used in luajit.io without porting.

Tested libraries:

  • lua-resty-lock
  • lua-resty-upload
  • lua-resty-http
  • lua-resty-dns
  • lua-resty-redis
  • lua-resty-mysql
  • lua-resty-postgres

Supported Platforms

Only supports Linux on x86 or x64.

The luajit.io uses linux-specific features, e.g. epoll, signalfd, timerfd, inotify, etc.

Dependencies

  • openssl
  • zlib
  • pcre

On Debian Linux, you should install the dev packages of them, which contains the required *.so links:

apt-get install zlib1g-dev libssl-dev libpcre3-dev

On Centos Linux:

yum install zlib-devel pcre-devel openssl-devel

Status

This library is considered experimental and still under active development.

And there is still big room to improve the performance, by increasing the jit compiled ratio, which is really a tough job.

Welcome to join and help!

QuickStart

install luajit

wget https://luajit.org/download/LuaJIT-2.1.0-beta3.zip
unzip LuaJIT-2.1.0-beta3.zip
cd LuaJIT-2.1.0-beta3
make install
ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit

http server

Just like the API compatibility, the luajit.io configuration simulates the nginx.conf, so most directives are copied from there. See conf/httpd.lua for example.

Copy the example into new file, e.g. conf/myhttpd.lua, and adjust the content according to your need.

Then just run it:

luajit conf/myhttpd.lua

generic tcp server

It contains a simple socks5 server, as the generic tcp server demo.

LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0 luajit conf/socks5.lua

Note that by default, the luajit is not compiled with -lpthread, which would cause multi-threading usage crash.

See https://sourceware.org/bugzilla/show_bug.cgi?id=10652 for detail.

The async DNS resolving uses multi-threading, so either re-compile the luajit or use LD_PRELOAD before running it.

You should locate the correct version of libpthread.so on your box.

locate libpthread.so



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap