我正在使用Spring Cloud Stream gcp pub sub,并且从newrelic收到错误消息
这是来自newrelic的堆栈跟踪
错误消息 java.lang.OutOfMemoryError:无法创建新的本机线程
java.lang.Thread.start0 (Native Method)
java.lang.Thread.start (Thread.java:717)
java.util.concurrent.ThreadPoolExecutor.addWorker (ThreadPoolExecutor.java:957)
java.util.concurrent.ThreadPoolExecutor.execute (ThreadPoolExecutor.java:1378)
io.grpc.internal.DnsNameResolver.resolve (DnsNameResolver.java:252)
io.grpc.internal.DnsNameResolver.refresh (DnsNameResolver.java:162)
…ChannelImpl$LbHelperImpl.handleInternalSubchannelState (ManagedChannelImpl.java:981)
…c.internal.ManagedChannelImpl$LbHelperImpl.access$4700 (ManagedChannelImpl.java:970)
…ternal.ManagedChannelImpl$LbHelperImpl$1.onStateChange (ManagedChannelImpl.java:1018)
io.grpc.internal.InternalSubchannel$2.run (InternalSubchannel.java:320)
io.grpc.internal.ChannelExecutor.drain (ChannelExecutor.java:73)
…InternalSubchannel$TransportListener.transportShutdown (InternalSubchannel.java:582)
…c.netty.ClientTransportLifecycleManager.notifyShutdown (ClientTransportLifecycleManager.java:53)
…etty.shaded.io.grpc.netty.NettyClientHandler.goingAway (NettyClientHandler.java:641)
…tty.shaded.io.grpc.netty.NettyClientHandler.access$200 (NettyClientHandler.java:83)
…ed.io.grpc.netty.NettyClientHandler$2.onGoAwayReceived (NettyClientHandler.java:230)
…dler.codec.http2.DefaultHttp2Connection.goAwayReceived (DefaultHttp2Connection.java:232)
…odec.http2.DefaultHttp2ConnectionDecoder.onGoAwayRead0 (DefaultHttp2ConnectionDecoder.java:166)
…tHttp2ConnectionDecoder$FrameReadListener.onGoAwayRead (DefaultHttp2ConnectionDecoder.java:495)
…ler.codec.http2.Http2InboundFrameLogger$1.onGoAwayRead (Http2InboundFrameLogger.java:119)
…er.codec.http2.DefaultHttp2FrameReader.readGoAwayFrame (DefaultHttp2FrameReader.java:591)
…odec.http2.DefaultHttp2FrameReader.processPayloadState (DefaultHttp2FrameReader.java:272)
….handler.codec.http2.DefaultHttp2FrameReader.readFrame (DefaultHttp2FrameReader.java:160)
….handler.codec.http2.Http2InboundFrameLogger.readFrame (Http2InboundFrameLogger.java:41)
….codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame (DefaultHttp2ConnectionDecoder.java:118)
…codec.http2.Http2ConnectionHandler$FrameDecoder.decode (Http2ConnectionHandler.java:390)
…etty.handler.codec.http2.Http2ConnectionHandler.decode (Http2ConnectionHandler.java:450)
…ec.ByteToMessageDecoder.decodeRemovalReentryProtection (ByteToMessageDecoder.java:489)
…io.netty.handler.codec.ByteToMessageDecoder.callDecode (ByteToMessageDecoder.java:428)
…o.netty.handler.codec.ByteToMessageDecoder.channelRead (ByteToMessageDecoder.java:265)
…hannel.AbstractChannelHandlerContext.invokeChannelRead (AbstractChannelHandlerContext.java:362)
…hannel.AbstractChannelHandlerContext.invokeChannelRead (AbstractChannelHandlerContext.java:348)
….channel.AbstractChannelHandlerContext.fireChannelRead (AbstractChannelHandlerContext.java:340)
…pc.netty.shaded.io.netty.handler.ssl.SslHandler.unwrap (SslHandler.java:1407)
…ed.io.netty.handler.ssl.SslHandler.decodeJdkCompatible (SslHandler.java:1177)
…pc.netty.shaded.io.netty.handler.ssl.SslHandler.decode (SslHandler.java:1221)
…ec.ByteToMessageDecoder.decodeRemovalReentryProtection (ByteToMessageDecoder.java:489)
…io.netty.handler.codec.ByteToMessageDecoder.callDecode (ByteToMessageDecoder.java:428)
…o.netty.handler.codec.ByteToMessageDecoder.channelRead (ByteToMessageDecoder.java:265)
…hannel.AbstractChannelHandlerContext.invokeChannelRead (AbstractChannelHandlerContext.java:362)
…hannel.AbstractChannelHandlerContext.invokeChannelRead (AbstractChannelHandlerContext.java:348)
….channel.AbstractChannelHandlerContext.fireChannelRead (AbstractChannelHandlerContext.java:340)
…channel.DefaultChannelPipeline$HeadContext.channelRead (DefaultChannelPipeline.java:1434)
…hannel.AbstractChannelHandlerContext.invokeChannelRead (AbstractChannelHandlerContext.java:362)
…hannel.AbstractChannelHandlerContext.invokeChannelRead (AbstractChannelHandlerContext.java:348)
…o.netty.channel.DefaultChannelPipeline.fireChannelRead (DefaultChannelPipeline.java:965)
….channel.nio.AbstractNioByteChannel$NioByteUnsafe.read (AbstractNioByteChannel.java:163)
…d.io.netty.channel.nio.NioEventLoop.processSelectedKey (NioEventLoop.java:647)
….channel.nio.NioEventLoop.processSelectedKeysOptimized (NioEventLoop.java:582)
….io.netty.channel.nio.NioEventLoop.processSelectedKeys (NioEventLoop.java:499)
…rpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run (NioEventLoop.java:461)
….netty.util.concurrent.SingleThreadEventExecutor$5.run (SingleThreadEventExecutor.java:884)
…d.io.netty.util.concurrent.FastThreadLocalRunnable.run (FastThreadLocalRunnable.java:30)
java.lang.Thread.run (Thread.java:748)
您会看到 io.grpc ,春季云流通过带有线程池的gRPC协议与Pub / Sub通信。
我用于将数据发布到GCP的编码(Spring Cloud Stream):
source.output().send(new GenericMessage<>(eventSync));
根本原因
我发现了由网络问题引起的问题(应用程序无法按预期方式与gcp pubsub通信,并且等待原因超时,这导致线程池出现瓶颈)。
依赖性
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-pubsub-stream-binder</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
根据docs我没有设置属性spring.cloud.gcp.pubsub.subscriber.executor-threads and spring.cloud.gcp.pubsub.publisher.executor-threads
问题
对于Thread performace,如何在Spring Cloud Stream中处理此问题?
如果我设置spring.cloud.gcp.pubsub.publisher.retry.total-timeout-seconds=5
(默认值为0表示无限制),可能会有所帮助?
如果我设置spring.cloud.gcp.pubsub.publisher.retry.max-attempts=2
(默认值为0表示无限制),可能会有所帮助?
如果我设置spring.cloud.gcp.pubsub.publisher.retry.max-rpc-timeout-second=5
(默认值为0表示无限制),可能会有所帮助?