lua-users home
lua-l archive

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




Dibyendu Majumdar <mobile@majumdar.org.uk>于2017年2月22日周三 下午7:26写道:
>> aside your love for Lua and your wish to use Lua everywhere, would you
>> still use Lua as a general purpose application development platform?
>
>
> We now use lua both in game client and server. For our game server, there
> are about 10K C loc (https://github.com/cloudwu/skynet) for the framework ,
> and more than 100K lua loc for gameplay.
>
> For mmo game server, Lua is still the best choice rather than go,erlang,
> python or nodejs because we choose the actor model for the game server
> framework like erlang. We can run thousands lua vm in one process that
> python can't (because of GIL). LuaJIT is not suitable too because of 2G
> memory limit. I think our framework (skynet) has better performance than
> nodejs even nodejs use v8 JIT, because skynet can use all the cpu cores. I
> have tried luaJIT for my framework , only 10%~15% performance improvements.
>
> And coroutine in lua can be a better solution for asynchronous programming
> than callback model in nodejs.

Looks like Go might be an option for you as it is designed for this use case?


GC may be the  primal problem for Go although now is much better than before. Our project started  in 2012, and before go 1.5 (2015), gc in go is terrible. 

Our mmo game server used over 60G memory and 32 cores (for >10k player online) , gc may stop the world for a short time with such large heap. In my opinion, for the net/web service , latency is more important than performance , especially for game service. 

In skynet (our game framework), we use ten thousands independent lua vm in one process, which one use 1M~20M memory. They can do gc circle independently, with different frequency. And we set memory limit for different modules to avoid memory leak bug (sometimes, we forgot to dereference the object not used, it can't be collect). In go, it's hardly to limit the memory for each module/goroutine.

Another problem is about hot update. We need fix bug or update new version without shutdown the process. Lua is easy to do that but it's hardly for Go.

Erlang is similar for this use case, but our colleagues don't like write  the business code in functional language. We tried to embed lua into erlang at first, but the performance is not good enough, so we rewrite the framework in C.