i'm running application which consists of Google Cloud Functions, triggered by PubSub Topics, so basically theu're communicating to each other via Google PubSub.
The problem is, it can struggle sometimes and show delays when publishing message up to 9s or more. I checked the Metrics Explorer and found out that when high delays it shows errors like:
- unreachable_5xx_error_500
- unreachable_no_response
- internal_rejected_error
- unreachable_5xx_error_503
- url_4xx_error_429
Code example of publishing message inside Google Cloud Function:
const {PubSub} = require('@google-cloud/pubsub');
const pubSubClient = new PubSub();
async function publishMessage() {
const topicName = 'my-topic';
const dataBuffer = Buffer.from(data);
const messageId = await pubSubClient.topic(topicName).publish(dataBuffer);
console.log(`Message ${messageId} published.`);
}
publishMessage().catch(console.error);
Code example of function triggered by PubSub Topic:
exports.subscribe = async (message) => {
const name = message.data
? Buffer.from(message.data, 'base64').toString()
: 'World';
console.log(`Hello, ${name}!`);
}
And i think this errors causing delays. I didn't find anything on this on the internet, so i hope you can explain what causing this errors and why and probably can help with this.