Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

GCP PubSub : Message Ack Latency has Increased with Java17

I'm running service on GAE to consume the message from GCP Pubsub with below configuration and it takes only ~40ms to ack the messages.
Java8 : 
Spring boot : 2.1.5.RELEASE
GCP Pubsub : 1.82.0

- Total time taken by processing 3 out of 3 messages by 38ms

With Java 17 and the configuration below, we have observed an increase in message acknowledgment latency in GCP PubSub : 
Spring boot : 2.7.9
GCP Pubsub : 1.82.0 or 1.129.0

- Total time taken by ack processing 3 out of 3 messages by 234ms 

The main culprit method is : 

public Boolean deleteMessages(final List<String> ackIds, final PubSubConfig pubSubConfig) throws Exception {

final SubscriberStubSettings subscriberStubSettings =
SubscriberStubSettings.newBuilder()
.setTransportChannelProvider(
SubscriberStubSettings
.defaultGrpcTransportProviderBuilder()
.setMaxInboundMessageSize(20 << 20) // 20MB
.build()
).build();

try (SubscriberStub subscriber = GrpcSubscriberStub.create(subscriberStubSettings)) {
final String subscriptionName = ProjectSubscriptionName.format(pubSubConfig.getProjectId(), pubSubConfig.getSubscriptionId());

if (!ackIds.isEmpty()) {

// acknowledge received messages
final AcknowledgeRequest acknowledgeRequest =
AcknowledgeRequest.newBuilder()
.setSubscription(subscriptionName)
.addAllAckIds(ackIds)
.build();

subscriber.acknowledgeCallable().call(acknowledgeRequest);

}
return true;
}
}

1 2 643
2 REPLIES 2