lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Jul 21, 2007, at 08:21, Duck wrote:

Well, you might be writing a "serious" server using blocking I/O and multiple threads, e.g. with LuaTask, instead of using non-blocking I/O and coroutines, e.g. with COPAS. (If very high concurrency is not an issue, both approaches are programmatically appropriate -- different strokes for different folks.)

Well... I went down the coroutine + non-blocking I/O road initially for an HTTP server of mine [1]... but... in practice... this doesn't really work for anything but demo-ware... because as soon as you start doing any non trivial processing per request... your server effectively start processing those requests serially as one cannot realistically extend cooperative threading across the existing tool chain (e.g. file IO is still blocking, etc)... so one end up with a fancy coroutine based server which effectively can only handle one request at the time... sigh... :(

My current approach [2], while not as glamourous and demo-ware friendly as a coroutine based one, is to outsource the entire concurrency and socket handling to an external host environment, D. J. Bernstein's tcpserver [3] in this case, while keeping all the interesting processing in pure Lua.

In practice, this latest approach provides a much better throughput and concurrency level that anything I have tried using only coroutines and LuaSocket.

As always, YMMV.