Hello!
You should remove the line `multi_accept on;` from your nginx.conf.
Also, you should configure `accept_mutex off`.
Also be aware that the web browser may serialize your requests to
avoid flooding the web server. You may want to use curl in multiple
shell sessions to test this instead.
Finally, one should never ever block nginx with such intensive CPU
computation for so long. If one has to do this occasionally, they
should periodically voluntarily give up the CPU to the nginx event
loop by calling ngx.sleep(0) on the Lua land (this needs at least
OpenResty 1.11.2.5 RC1 though).
Regards,
-agentzh
On Mon, Aug 14, 2017 at 5:18 AM, artur233945 <artur...@gmail.com> wrote:
> Hi, I'm new to this list and OpenResty and trying to make my Lua content
> handlers run in parallel, but it seems that only one active worker per
> location is enabled, which is pretty non-obvious to me.
>
> For testing I created simple nginx.conf with 4 workers and 2 locations
> (/test and /test2) and identical content handlers that do blocking "hard
> work", emiting json after around 5 seconds. When I run 3 queries in a
> browser, simply by clicking tab and pressing F5 with ~1sec delay, queries
> /test2 (A) and /test (B) run in parallel, but third query to /test (C)
> absolutely waits for (B). If I run all three queries to /test, they all are
> executed in order, total 15 seconds.
>
> Since I have only one location by app design, Lua handlers will never run in
> additional workers, constraining my app to a single CPU.
>
> It clearly seems that I'm missing something, but googling for "lua nginx
> worker", "nginx lua only one worker", etc. didn't provide anything useful.
> Can someone please confirm what is intended behavior or what is my
> configuration bug?
>
> Thank you in advance!
>
> ---
>
> (nginx.conf and error.log attached)
>
> uname -a = Linux user-VirtualBox 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2
> 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
> openresty -v = nginx version: openresty/1.11.2.4
> (openresty installed via "deb http://openresty.org/package/ubuntu xenial
> main" repository).