title: Facing issue "WebClientRequestException: Pending acquire queue has reached its maximum size of 1000" with spring reactive webClient
body: <p>I am running load of a microservice API, which involves calling other microservice API using Spring Reactive Webclient. I am using Postman runner tab to test this.</p>
  <p>Firstly, i run the load with 1500 iteration, second microservice is getting called for each request and everything is working fine as expected.
  But when i run the load with 5000 iteration, second microservice is getting called for for 3500 times and 1500 calls are failing due to issue</p>
  <blockquote>
  <p>WebClientRequestException: Pending acquire queue has reached its maximum size of 1000</p>
  </blockquote>
  <p>Using org.springframework.web.reactive.function.client.WebClient with default configuration, below is the code snippet.</p>
  <pre><code> private WebClient webClient;
  
      @PostConstruct
      public void init() {
          this.webClient = WebClient.builder().defaultHeader(HttpHeaders.CONTENT_TYPE,  MediaType.APPLICATION_JSON_VALUE)
                  .build();
      }
  </code></pre>
  <p>what can be done to avoid this?</p>
  <p>I am using latest spring-boot-starter-parent dependency (with version 2.5.3) with spring-webflux-5.3.9.jar jar.</p>
  <p>the logs:</p>
  <pre><code>reactor.core.Exceptions$ErrorCallbackNotImplemented: reactor.core.Exceptions$RetryExhaustedException: Retries exhausted: 3/3
  Caused by: reactor.core.Exceptions$RetryExhaustedException: Retries exhausted: 3/3
          at reactor.core.Exceptions.retryExhausted(Exceptions.java:290)
          at reactor.util.retry.RetryBackoffSpec.lambda$static$0(RetryBackoffSpec.java:67)
          at reactor.util.retry.RetryBackoffSpec.lambda$generateCompanion$4(RetryBackoffSpec.java:557)
          at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:375)
          at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerComplete(FluxConcatMap.java:296)
          at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onComplete(FluxConcatMap.java:885)
          at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1817)
          at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:249)
          at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.complete(MonoIgnoreThen.java:284)
          at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onNext(MonoIgnoreThen.java:187)
          at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:232)
          at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
          at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
          at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.complete(MonoIgnoreThen.java:284)
          at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onNext(MonoIgnoreThen.java:187)
          at reactor.core.publisher.MonoDelay$MonoDelayRunnable.propagateDelay(MonoDelay.java:271)
          at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:286)
          at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
          at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          at java.base/java.lang.Thread.run(Thread.java:829)
  
  **Caused by: org.springframework.web.reactive.function.client.WebClientRequestException: Pending acquire queue has reached its maximum size of 1000; nested exception is reactor.netty.internal.shaded.reactor.pool.PoolAcquirePendingLimitException: Pending acquire queue has reached its maximum size of 1000**
          at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.lambda$wrapException$9(ExchangeFunctions.java:141)
          Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
  Error has been observed at the following site(s):
          |_ checkpoint ⇢ Request to POST http://172.20.0.2:3130/v1/login/mobile [DefaultWebClient]
  Stack trace:
                  at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.lambda$wrapException$9(ExchangeFunctions.java:141)
                  at reactor.core.publisher.MonoErrorSupplied.subscribe(MonoErrorSupplied.java:55)
                  at reactor.core.publisher.Mono.subscribe(Mono.java:4338)
                  at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
                  at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:222)
                  at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:222)
                  at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:222)
                  at reactor.core.publisher.MonoNext$NextSubscriber.onError(MonoNext.java:93)
                  at reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onError(MonoFlatMapMany.java:204)
                  at reactor.core.publisher.SerializedSubscriber.onError(SerializedSubscriber.java:124)
                  at reactor.core.publisher.FluxRetryWhen$RetryWhenMainSubscriber.whenError(FluxRetryWhen.java:225)
                  at reactor.core.publisher.FluxRetryWhen$RetryWhenOtherSubscriber.onError(FluxRetryWhen.java:274)
                  at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:414)
                  at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onNext(FluxConcatMap.java:251)
                  at reactor.core.publisher.EmitterProcessor.drain(EmitterProcessor.java:491)
  at reactor.core.publisher.EmitterProcessor.tryEmitNext(EmitterProcessor.java:299)
                  at reactor.core.publisher.SinkManySerialized.tryEmitNext(SinkManySerialized.java:100)
                  at reactor.core.publisher.InternalManySink.emitNext(InternalManySink.java:27)
                  at reactor.core.publisher.FluxRetryWhen$RetryWhenMainSubscriber.onError(FluxRetryWhen.java:190)
                  at reactor.core.publisher.MonoCreate$DefaultMonoSink.error(MonoCreate.java:189)
                  at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect$ClientTransportSubscriber.onError(HttpClientConnect.java:304)
                  at reactor.core.publisher.MonoCreate$DefaultMonoSink.error(MonoCreate.java:189)
                  at reactor.netty.resources.DefaultPooledConnectionProvider$DisposableAcquire.onError(DefaultPooledConnectionProvider.java:172)
                  at reactor.netty.internal.shaded.reactor.pool.AbstractPool$Borrower.fail(AbstractPool.java:444)
                  at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool.pendingOffer(SimpleDequePool.java:543)
                  at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool.doAcquire(SimpleDequePool.java:266)
                  at reactor.netty.internal.shaded.reactor.pool.AbstractPool$Borrower.request(AbstractPool.java:399)
                  at reactor.netty.resources.DefaultPooledConnectionProvider$DisposableAcquire.onSubscribe(DefaultPooledConnectionProvider.java:212)
                  at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool$QueueBorrowerMono.subscribe(SimpleDequePool.java:674)
                  at reactor.netty.resources.PooledConnectionProvider.lambda$acquire$1(PooledConnectionProvider.java:137)
                  at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
                  at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:268)
                  at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
                  at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:77)
                  at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46)
                  at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57)
                  at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:271)
                  at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
                  at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
                  at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
                  at reactor.core.publisher.FluxRetryWhen$RetryWhenMainSubscriber.resubscribe(FluxRetryWhen.java:216)
                  at reactor.core.publisher.FluxRetryWhen$RetryWhenOtherSubscriber.onNext(FluxRetryWhen.java:269)
                  at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:282)
                  at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:861)
                  at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
                  at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:249)
                  at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.complete(MonoIgnoreThen.java:284)
                  at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onNext(MonoIgnoreThen.java:187)
                  at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:232)
                  at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
                  at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
                  at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.complete(MonoIgnoreThen.java:284)
                  at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onNext(MonoIgnoreThen.java:187)
                  at reactor.core.publisher.MonoDelay$MonoDelayRunnable.propagateDelay(MonoDelay.java:271)
                  at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:286)
                  at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
                  at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
                  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
                  at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
                  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
                  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
                  at java.base/java.lang.Thread.run(Thread.java:829)
  **Caused by: reactor.netty.internal.shaded.reactor.pool.PoolAcquirePendingLimitException: Pending acquire queue has reached its maximum size of 1000
          at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool.pendingOffer(SimpleDequePool.java:543)**
          at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool.doAcquire(SimpleDequePool.java:266)
          at reactor.netty.internal.shaded.reactor.pool.AbstractPool$Borrower.request(AbstractPool.java:399)
          at reactor.netty.resources.DefaultPooledConnectionProvider$DisposableAcquire.onSubscribe(DefaultPooledConnectionProvider.java:212)
          at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool$QueueBorrowerMono.subscribe(SimpleDequePool.java:674)
          at reactor.netty.resources.PooledConnectionProvider.lambda$acquire$1(PooledConnectionProvider.java:137)
          at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
          at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:268)
          at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
          at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:77)
          at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46)
  </code></pre>