ubuntu 16.04 - No concurrent connections with nginx-clojure using Java -
i build nginx-1.13.1 nginx-clojure-0.4.5 ubuntu 16.04.
i used sample java code nginx-clojure site (see below) inserted 1 second sleep before responding. launched 10 curl http calls invoke java code. expected after 10 secs 10 curl http calls return more or less simultaneously. instead returned 1 @ time @ 1 second interval. implies nginx and/or nginx-clojure not processing them concurrently, serially. supposed this? here's console output:
ubuntu:/share/java$ ./launchcontrollers.sh 10 fri 28 jul 15:27:21 bst 2017 curl http://localhost:80/myjava/1 & curl http://localhost:80/myjava/2 & curl http://localhost:80/myjava/3 & curl http://localhost:80/myjava/4 & curl http://localhost:80/myjava/5 & curl http://localhost:80/myjava/6 & curl http://localhost:80/myjava/7 & curl http://localhost:80/myjava/8 & curl http://localhost:80/myjava/9 & curl http://localhost:80/myjava/10 & fri 28 jul 15:27:21 bst 2017 ubuntu:/share/java$ 2017-07-28 15:27:23: hello, java & nginx! 2017-07-28 15:27:24: hello, java & nginx! 2017-07-28 15:27:25: hello, java & nginx! 2017-07-28 15:27:26: hello, java & nginx! 2017-07-28 15:27:27: hello, java & nginx! 2017-07-28 15:27:28: hello, java & nginx! 2017-07-28 15:27:29: hello, java & nginx! 2017-07-28 15:27:30: hello, java & nginx! 2017-07-28 15:27:31: hello, java & nginx! 2017-07-28 15:27:32: hello, java & nginx!
here nginx-clojure java invoke method:
public object[] invoke( map<string, object> request ) { try { thread.sleep( 1000 ); } catch ( throwable t ) { t.printstacktrace( system.err ); } return new object[] { ngx_http_ok, //http status 200 arraymap.create( content_type, "text/plain" ), //headers map new simpledateformat( ts_format ).format( new date() ) + ": " + "hello, java & nginx!\n" //response body can string, file or array/collection of them }; }
i tried substituting sleep upd socket waits udp packet , spawning 100 curl http calls (each udp socket listening unique port number). resultant behaviour strange. if sent packet each udp port, http call hangs , have kill curl calls individually. why nginx/nginx-closure behave this?
Comments
Post a Comment