Turbo.lua
lastmod 2019-07-15created 2019-05-222 edits
Turbo is a framework built for LuaJIT 2 to simplify the task of building fast and scalable network applications. It uses a event-driven, non-blocking, no thread design to deliver excellent performance and minimal footprint to high-load applications while also providing excellent support for embedded uses. The toolkit can be used for HTTP REST API's, traditional dynamic web pages through templating, open connections like WebSockets, or just as high level building blocks for native speed network applications.
First and foremost the framework is aimed at the HTTP(S) protocol. This means web developers and HTTP API developers are the first class citizens. But the framework contains generic nuts and bolts such as; a I/O loop, IO Stream classes, customizeable TCP (with SSL) server classes giving it value for everyone doing any kind of high performance network application. It will also speak directly to your exising C libraries, and happily also create native C struct's for the ultimate memory and CPU performance.
Keep in mind that running this with LuaJIT provides you with roughly the speed of compiled C code with only a fraction of the development time. Perfect for small devices running cheap CPU's on battery power as well as your pay per use Amazon cluster.
LuaJIT 2 is REQUIRED, PUC-RIO Lua is unsupported.
API Documentation is available at https://turbo.readthedocs.io, or it can be built from source with make html from /doc in the source tree.
It's main features and design principles are:
- Simple and intuitive API (much like Tornado).
- Low-level operations is possible if the users wishes that.
- Implemented in straight Lua and LuaJIT FFI on Linux, so the user can study and modify inner workings without too much effort. The Windows implementation uses some Lua modules to make compability possible.
- Good documentation
- Event driven, asynchronous and threadless design
- Small footprint
- SSL support (requires OpenSSL or LuaSec module for Windows)
Troubleshooting
luarocks install prefix
When installing with luarocks install turbo, the installation may fail if the default rocks path (/usr/loacl) is different.
In this case, either edit Turbo's Makefile directly, or refer to that file1 and pass the relevant environment variables yourself.
Note that if you pass CFLAGS to luarocks, the relevant environment variables may not be propagated. Instead, you can pass the include path using CPATH.