国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

SpringBoot 最大連接數(shù)及最大并發(fā)數(shù)是多少?圖解就看到了!

這篇具有很好參考價值的文章主要介紹了SpringBoot 最大連接數(shù)及最大并發(fā)數(shù)是多少?圖解就看到了!。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

在SpringBoot2.7.10版本中內(nèi)置Tomcat版本是9.0.73,SpringBoot內(nèi)置Tomcat的默認設(shè)置如下:

  • Tomcat的連接等待隊列長度,默認是100

  • Tomcat的最大連接數(shù),默認是8192

  • Tomcat的最小工作線程數(shù),默認是10

  • Tomcat的最大線程數(shù),默認是200

  • Tomcat的連接超時時間,默認是20s

springboot 連接數(shù),springboot,spring boot,后端,java,spring

相關(guān)配置及默認值如下

server:
??tomcat:
????#?當所有可能的請求處理線程都在使用中時,傳入連接請求的最大隊列長度
????accept-count:?100
????#?服務(wù)器在任何給定時間接受和處理的最大連接數(shù)。一旦達到限制,操作系統(tǒng)仍然可以接受基于“acceptCount”屬性的連接。
????max-connections:?8192
????threads:
??????#?工作線程的最小數(shù)量,初始化時創(chuàng)建的線程數(shù)
??????min-spare:?10
??????#?工作線程的最大數(shù)量?io密集型建議10倍的cpu數(shù),cpu密集型建議cpu數(shù)+1,絕大部分應(yīng)用都是io密集型
??????max:?200
????#?連接器在接受連接后等待顯示請求 URI 行的時間。
????connection-timeout:?20000
????#?在關(guān)閉連接之前等待另一個 HTTP 請求的時間。如果未設(shè)置,則使用 connectionTimeout。設(shè)置為?-1 時不會超時。
????keep-alive-timeout:?20000
????#?在連接關(guān)閉之前可以進行流水線處理的最大HTTP請求數(shù)量。當設(shè)置為0或1時,禁用keep-alive和流水線處理。當設(shè)置為-1時,允許無限數(shù)量的流水線處理或keep-alive請求。?
????max-keep-alive-requests:?100

2架構(gòu)圖

springboot 連接數(shù),springboot,spring boot,后端,java,spring

當連接數(shù)大于maxConnections+acceptCount + 1時,新來的請求不會收到服務(wù)器拒絕連接響應(yīng),而是不會和新的請求進行3次握手建立連接,一段時間后(客戶端的超時時間或者Tomcat的20s后)會出現(xiàn)請求連接超時。

3TCP的3次握手4次揮手

springboot 連接數(shù),springboot,spring boot,后端,java,spring

4時序圖

springboot 連接數(shù),springboot,spring boot,后端,java,spring

5核心參數(shù)

AcceptCount

全連接隊列容量,等同于backlog參數(shù),與Linux中的系統(tǒng)參數(shù)somaxconn取較小值,Windows中沒有系統(tǒng)參數(shù)。

NioEndpoint.java
serverSock?=?ServerSocketChannel.open();
socketProperties.setProperties(serverSock.socket());
InetSocketAddress?addr?=?new?InetSocketAddress(getAddress(),?getPortWithOffset());
//?這里
serverSock.socket().bind(addr,getAcceptCount());
MaxConnections

Acccptor.java

//?線程的run方法。
public?void?run()?{????
??while?(!stopCalled)?{?
??????//?如果我們已達到最大連接數(shù),等待
?????????connectionLimitLatch.countUpOrAwait();
????????????//?接受來自服務(wù)器套接字的下一個傳入連接
????????????socket?=?endpoint.serverSocketAccept()
????????????//?socket.close?釋放的時候?調(diào)用?connectionLimitLatch.countDown();???????
MinSpareThread/MaxThread

AbstractEndpoint.java

//?tomcat?啟動時
public?void?createExecutor()?{
????????internalExecutor?=?true;
?????//?容量為Integer.MAX_VALUE
????????TaskQueue?taskqueue?=?new?TaskQueue();
????????TaskThreadFactory?tf?=?new?TaskThreadFactory(getName()?+?"-exec-",?daemon,?getThreadPriority());
?????//?Tomcat擴展的線程池
????????executor?=?new?ThreadPoolExecutor(getMinSpareThreads(),?getMaxThreads(),?60,?TimeUnit.SECONDS,taskqueue,?tf);
????????taskqueue.setParent(?(ThreadPoolExecutor)?executor);
}

重點重點重點

Tomcat擴展了線程池增強了功能。

  • JDK線程池流程:minThreads --> queue --> maxThreads --> Exception

  • Tomcat增強后:?minThreads --> maxThreads --> queue --> Exception

MaxKeepAliveRequests

長連接,在發(fā)送了maxKeepAliveRequests個請求后就會被服務(wù)器端主動斷開連接。

在連接關(guān)閉之前可以進行流水線處理的最大HTTP請求數(shù)量。當設(shè)置為0或1時,禁用keep-alive和流水線處理。當設(shè)置為-1時,允許無限數(shù)量的流水線處理或keep-alive請求。

較大的?MaxKeepAliveRequests?值可能會導(dǎo)致服務(wù)器上的連接資源被長時間占用。根據(jù)您的具體需求,您可以根據(jù)服務(wù)器的負載和資源配置來調(diào)整?MaxKeepAliveRequests?的值,以平衡并發(fā)連接和服務(wù)器資源的利用率。

NioEndpoint.setSocketOptions?
?socketWrapper.setKeepAliveLeft(NioEndpoint.this.getMaxKeepAliveRequests());

Http11Processor.service(SocketWrapperBase<?>?socketWrapper)
??keepAlive?=?true;
??while(!getErrorState().isError()?&&?keepAlive?&&?!isAsync()?&&?upgradeToken?==?null?&&
????????????????sendfileState?==?SendfileState.DONE?&&?!protocol.isPaused())?{
????//?默認100??
?int?maxKeepAliveRequests?=?protocol.getMaxKeepAliveRequests();
?if?(maxKeepAliveRequests?==?1)?{
?????keepAlive?=?false;
?}?else?if?(maxKeepAliveRequests?>?0?&&
????????????//????
?????????socketWrapper.decrementKeepAlive()?<=?0)?{
?????keepAlive?=?false;
?}
ConnectionTimeout

連接的生存周期,當已經(jīng)建立的連接,在connectionTimeout時間內(nèi),如果沒有請求到來,服務(wù)端程序?qū)鲃雨P(guān)閉該連接。

  • 在Tomcat 9中,ConnectionTimeout的默認值是20000毫秒,也就是20秒。

  • 如果該時間過長,服務(wù)器將要等待很長時間才會收到客戶端的請求結(jié)果,從而導(dǎo)致服務(wù)效率低下。如果該時間過短,則可能會出現(xiàn)客戶端在請求過程中網(wǎng)絡(luò)慢等問題,而被服務(wù)器取消連接的情況。

  • 由于某個交換機或者路由器出現(xiàn)了問題,導(dǎo)致某些post大文件的請求堆積在交換機或者路由器上,tomcat的工作線程一直拿不到完整的文件數(shù)據(jù)。

NioEndpoint.Poller#run()

?//?Check?for?read?timeout
?if?((socketWrapper.interestOps()?&?SelectionKey.OP_READ)?==?SelectionKey.OP_READ)?{
?????long?delta?=?now?-?socketWrapper.getLastRead();
?????long?timeout?=?socketWrapper.getReadTimeout();
?????if?(timeout?>?0?&&?delta?>?timeout)?{
?????????readTimeout?=?true;
?????}
?}
?//?Check?for?write?timeout
?if?(!readTimeout?&&?(socketWrapper.interestOps()?&?SelectionKey.OP_WRITE)?==?SelectionKey.OP_WRITE)?{
?????long?delta?=?now?-?socketWrapper.getLastWrite();
?????long?timeout?=?socketWrapper.getWriteTimeout();
?????if?(timeout?>?0?&&?delta?>?timeout)?{
?????????writeTimeout?=?true;
?????}
?}
KeepAliveTimeout

等待另一個 HTTP 請求的時間,然后關(guān)閉連接。當未設(shè)置時,將使用?connectionTimeout。當設(shè)置為 -1 時,將沒有超時。

Http11InputBuffer.parseRequestLine

//?Read?new?bytes?if?needed
if?(byteBuffer.position()?>=?byteBuffer.limit())?{
????if?(keptAlive)?{
????????//?還沒有讀取任何請求數(shù)據(jù),所以使用保持活動超時
????????wrapper.setReadTimeout(keepAliveTimeout);
????}
????if?(!fill(false))?{
????????//?A?read?is?pending,?so?no?longer?in?initial?state
????????parsingRequestLinePhase?=?1;
????????return?false;
????}
????//??至少已收到請求的一個字節(jié)?切換到套接字超時。
?????wrapper.setReadTimeout(connectionTimeout);
}

6內(nèi)部線程

Acceptor

Acceptor:接收器,作用是接受scoket網(wǎng)絡(luò)請求,并調(diào)用setSocketOptions()封裝成為NioSocketWrapper,并注冊到Poller的events中。注意查看run方法org.apache.tomcat.util.net.Acceptor#run

public?void?run()?{
???while?(!stopCalled)?{
???????//?等待下一個請求進來
???????socket?=?endpoint.serverSocketAccept();
????????//?注冊socket到Poller,生成PollerEvent事件
???????endpoint.setSocketOptions(socket);
??????????//?向輪詢器注冊新創(chuàng)建的套接字
????????????????-?poller.register(socketWrapper);
????????????????????-?(SynchronizedQueue(128))events.add(new?PollerEvent(socketWrapper))??
Poller

Poller:輪詢器,輪詢是否有事件達到,有請求事件到達后,以NIO的處理方式,查詢Selector取出所有請求,遍歷每個請求的需求,分配給Executor線程池執(zhí)行。查看org.apache.tomcat.util.net.NioEndpoint.Poller#run()

public?void?run()?{
???while?(true)?{
???????????//查詢selector取出所有請求事件
???????????Iterator<SelectionKey>?iterator?=
???????????????keyCount?>?0???selector.selectedKeys().iterator()?:?null;
???????????//?遍歷就緒鍵的集合并調(diào)度任何活動事件。
???????????while?(iterator?!=?null?&&?iterator.hasNext())?{
???????????????SelectionKey?sk?=?iterator.next();
???????????????iterator.remove();
???????????????NioSocketWrapper?socketWrapper?=?(NioSocketWrapper)?sk.attachment();
???????????????//?分配給Executor線程池執(zhí)行處理請求key
???????????????if?(socketWrapper?!=?null)?{
???????????????????processKey(sk,?socketWrapper);
???????????????????-?processSocket(socketWrapper,?SocketEvent.OPEN_READ/SocketEvent.OPEN_WRITE)
???????????????????????-?executor.execute((Runnable)new?SocketProcessor(socketWrapper,SocketEvent))
???????????????}
???????????}
TomcatThreadPoolExecutor

真正執(zhí)行連接讀寫操作的線程池,在JDK線程池的基礎(chǔ)上進行了擴展優(yōu)化。

AbstractEndpoint.java

public?void?createExecutor()?{
????internalExecutor?=?true;
????TaskQueue?taskqueue?=?new?TaskQueue();
????TaskThreadFactory?tf?=?new?TaskThreadFactory(getName()?+?"-exec-",?daemon,?getThreadPriority());
?//?tomcat自定義線程池
????executor?=?new?ThreadPoolExecutor(getMinSpareThreads(),?getMaxThreads(),?60,?TimeUnit.SECONDS,taskqueue,?tf);
????taskqueue.setParent(?(ThreadPoolExecutor)?executor);
}

TomcatThreadPoolExecutor.java

//?與 java.util.concurrent.ThreadPoolExecutor 相同,但實現(xiàn)了更高效的getSubmittedCount()方法,用于正確處理工作隊列。
//?如果未指定?RejectedExecutionHandler,將配置一個默認的,并且該處理程序?qū)⑹冀K拋出?RejectedExecutionException
public?class?ThreadPoolExecutor?extends?java.util.concurrent.ThreadPoolExecutor?{
?//?已提交但尚未完成的任務(wù)數(shù)。這包括隊列中的任務(wù)和已交給工作線程但后者尚未開始執(zhí)行任務(wù)的任務(wù)。
????//?這個數(shù)字總是大于或等于getActiveCount()?。
????private?final?AtomicInteger?submittedCount?=?new?AtomicInteger(0);
????
????@Override
????protected?void?afterExecute(Runnable?r,?Throwable?t)?{
????????if?(!(t?instanceof?StopPooledThreadException))?{
????????????submittedCount.decrementAndGet();
????????}
????@Override
????public?void?execute(Runnable?command){
????????//?提交任務(wù)的數(shù)量+1
????????submittedCount.incrementAndGet();
????????try?{
????????????//??線程池內(nèi)部方法,真正執(zhí)行的方法。就是JDK線程池原生的方法。
????????????super.execute(command);
????????}?catch?(RejectedExecutionException?rx)?{
????????????//?再次把被拒絕的任務(wù)放入到隊列中。
????????????if?(super.getQueue()?instanceof?TaskQueue)?{
????????????????final?TaskQueue?queue?=?(TaskQueue)super.getQueue();
????????????????try?{
??????????????????????//強制的將任務(wù)放入到阻塞隊列中
????????????????????if?(!queue.force(command,?timeout,?unit))?{
????????????????????????//放入失敗,則繼續(xù)拋出異常
????????????????????????submittedCount.decrementAndGet();
????????????????????????throw?new?RejectedExecutionException(sm.getString("threadPoolExecutor.queueFull"));
????????????????????}
????????????????}?catch?(InterruptedException?x)?{
?????????????????????//被中斷也拋出異常
????????????????????submittedCount.decrementAndGet();
????????????????????throw?new?RejectedExecutionException(x);
????????????????}
????????????}?else?{
?????????????????//不是這種隊列,那么當任務(wù)滿了之后,直接拋出去。
????????????????submittedCount.decrementAndGet();
????????????????throw?rx;
????????????}

????????}
????}
/**
?*?實現(xiàn)Tomcat特有邏輯的自定義隊列
?*/
public?class?TaskQueue?extends?LinkedBlockingQueue<Runnable>?{
????private?static?final?long?serialVersionUID?=?1L;

????private?transient?volatile?ThreadPoolExecutor?parent?=?null;

????private?static?final?int?DEFAULT_FORCED_REMAINING_CAPACITY?=?-1;

????/**
?????*?強制遺留的容量
?????*/
????private?int?forcedRemainingCapacity?=?-1;

????/**
?????*?隊列的構(gòu)建方法
?????*/
????public?TaskQueue()?{
????}

????public?TaskQueue(int?capacity)?{
????????super(capacity);
????}

????public?TaskQueue(Collection<??extends?Runnable>?c)?{
????????super(c);
????}

????/**
?????*?設(shè)置核心變量
?????*/
????public?void?setParent(ThreadPoolExecutor?parent)?{
????????this.parent?=?parent;
????}

????/**
?????* put:向阻塞隊列填充元素,當阻塞隊列滿了之后,put時會被阻塞。
?????* offer:向阻塞隊列填充元素,當阻塞隊列滿了之后,offer會返回false。
?????*
?????*?@param?o?當任務(wù)被拒絕后,繼續(xù)強制的放入到線程池中
?????*?@return?向阻塞隊列塞任務(wù),當阻塞隊列滿了之后,offer會返回false。
?????*/
????public?boolean?force(Runnable?o)?{
????????if?(parent?==?null?||?parent.isShutdown())?{
????????????throw?new?RejectedExecutionException("taskQueue.notRunning");
????????}
????????return?super.offer(o);
????}

????/**
?????*?帶有阻塞時間的塞任務(wù)
?????*/
????@Deprecated
????public?boolean?force(Runnable?o,?long?timeout,?TimeUnit?unit)?throws?InterruptedException?{
????????if?(parent?==?null?||?parent.isShutdown())?{
????????????throw?new?RejectedExecutionException("taskQueue.notRunning");
????????}
????????return?super.offer(o,?timeout,?unit);?//forces?the?item?onto?the?queue,?to?be?used?if?the?task?is?rejected
????}

????/**
?????*?當線程真正不夠用時,優(yōu)先是開啟線程(直至最大線程),其次才是向隊列填充任務(wù)。
?????*
?????*?@param?runnable?任務(wù)
?????*?@return?false?表示向隊列中添加任務(wù)失敗,
?????*/
????@Override
????public?boolean?offer(Runnable?runnable)?{
????????if?(parent?==?null)?{
????????????return?super.offer(runnable);
????????}
????????//若是達到最大線程數(shù),進隊列。
????????if?(parent.getPoolSize()?==?parent.getMaximumPoolSize())?{
????????????return?super.offer(runnable);
????????}
????????//當前活躍線程為10個,但是只有8個任務(wù)在執(zhí)行,于是,直接進隊列。
????????if?(parent.getSubmittedCount()?<?(parent.getPoolSize()))?{
????????????return?super.offer(runnable);
????????}
????????//當前線程數(shù)小于最大線程數(shù),那么直接返回false,去創(chuàng)建最大線程
????????if?(parent.getPoolSize()?<?parent.getMaximumPoolSize())?{
????????????return?false;
????????}
????????//否則的話,將任務(wù)放入到隊列中
????????return?super.offer(runnable);
????}

????/**
?????*?獲取任務(wù)
?????*/
????@Override
????public?Runnable?poll(long?timeout,?TimeUnit?unit)?throws?InterruptedException?{
????????Runnable?runnable?=?super.poll(timeout,?unit);
????????//取任務(wù)超時,會停止當前線程,來避免內(nèi)存泄露
????????if?(runnable?==?null?&&?parent?!=?null)?{
????????????parent.stopCurrentThreadIfNeeded();
????????}
????????return?runnable;
????}

????/**
?????*?阻塞式的獲取任務(wù),可能返回null。
?????*/
????@Override
????public?Runnable?take()?throws?InterruptedException?{
????????//當前線程應(yīng)當被終止的情況下:
????????if?(parent?!=?null?&&?parent.currentThreadShouldBeStopped())?{
????????????long?keepAliveTime?=?parent.getKeepAliveTime(TimeUnit.MILLISECONDS);
????????????return?poll(keepAliveTime,?TimeUnit.MILLISECONDS);
????????}
????????return?super.take();
????}

????/**
?????*?返回隊列的剩余容量
?????*/
????@Override
????public?int?remainingCapacity()?{
????????if?(forcedRemainingCapacity?>?DEFAULT_FORCED_REMAINING_CAPACITY)?{
????????????return?forcedRemainingCapacity;
????????}
????????return?super.remainingCapacity();
????}


????/**
?????*?強制設(shè)置剩余容量
?????*/
????public?void?setForcedRemainingCapacity(int?forcedRemainingCapacity)?{
????????this.forcedRemainingCapacity?=?forcedRemainingCapacity;
????}

????/**
?????*?重置剩余容量
?????*/
????void?resetForcedRemainingCapacity()?{
????????this.forcedRemainingCapacity?=?DEFAULT_FORCED_REMAINING_CAPACITY;
????}
}?
/**
?*?實現(xiàn)Tomcat特有邏輯的自定義隊列
?*/
public?class?TaskQueue?extends?LinkedBlockingQueue<Runnable>?{
????private?static?final?long?serialVersionUID?=?1L;

????private?transient?volatile?ThreadPoolExecutor?parent?=?null;

????private?static?final?int?DEFAULT_FORCED_REMAINING_CAPACITY?=?-1;

????/**
?????*?強制遺留的容量
?????*/
????private?int?forcedRemainingCapacity?=?-1;

????/**
?????*?隊列的構(gòu)建方法
?????*/
????public?TaskQueue()?{
????}

????public?TaskQueue(int?capacity)?{
????????super(capacity);
????}

????public?TaskQueue(Collection<??extends?Runnable>?c)?{
????????super(c);
????}

????/**
?????*?設(shè)置核心變量
?????*/
????public?void?setParent(ThreadPoolExecutor?parent)?{
????????this.parent?=?parent;
????}

????/**
?????* put:向阻塞隊列填充元素,當阻塞隊列滿了之后,put時會被阻塞。
?????* offer:向阻塞隊列填充元素,當阻塞隊列滿了之后,offer會返回false。
?????*
?????*?@param?o?當任務(wù)被拒絕后,繼續(xù)強制的放入到線程池中
?????*?@return?向阻塞隊列塞任務(wù),當阻塞隊列滿了之后,offer會返回false。
?????*/
????public?boolean?force(Runnable?o)?{
????????if?(parent?==?null?||?parent.isShutdown())?{
????????????throw?new?RejectedExecutionException("taskQueue.notRunning");
????????}
????????return?super.offer(o);
????}

????/**
?????*?帶有阻塞時間的塞任務(wù)
?????*/
????@Deprecated
????public?boolean?force(Runnable?o,?long?timeout,?TimeUnit?unit)?throws?InterruptedException?{
????????if?(parent?==?null?||?parent.isShutdown())?{
????????????throw?new?RejectedExecutionException("taskQueue.notRunning");
????????}
????????return?super.offer(o,?timeout,?unit);?//forces?the?item?onto?the?queue,?to?be?used?if?the?task?is?rejected
????}

????/**
?????*?當線程真正不夠用時,優(yōu)先是開啟線程(直至最大線程),其次才是向隊列填充任務(wù)。
?????*
?????*?@param?runnable?任務(wù)
?????*?@return?false?表示向隊列中添加任務(wù)失敗,
?????*/
????@Override
????public?boolean?offer(Runnable?runnable)?{
????????if?(parent?==?null)?{
????????????return?super.offer(runnable);
????????}
????????//若是達到最大線程數(shù),進隊列。
????????if?(parent.getPoolSize()?==?parent.getMaximumPoolSize())?{
????????????return?super.offer(runnable);
????????}
????????//當前活躍線程為10個,但是只有8個任務(wù)在執(zhí)行,于是,直接進隊列。
????????if?(parent.getSubmittedCount()?<?(parent.getPoolSize()))?{
????????????return?super.offer(runnable);
????????}
????????//當前線程數(shù)小于最大線程數(shù),那么直接返回false,去創(chuàng)建最大線程
????????if?(parent.getPoolSize()?<?parent.getMaximumPoolSize())?{
????????????return?false;
????????}
????????//否則的話,將任務(wù)放入到隊列中
????????return?super.offer(runnable);
????}

????/**
?????*?獲取任務(wù)
?????*/
????@Override
????public?Runnable?poll(long?timeout,?TimeUnit?unit)?throws?InterruptedException?{
????????Runnable?runnable?=?super.poll(timeout,?unit);
????????//取任務(wù)超時,會停止當前線程,來避免內(nèi)存泄露
????????if?(runnable?==?null?&&?parent?!=?null)?{
????????????parent.stopCurrentThreadIfNeeded();
????????}
????????return?runnable;
????}

????/**
?????*?阻塞式的獲取任務(wù),可能返回null。
?????*/
????@Override
????public?Runnable?take()?throws?InterruptedException?{
????????//當前線程應(yīng)當被終止的情況下:
????????if?(parent?!=?null?&&?parent.currentThreadShouldBeStopped())?{
????????????long?keepAliveTime?=?parent.getKeepAliveTime(TimeUnit.MILLISECONDS);
????????????return?poll(keepAliveTime,?TimeUnit.MILLISECONDS);
????????}
????????return?super.take();
????}

????/**
?????*?返回隊列的剩余容量
?????*/
????@Override
????public?int?remainingCapacity()?{
????????if?(forcedRemainingCapacity?>?DEFAULT_FORCED_REMAINING_CAPACITY)?{
????????????return?forcedRemainingCapacity;
????????}
????????return?super.remainingCapacity();
????}


????/**
?????*?強制設(shè)置剩余容量
?????*/
????public?void?setForcedRemainingCapacity(int?forcedRemainingCapacity)?{
????????this.forcedRemainingCapacity?=?forcedRemainingCapacity;
????}

????/**
?????*?重置剩余容量
?????*/
????void?resetForcedRemainingCapacity()?{
????????this.forcedRemainingCapacity?=?DEFAULT_FORCED_REMAINING_CAPACITY;
????}
}?

JDK線程池架構(gòu)圖

springboot 連接數(shù),springboot,spring boot,后端,java,spring

Tomcat線程架構(gòu)

springboot 連接數(shù),springboot,spring boot,后端,java,spring

7測試

如下配置舉例

server:
??port:?8080
??tomcat:
????accept-count:?3
????max-connections:?6
????threads:
??????min-spare:?2
??????max:?3

使用ss -nlt查看全連接隊列容量。

ss?-nltp
ss?-nlt|grep?8080
-?Recv-Q表示(acceptCount)全連接隊列目前長度
-?Send-Q表示(acceptCount)全連接隊列的容量。

靜默狀態(tài)

springboot 連接數(shù),springboot,spring boot,后端,java,spring

6個并發(fā)連接

結(jié)果同上

9個并發(fā)連接

springboot 連接數(shù),springboot,spring boot,后端,java,spring

10個并發(fā)連接

springboot 連接數(shù),springboot,spring boot,后端,java,spring

11個并發(fā)連接

結(jié)果同上

使用ss -nt查看連接狀態(tài)。

ss?-ntp
ss?-nt|grep?8080
-?Recv-Q表示客戶端有多少個字節(jié)發(fā)送但還沒有被服務(wù)端接收
-?Send-Q就表示為有多少個字節(jié)未被客戶端接收。

靜默狀態(tài)

springboot 連接數(shù),springboot,spring boot,后端,java,spring

6個并發(fā)連接

springboot 連接數(shù),springboot,spring boot,后端,java,spring

9個并發(fā)連接

springboot 連接數(shù),springboot,spring boot,后端,java,spring

補充個netstat

springboot 連接數(shù),springboot,spring boot,后端,java,spring

10個并發(fā)連接

結(jié)果同上,隊列中多加了個

11個并發(fā)連接

springboot 連接數(shù),springboot,spring boot,后端,java,spring

超出連接后,會有個連接一直停留在SYN_RECV狀態(tài),不會完成3次握手了。

超出連接后客戶端一直就停留在SYN-SENT狀態(tài),服務(wù)端不會再發(fā)送SYN+ACK,直到客戶端超時(20s內(nèi)核控制)斷開。

客戶端請求超時(需要等待一定時間(20s))。

這里如果客戶端設(shè)置了超時時間,要和服務(wù)端3次握手超時時間對比小的為準。

12個并發(fā)連接

springboot 連接數(shù),springboot,spring boot,后端,java,spring

最后說一句(求關(guān)注!別白嫖!)

如果這篇文章對您有所幫助,或者有所啟發(fā)的話,求一鍵三連:點贊、轉(zhuǎn)發(fā)、在看。

關(guān)注公眾號:woniuxgg,在公眾號中回復(fù):筆記??就可以獲得蝸牛為你精心準備的java實戰(zhàn)語雀筆記,回復(fù)面試、開發(fā)手冊、有超贊的粉絲福利!文章來源地址http://www.zghlxwxcb.cn/news/detail-854856.html

到了這里,關(guān)于SpringBoot 最大連接數(shù)及最大并發(fā)數(shù)是多少?圖解就看到了!的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 題目:一個整數(shù),它加上 100 后是一個完全平方數(shù),再加上 168 又是一個完全平方數(shù),請問該數(shù)是多少?

    題目:一個整數(shù),它加上 100 后是一個完全平方數(shù),再加上 168 又是一個完全平方數(shù),請問該數(shù)是多少? 完全平方指用一個整數(shù)乘以自己例如1×1,2×2,3×3等,依此類推。若一個數(shù)能表示成某個整數(shù)的平方的形式,則稱這個數(shù)為完全平方數(shù)。 完全平方數(shù)是非負數(shù) (下面會說到

    2024年02月04日
    瀏覽(27)
  • 在sql server數(shù)據(jù)庫設(shè)置最大并發(fā)連接數(shù)

    1.查詢所有 SELECT * FROM sysprocesses ? WHERE dbid in( select database_id from sys.databases where name=\\\'ECS_DEV\\\' )order by program_name; 2.查詢連接數(shù) SELECT program_name,COUNT(1) FROM sysprocesses ? WHERE dbid in( select database_id from sys.databases where name=\\\'ECS_DEV\\\' )group by program_name; 3.查詢服務(wù)器運行程序連接數(shù) SELECT count

    2024年02月06日
    瀏覽(83)
  • Linux下解決高并發(fā)socket最大連接數(shù)限制,tcp默認1024個連接

    ?linux獲取TCP連接數(shù) linux作為服務(wù)器系統(tǒng),當socket運行高并發(fā)TCP程序時,通常會出現(xiàn)連接建立到一定個數(shù)后不能再建立連接的情況 本人在工作時,測試高并發(fā)tcp程序(GPS服務(wù)器端程序),多次測試,發(fā)現(xiàn)每次連接建立到1000左右時,再也不能建立tcp連接,最總上網(wǎng)搜索,linux系

    2024年02月12日
    瀏覽(18)
  • 面試官:服務(wù)器最大可以創(chuàng)建多少個tcp連接以及端口并解釋下你對文件句柄的理解

    面試官:服務(wù)器最大可以創(chuàng)建多少個tcp連接以及端口并解釋下你對文件句柄的理解

    轉(zhuǎn)載請注明出處: 服務(wù)器最大可以創(chuàng)建多少個TCP連接取決于多個因素,例如服務(wù)器的硬件配置、網(wǎng)絡(luò)帶寬、操作系統(tǒng)設(shè)置等。 一般來說,現(xiàn)代服務(wù)器的硬件資源和網(wǎng)絡(luò)帶寬都比較充足,因此可以創(chuàng)建大量的TCP連接。然而,服務(wù)器在創(chuàng)建TCP連接時也會有一些限制,例如操作系

    2023年04月12日
    瀏覽(28)
  • Modbus的常見問題解答:多臺設(shè)備如何連接?為什么要加終端電阻?RS485總線可掛接多少個設(shè)備?在RS485通訊中,最大傳輸距離是多少?

    Modbus的常見問題解答:多臺設(shè)備如何連接?為什么要加終端電阻?RS485總線可掛接多少個設(shè)備?在RS485通訊中,最大傳輸距離是多少?

    多臺RS485設(shè)備如何連接呢? 使用屏蔽雙絞線,采用手拉手菊花鏈式拓撲結(jié)構(gòu)將網(wǎng)關(guān)和各串行設(shè)備節(jié)點連接起來,并在網(wǎng)絡(luò)起始端和末尾端設(shè)備的RS485+和RS485-之間各并接一個120Ω電阻以減少信號在兩端的反射。 什么情況下在RS485總線上要增加終端電阻? RS485總線隨著傳輸距離的

    2024年02月10日
    瀏覽(28)
  • 【Spring面試】一、SpringBoot啟動優(yōu)化與最大連接數(shù)

    【Spring面試】一、SpringBoot啟動優(yōu)化與最大連接數(shù)

    調(diào)試: 寫一個測試接口: 服務(wù)配置中的相關(guān)參數(shù): 此時,JMeter模擬100QPS: 成功40個,剛好是 (max-connections)+(accept-count) ,而這兩個參數(shù)的默認值可以在Spring-boot-autoconfigure.jar的配置元數(shù)據(jù)的json文件 spring-configuration-metadata.json 中找到:(當然也可以直接在application.yaml中按

    2024年02月09日
    瀏覽(19)
  • Mysql單表最大記錄是多少

    mysql單表最大記錄數(shù)不能超過多少? 其實mysql本身并沒有對單表最大記錄數(shù)進行限制,這個數(shù)值取決于你的操作系統(tǒng)對單個文件的限制本身。 從性能角度來講,Mysql單表數(shù)據(jù)不要超過多少呢? 業(yè)界流傳是500萬行,超過500萬行就要考慮分庫分表了。 曾經(jīng)在中國互聯(lián)網(wǎng)技術(shù)圈廣為

    2024年02月12日
    瀏覽(16)
  • Linux 最大可以打開多少文件描述符?

    Linux 最大可以打開多少文件描述符?

    在日常開發(fā)中,對文件的操作可謂是再尋常不過的一件事情。那么你是否有這樣一個疑問,我最多可以打開多少個文件呢? 在Linux系統(tǒng)中,當某個程序 打開文件 時,內(nèi)核會返回相應(yīng)的 文件描述符 (fd: file descriptors),也就是所謂的文件句柄,程序為了處理該文件必須引用此描

    2024年02月07日
    瀏覽(20)
  • 運行 100 萬個并發(fā)任務(wù)需要多少內(nèi)存?

    在這篇博文中,我深入研究了 Rust、Go、Java、C#、Python、Node.js 和 Elixir 等流行語言在異步和多線程編程之間的內(nèi)存消耗比較。 前段時間,我不得不比較一些旨在處理大量網(wǎng)絡(luò)連接的計算機程序的性能。我看到這些程序的內(nèi)存消耗存在巨大差異,甚至超過 20 倍。一些程序消耗的

    2024年02月06日
    瀏覽(17)
  • 4核8G服務(wù)器能承受多少并發(fā)?

    4核8G服務(wù)器能承受多少并發(fā)?

    騰訊云4核8G服務(wù)器能承受多少并發(fā)?阿騰云的4核8G服務(wù)器可以支持20個訪客同時訪問,關(guān)于4核8G服務(wù)器承載量并發(fā)數(shù)qps計算測評,云服務(wù)器上運行程序效率不同支持人數(shù)在線人數(shù)不同,公網(wǎng)帶寬也是影響4核8G服務(wù)器并發(fā)數(shù)的一大因素,假設(shè)公網(wǎng)帶寬太小,流量直接卡在入口,

    2024年02月20日
    瀏覽(28)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包