Mq Lua

lua-users home
wiki

mqlua is a "different" way to execute Lua code. It combines three existing technologies: Lua, POSIX threads, and, 0MQ (zeromq.orq). It comes as a binary, called "mqlua", which takes a filename of a Lua program as argument. This Lua program is meant to "orchestrate" a network of so called nodes.

This program can thus create "nodes" using the "node" module. Nodes are independent Lua states running in their own thread. Nodes can communicate using 0MQ (zeromq) message queues. The Lua states run truly in parallel and use all available CPU cores. This has nothing to do with Lua coroutines (which are still available to each Lua state).

Nodes can communicate between threads in the same process, processes on the same machine, or, processes on different machines by using zeromq message queues. Lua nodes allow for full distributed/parallel processing, using a simple language, Lua.

A new Node (i.e. a Lua state running in its own thread) is created using node.create():

local n = node.create('worker.lua', 'bee', 42)

This will create a new thread with a new Lua state, running the chunk found in the file "worker.lua", passing the arguments "bee" and 42 in "..." to worker.lua.

Nodes can use the "zmq" module to communicate with each other. So it is possible to run multiple independend Lua threads in one process and have them communicate with each other, or with Nodes in differents processes on the same machine, or with Nodes running on remote machines.

The sourcecode can be found at https://github.com/arcapos/mqlua

Note that building mqlua also requires the luazmq module, which can be found at https://github.com/arcapos/luazmq

Author: MarcBalmer


RecentChanges · preferences
edit · history
Last edited January 31, 2020 10:36 am GMT (diff)