欲知hi-nginx-java的并發性能,用jmeter進行測驗便知一二,
設定用戶數為100000,回圈次數為100,ramp-up perio為2:

請求地址為http://localhost/test.java,該地址對應的servlet如下:
1 private static hi.route r = hi.route.get_instance(); 2 3 public jdemo() { 4 jdemo.r.get("^/(hello|test)/?$", (hi.request req, hi.response res, Matcher m) -> { 5 this.do_hello(req, res); 6 }); 7 } 8 9 public void handler(hi.request req, hi.response res) { 10 jdemo.r.run(req, res); 11 } 12 13 private void do_hello(hi.request req, hi.response res) { 14 res.set_content_type("text/plain;charset=UTF-8"); 15 res.set_cookie("test-k", "test-v", "Max-Age=3; Path=/"); 16 res.status = 200; 17 res.content = "hello,world"; 18 }
具體實作可參考:https://github.com/webcpp/jdemo/blob/master/hi/jdemo.java

使用jmeter的命令列模式進行測驗,結果如下圖所示:


此次測驗在一臺2核4執行緒4g記憶體筆記本上完成,hi-nginx開4個作業行程,最終消耗記憶體為每作業行程68mb至101mb,并發數越大,記憶體消耗越小,

以上,足證hi-nginx-java架構可提供更優性能的java web開發方法,
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/220839.html
標籤:Java
上一篇:MFC的大致講解
下一篇:技術點14:session
