I'm Luvin It
Introduction to Luvit and Virgo project
Tomaz Muraus
[email protected]
FOSDEM 2013, Brussels, Belgium
Agenda
- What is Luvit?
- Luvit History
- Why Should I Care?
- Virgo
- Questions
Who am I?
- Tomaz Muraus, @KamiSLO,
+Tomaz Muraus
- Github: github.com/Kami
-
- Engineer at Rackspace (Cloud Monitoring, Service Registry)
- Apache Libcloud Project chair & committer
- Dude who likes open standards and open source
What is Luvit?
Luvit - HTTP Server Example
local http = require('http')
http.createServer(function (req, res)
local body = 'Hello FOSDEM\n'
res:writeHead(200, {
['Content-Type'] = 'text/plain',
['Content-Length'] = #body
})
res:finish(body)
end):listen(8080)
print('Server listening at http://localhost:8080/')
Luvit History
- Originally developed by Tim Caswell
- https://github.com/creationix
- First version released in September 2011 (young project)
- A lot of contributions by Rackers (Ryan Philips, Brandon Philips)
- Current stable version is 0.6.0
Why Should I Care?
- Lua is cool
- Mostly (some of the same issues as JavaScript)
- Used as a scripting / secondary language in many apps and
games
- World of Warcraft
- awesome am
- Easy to embed
- LuaJIT is even more cool
- JIT compiler
- Other popular JIT compiler: v8, pypy jit, tracemonkey, ...
- FFI API
Lua C stack based API
#include
#include
#include
#include
int main()
{
lua_State *L = luaL_newstate();
if (luaL_dostring(L, "function foo (x,y) return x+y end")) exit(1);
lua_getglobal(L, "foo");
lua_pushinteger(L, 5);
lua_pushinteger(L, 3);
lua_call(L, 2, 1);
printf("Result: %d\n", lua_tointeger(L, -1));
lua_close(L);
return 0;
}
Virgo
- Platform for building host agents
- Initial implementation - Rackspace Monitoring agent
- Runs on a server and collects metrics
- Sends collected metrics and data to the agent endpoint over TCP (TLS)
- We use sigar for metrics collection / system information
- Low memory footprint
- Runs on Linux and Windows
- Statically link all the things
Why We Picked Luvit?
- Easy to embed
- Faster development cycle
- Easier to update
- Low memory footprint
- Speed
- Previous experience with Lua from the Cloudkick agent
Virgo - layers
Virgo - Goals
- Low (memory) footprint
- Cross platform support
- Secure
- Communication only over HTTPS
- Signed bundles
- Signed binaries (also Windows specific stuff)
- Simple protocol
Virgo - Memory Usage
Virgo - communication with the endpoint(s)
Virgo - protocol example (request)
{
"v": "1",
"id": 0,
"source": "agentA",
"target": "endpoint",
"method": "heartbeat.post",
"params": {
"timestamp": 1325645515246
}
}
Virgo - protocol example (response)
{
"v": "1",
"id": 1,
"source": "endpoint",
"target": "agentA",
"result": {
"timestamp": 1325645515246
}
}
Thanks