使用C#的Google PubSub“Deadline Exceeded”

时间:2018-05-30 17:52:47

标签: google-cloud-platform google-cloud-pubsub

在识别本地GCP PubSub Publisher客户端的最佳设置时遇到问题。在开始发送数据的几个小时内开始获得“截止日期超过”,其中包含“Stream removed”和“Connect Failed”的变化。

度量标准不是很广泛,从Publisher的GetCurrentFlowState()中记录ByteCount和ElementCount并没有带来太多信息。

到目前为止,设置效果更好(仍然“超出截止日期”):

    private async Task Init()
    {
        _topicName = new TopicName(ProjectId, TopicId);
        var pubApiSets = PublisherServiceApiSettings.GetDefault();
        pubApiSets.PublishSettings = CreateRetryCallSettings(10);
        _pub = await PublisherClient.CreateAsync(
            new TopicName(ProjectId, TopicId),
            settings: new PublisherClient.Settings()
            {
              BatchingSettings = new BatchingSettings(
              elementCountThreshold: 1000, 
              delayThreshold: TimeSpan.FromSeconds(10), 
              byteCountThreshold: 256000)
            },
            clientCreationSettings: new PublisherClient.ClientCreationSettings(

                publisherServiceApiSettings: pubApiSets)
        );
        logger.Trace("client initialized");
    }

    private CallSettings CreateRetryCallSettings(int tryCount)
    {
        var retryBackoff = new BackoffSettings(TimeSpan.FromMilliseconds(500), TimeSpan.FromMilliseconds(5000), 2);
        var timeoutBackoff = new BackoffSettings(TimeSpan.FromMilliseconds(60000), TimeSpan.FromMilliseconds(300000), 1.2);
        return CallSettings.FromCallTiming(CallTiming.FromRetry(new RetrySettings(retryBackoff, timeoutBackoff, Expiration.None,
            (RpcException e) => e.Status.StatusCode != StatusCode.AlreadyExists && --tryCount > 0,
            RetrySettings.RandomJitter)));
    }

有没有建议如何选择最佳设置?
有没有办法为Publisher客户端检索更详细的指标?

0 个答案:

没有答案