# ab -n 200 -c 100 localhost/mongo
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
apr_socket_recv: Connection reset by peer (104)
Total of 119 requests completed
# tail error.log
2012/03/28 17:37:29 [notice] 18540#0: signal process started
2012/03/28 17:37:32 [warn] 18541#0: lua_code_cache is off; this will
hurt performance in /usr/local/openresty/nginx/conf/nginx.conf:55
orker process: lj_ctype.h:395: ctype_check: Assertion `id > 0 && id <
cts->top' failed.
2012/03/28 17:37:43 [alert] 18542#0: worker process 18543 exited on
signal 6
# sbin/nginx -V
nginx version: ngx_openresty/1.0.11.19
built by gcc 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-debug
--with-cc-opt=-O0 --add-module=../ngx_devel_kit-0.2.17 --add-module=../
echo-nginx-module-0.38rc1 --add-module=../xss-nginx-module-0.03rc9 --
add-module=../ngx_coolkit-0.2rc1 --add-module=../set-misc-nginx-
module-0.22rc5 --add-module=../form-input-nginx-module-0.07rc5 --add-
module=../encrypted-session-nginx-module-0.02 --add-module=../
ngx_lua-0.5.0rc16 --add-module=../headers-more-nginx-module-0.17rc1 --
add-module=../srcache-nginx-module-0.13rc3 --add-module=../array-var-
nginx-module-0.03rc1 --add-module=../memc-nginx-module-0.13rc3 --add-
module=../redis2-nginx-module-0.08rc4 --add-module=../upstream-
keepalive-nginx-module-0.7 --add-module=../auth-request-nginx-
module-0.2 --add-module=../rds-json-nginx-module-0.12rc7 --add-
module=../rds-csv-nginx-module-0.05rc1 --with-ld-opt=-Wl,-rpath,/usr/
local/openresty/luajit/lib --with-http_ssl_module
# uname -a
Linux simon-1 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC
2011 i686 i686 i386 GNU/Linux
================
ab -n 200 -c 1 localhost/mongo 一个并发就不会有问题。
将lua_code_cache设为on,ab会挂住超时:
# ab -n 200 -c 100 localhost/mongo
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
apr_poll: The timeout specified has expired (70007)
Total of 101 requests completed
================ 退出时的堆栈:
(gdb) c
Continuing.
Program received signal SIGABRT, Aborted.
0x0014e416 in __kernel_vsyscall ()
(gdb) bt
#0 0x0014e416 in __kernel_vsyscall ()
#1 0x005b6e71 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/
raise.c:64
#2 0x005ba34e in abort () at abort.c:92
#3 0x005af888 in __assert_fail (assertion=0x560667 "id > 0 && id <
cts->top",
file=0x56065c "lj_ctype.h", line=395, function=0x563ab2
"ctype_check")
at assert.c:81
#4 0x005376eb in ctype_check (g=<value optimized out>, cd=0xb66f56f8)
at lj_ctype.h:395
#5 ctype_get (g=<value optimized out>, cd=0xb66f56f8) at lj_ctype.h:
402
#6 ctype_child (g=<value optimized out>, cd=0xb66f56f8) at lj_ctype.h:
413
#7 ctype_raw (g=<value optimized out>, cd=0xb66f56f8) at lj_ctype.h:
420
#8 lj_cdata_free (g=<value optimized out>, cd=0xb66f56f8) at
lj_cdata.c:69
#9 0x004f6877 in gc_sweep (g=0xb78251f0, p=0xb68f0c68, lim=31) at
lj_gc.c:404
#10 0x004f7ec8 in gc_onestep (L=0xb6a8fdd0) at lj_gc.c:631
#11 0x004f860f in lj_gc_step (L=0xb6a8fdd0) at lj_gc.c:675
#12 0x0050339b in lua_createtable (L=0xb6a8fdd0, narray=0, nrec=3)
at lj_api.c:655
#13 0x00543598 in lib_create_table (L=0xb6a8fdd0, libname=0x0,
p=0x566361 "\004free\003set\374\001\307__index\372\377",
cf=0x56886c)
at lj_lib.c:40
#14 lj_lib_register (L=0xb6a8fdd0, libname=0x0,
p=0x566361 "\004free\003set\374\001\307__index\372\377",
cf=0x56886c)
at lj_lib.c:52
#15 0x0055518d in luaopen_ffi (L=0xb6a8fdd0) at lib_ffi.c:799
#16 0x004f469f in lj_BC_FUNCC ()
from /usr/local/openresty/luajit/lib/libluajit-5.1.so.2
#17 0x0054e5da in lj_cf_package_require (L=0xb6a8fdd0) at
lib_package.c:423
#18 0x004f469f in lj_BC_FUNCC ()
from /usr/local/openresty/luajit/lib/libluajit-5.1.so.2
#19 0x0054e5da in lj_cf_package_require (L=0xb6a8fdd0) at
lib_package.c:423
#20 0x004f469f in lj_BC_FUNCC ()
from /usr/local/openresty/luajit/lib/libluajit-5.1.so.2
#21 0x0054e5da in lj_cf_package_require (L=0xb6a8fdd0) at
lib_package.c:423
#22 0x004f469f in lj_BC_FUNCC ()
from /usr/local/openresty/luajit/lib/libluajit-5.1.so.2
#23 0x0054e5da in lj_cf_package_require (L=0xb6a8fdd0) at
lib_package.c:423
#24 0x004f469f in lj_BC_FUNCC ()
from /usr/local/openresty/luajit/lib/libluajit-5.1.so.2
#25 0x005059fe in lua_resume (L=0xb6a8fdd0, nargs=0) at lj_api.c:1113
#26 0x081002e1 in ngx_http_lua_run_thread (L=0xb78251c0, r=0x87cdf18,
ctx=0x87e4800, nret=0) at ../ngx_lua-0.5.0rc16/src/
ngx_http_lua_util.c:786
#27 0x08103a11 in ngx_http_lua_content_by_chunk (L=0xb78251c0,
r=0x87cdf18)
at ../ngx_lua-0.5.0rc16/src/ngx_http_lua_contentby.c:92
#28 0x08103da9 in ngx_http_lua_content_handler_file (r=0x87cdf18)
at ../ngx_lua-0.5.0rc16/src/ngx_http_lua_contentby.c:243
---Type <return> to continue, or q <return> to quit---
#29 0x08103bb5 in ngx_http_lua_content_handler (r=0x87cdf18)
at ../ngx_lua-0.5.0rc16/src/ngx_http_lua_contentby.c:172
#30 0x0808bd6a in ngx_http_core_content_phase (r=0x87cdf18,
ph=0x87e0034)
at src/http/ngx_http_core_module.c:1375
#31 0x0808ac38 in ngx_http_core_run_phases (r=0x87cdf18)
at src/http/ngx_http_core_module.c:871
#32 0x0808abcd in ngx_http_handler (r=0x87cdf18)
at src/http/ngx_http_core_module.c:854
#33 0x08096901 in ngx_http_process_request (r=0x87cdf18)
at src/http/ngx_http_request.c:1671
#34 0x0809556d in ngx_http_process_request_headers (rev=0xb6ea5874)
at src/http/ngx_http_request.c:1117
#35 0x08094e26 in ngx_http_process_request_line (rev=0xb6ea5874)
at src/http/ngx_http_request.c:917
#36 0x080941a2 in ngx_http_init_request (rev=0xb6ea5874)
at src/http/ngx_http_request.c:522
#37 0x08081dae in ngx_epoll_process_events (cycle=0x87c6dc8,
timer=4997,
flags=1) at src/event/modules/ngx_epoll_module.c:678
#38 0x08075047 in ngx_process_events_and_timers (cycle=0x87c6dc8)
at src/event/ngx_event.c:245
#39 0x080800bb in ngx_worker_process_cycle (cycle=0x87c6dc8, data=0x0)
at src/os/unix/ngx_process_cycle.c:801
#40 0x0807d39f in ngx_spawn_process (cycle=0x87c6dc8,
proc=0x807ff6e <ngx_worker_process_cycle>, data=0x0,
name=0x8132d7f "worker process", respawn=0)
at src/os/unix/ngx_process.c:196
#41 0x0807fc61 in ngx_reap_children (cycle=0x87c6dc8)
at src/os/unix/ngx_process_cycle.c:617
#42 0x0807ecb2 in ngx_master_process_cycle (cycle=0x87c6dc8)
at src/os/unix/ngx_process_cycle.c:180
#43 0x080589d7 in main (argc=1, argv=0xbf850a04) at src/core/nginx.c:
411
(gdb)
=============== mongo.lua
local mongol = require "resty.mongol"
local conn = mongol ("10.6.2.51" ) -- Connect to localhost:27017
local db = conn:new_db_handle("test")
col = db:get_col("test")
col:insert({{name="dog"}})
ngx.say("ok")
春老师有时间帮忙看看,lua虚拟机实在不懂