I did the test with nginx+luajit and got ~ 40k/second on the json test. I think that's about all you are going to get out of a large instance. Of course, nginx was only using a few MB of RAM... .
see https://gist.github.com/bakins/5322735 untested... .
"attempt to set status 404 via ngx.exit after sending out the response status 200"2013/4/5 Brian Akins <br...@akins.org> see https://gist.github.com/bakins/5322735 untested... .
Hello! On Fri, Apr 5, 2013 at 3:19 PM, Tor Hveem wrote: > I just benchmarked your solution vs mine, and I can't find any statistical > significane at all in the difference. But then again, I might be doing > something wrong.. > When doing benchmark, always remember to use the flamegraph tools to find where is hot! ;) See the C-land flamegraph tool for any running processes on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-bt And the Lua-land flamegraph for ngx_lua + LuaJIT 2.0/Lua 5.1.x on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-lua-bt Best regards, -agentzh
Hello! On Fri, Apr 5, 2013 at 3:19 PM, Tor Hveem wrote: > I just benchmarked your solution vs mine, and I can't find any statistical > significane at all in the difference. But then again, I might be doing > something wrong.. > When doing benchmark, always remember to use the flamegraph tools to find where is hot! ;) See the C-land flamegraph tool for any running processes on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-bt And the Lua-land flamegraph for ngx_lua + LuaJIT 2.0/Lua 5.1.x on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-lua-bt Best regards, -agentzh .
resty.mysql
ngx.ctx
looks like the code https://gist.github.com/bakins/5322735#file-luajit-benchmark-as-a-module-L29 connects to mysql on every request. what's normal way to connect once in init_by_lua and use the connection?or, is there connection pool library? On Fri, Apr 5, 2013 at 8:36 PM, agentzh <age...@gmail.com> wrote: Hello! On Fri, Apr 5, 2013 at 3:19 PM, Tor Hveem wrote: > I just benchmarked your solution vs mine, and I can't find any statistical > significane at all in the difference. But then again, I might be doing > something wrong.. > When doing benchmark, always remember to use the flamegraph tools to find where is hot! ;) See the C-land flamegraph tool for any running processes on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-bt And the Lua-land flamegraph for ngx_lua + LuaJIT 2.0/Lua 5.1.x on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-lua-bt Best regards, -agentzh . skynare ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine given db:connect() uses tcpsock:connect()On Tue, Apr 23, 2013 at 6:03 PM, Brian Akins <br...@akins.org> wrote: http://wiki.nginx.org/HttpLuaModule#tcpsock:connect "Before actually resolving the host name and connecting to the remote backend, this method will always look up the connection pool for matched idle connections created by previous calls of this method (or the ngx.socket.connect function)." And from resty-mysql: The resty.mysql object instance cannot be stored in a Lua variable at the Lua module level, because it will then be shared by all the concurrent requests handled by the same nginx worker process (seehttp://wiki.nginx.org/HttpLuaModule#Data_Sharing_within_an_Nginx_Worker ) and result in bad race conditions when concurrent requests are trying to use the same resty.mysql instance. You should always initiate resty.mysql objects in function local variables or in the ngx.ctx table. These places all have their own data copies for each request. On Tue, Apr 23, 2013 at 5:41 PM, Sam Lee <sky...@gmail.com> wrote: looks like the code https://gist.github.com/bakins/5322735#file-luajit-benchmark-as-a-module-L29 connects to mysql on every request. what's normal way to connect once in init_by_lua and use the connection?or, is there connection pool library? On Fri, Apr 5, 2013 at 8:36 PM, agentzh <age...@gmail.com> wrote: Hello! On Fri, Apr 5, 2013 at 3:19 PM, Tor Hveem wrote: > I just benchmarked your solution vs mine, and I can't find any statistical > significane at all in the difference. But then again, I might be doing > something wrong.. > When doing benchmark, always remember to use the flamegraph tools to find where is hot! ;) See the C-land flamegraph tool for any running processes on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-bt And the Lua-land flamegraph for ngx_lua + LuaJIT 2.0/Lua 5.1.x on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-lua-bt Best regards, -agentzh . agentzh Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh tor Round 4 is out. Openresty seems to do worse than in round 3. http://www.techempower.com/blog/2013/05/02/frameworks-round-4/ 2013/4/24 agentzh <age...@gmail.com> Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh. brian That may be my fault... For such a simple benchmark, coding it like you would a more complex "real" project may have some performance impact. Of course, all the tests I did showed an improvement with my changes. On Thu, May 2, 2013 at 10:53 AM, Tor Hveem <t...@hveem.no> wrote: Round 4 is out. Openresty seems to do worse than in round 3. http://www.techempower.com/blog/2013/05/02/frameworks-round-4/ 2013/4/24 agentzh <age...@gmail.com> Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh. brian Actually, some of the tests are better. I'll do a better comparison when I get a minute. tor I'm sorry I was being vague. I meant mostly doing worse in comparison of the others, not itself :)2013/5/2 Brian Akins <br...@akins.org> Actually, some of the tests are better. I'll do a better comparison when I get a minute. . brian No worries. Looks like the other frameworks got some more attention from their communities.
http://wiki.nginx.org/HttpLuaModule#tcpsock:connect "Before actually resolving the host name and connecting to the remote backend, this method will always look up the connection pool for matched idle connections created by previous calls of this method (or the ngx.socket.connect function)." And from resty-mysql: The resty.mysql object instance cannot be stored in a Lua variable at the Lua module level, because it will then be shared by all the concurrent requests handled by the same nginx worker process (seehttp://wiki.nginx.org/HttpLuaModule#Data_Sharing_within_an_Nginx_Worker ) and result in bad race conditions when concurrent requests are trying to use the same resty.mysql instance. You should always initiate resty.mysql objects in function local variables or in the ngx.ctx table. These places all have their own data copies for each request. On Tue, Apr 23, 2013 at 5:41 PM, Sam Lee <sky...@gmail.com> wrote: looks like the code https://gist.github.com/bakins/5322735#file-luajit-benchmark-as-a-module-L29 connects to mysql on every request. what's normal way to connect once in init_by_lua and use the connection?or, is there connection pool library? On Fri, Apr 5, 2013 at 8:36 PM, agentzh <age...@gmail.com> wrote: Hello! On Fri, Apr 5, 2013 at 3:19 PM, Tor Hveem wrote: > I just benchmarked your solution vs mine, and I can't find any statistical > significane at all in the difference. But then again, I might be doing > something wrong.. > When doing benchmark, always remember to use the flamegraph tools to find where is hot! ;) See the C-land flamegraph tool for any running processes on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-bt And the Lua-land flamegraph for ngx_lua + LuaJIT 2.0/Lua 5.1.x on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-lua-bt Best regards, -agentzh . agentzh Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh tor Round 4 is out. Openresty seems to do worse than in round 3. http://www.techempower.com/blog/2013/05/02/frameworks-round-4/ 2013/4/24 agentzh <age...@gmail.com> Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh. brian That may be my fault... For such a simple benchmark, coding it like you would a more complex "real" project may have some performance impact. Of course, all the tests I did showed an improvement with my changes. On Thu, May 2, 2013 at 10:53 AM, Tor Hveem <t...@hveem.no> wrote: Round 4 is out. Openresty seems to do worse than in round 3. http://www.techempower.com/blog/2013/05/02/frameworks-round-4/ 2013/4/24 agentzh <age...@gmail.com> Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh. brian Actually, some of the tests are better. I'll do a better comparison when I get a minute. tor I'm sorry I was being vague. I meant mostly doing worse in comparison of the others, not itself :)2013/5/2 Brian Akins <br...@akins.org> Actually, some of the tests are better. I'll do a better comparison when I get a minute. . brian No worries. Looks like the other frameworks got some more attention from their communities.
looks like the code https://gist.github.com/bakins/5322735#file-luajit-benchmark-as-a-module-L29 connects to mysql on every request. what's normal way to connect once in init_by_lua and use the connection?or, is there connection pool library? On Fri, Apr 5, 2013 at 8:36 PM, agentzh <age...@gmail.com> wrote: Hello! On Fri, Apr 5, 2013 at 3:19 PM, Tor Hveem wrote: > I just benchmarked your solution vs mine, and I can't find any statistical > significane at all in the difference. But then again, I might be doing > something wrong.. > When doing benchmark, always remember to use the flamegraph tools to find where is hot! ;) See the C-land flamegraph tool for any running processes on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-bt And the Lua-land flamegraph for ngx_lua + LuaJIT 2.0/Lua 5.1.x on Linux: https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-lua-bt Best regards, -agentzh . agentzh Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh tor Round 4 is out. Openresty seems to do worse than in round 3. http://www.techempower.com/blog/2013/05/02/frameworks-round-4/ 2013/4/24 agentzh <age...@gmail.com> Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh. brian That may be my fault... For such a simple benchmark, coding it like you would a more complex "real" project may have some performance impact. Of course, all the tests I did showed an improvement with my changes. On Thu, May 2, 2013 at 10:53 AM, Tor Hveem <t...@hveem.no> wrote: Round 4 is out. Openresty seems to do worse than in round 3. http://www.techempower.com/blog/2013/05/02/frameworks-round-4/ 2013/4/24 agentzh <age...@gmail.com> Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh. brian Actually, some of the tests are better. I'll do a better comparison when I get a minute. tor I'm sorry I was being vague. I meant mostly doing worse in comparison of the others, not itself :)2013/5/2 Brian Akins <br...@akins.org> Actually, some of the tests are better. I'll do a better comparison when I get a minute. . brian No worries. Looks like the other frameworks got some more attention from their communities.
Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh
Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh.
Round 4 is out. Openresty seems to do worse than in round 3. http://www.techempower.com/blog/2013/05/02/frameworks-round-4/ 2013/4/24 agentzh <age...@gmail.com> Hello! On Tue, Apr 23, 2013 at 4:11 PM, Sam Lee wrote: > ah, so `local ok, err = db:connect(mysqlconn)` for every request is fine > given db:connect() uses tcpsock:connect() > Yes, exactly :) Regards, -agentzh. brian Actually, some of the tests are better. I'll do a better comparison when I get a minute. tor I'm sorry I was being vague. I meant mostly doing worse in comparison of the others, not itself :)2013/5/2 Brian Akins <br...@akins.org> Actually, some of the tests are better. I'll do a better comparison when I get a minute. . brian No worries. Looks like the other frameworks got some more attention from their communities.
Actually, some of the tests are better. I'll do a better comparison when I get a minute. .