Jetty最大線程數原理及優化


https://blog.csdn.net/majianxiong_lzu/article/details/90237408

 

jetty性能優化思路整理

http://www.sxrczx.com/pages/gordon-tech.lofter.com/post/481906_24eb191.html

 

 

 

版權
Jetty默認的線程池初始化大小為8,最大線程數為200,在創建Server時如果沒有指定線程池數量,框架會初始化一個QueuedThreadPool。部分代碼如下:

this._threadPool = (ThreadPool)(pool != null?pool:new QueuedThreadPool());

public QueuedThreadPool() {
this(200);
}

public QueuedThreadPool(@Name("maxThreads") int maxThreads) {
this(maxThreads, 8);
}
 
如果應用的並發高於200,則默認值不符合要求,可通過以下方式調整線程數大小。

int port = 8081;
//第一個參數為最大線程數,第二個參數為最小線程數
QueuedThreadPool threadPool = new QueuedThreadPool(2000, 20);
Server server = new Server(threadPool);
ServerConnector connector = new ServerConnector(server);
connector.setPort(port);
server.addConnector(connector);

/**
* 其他設置
*
*/

//啟動
server.start();
————————————————
版權聲明:本文為CSDN博主「機器熊技術大雜燴」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/majianxiong_lzu/article/details/90237408


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM