首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么内部通信的通信时间(速度)比以前慢了一点?

为什么内部通信的通信时间(速度)比以前慢了一点?
EN

Stack Overflow用户
提问于 2019-08-09 14:21:05
回答 1查看 139关注 0票数 0

我在GKE上申请了。我有一个关于pods之间的连接的问题。所构建的应用程序是在集群上使用service_type LoadBalancer实现的,它利用internet进行连接。

此时,我决定使用service_type clusterIP来包含一个不应该暴露在互联网上的pod。在一次测试中,连接到此pod大约需要5.4毫秒,但将此pod暴露到Internet时,这一时间约为4.3毫秒。

也就是说,当使用LoadBalancer类型时比使用ClusterIP类型要好。

在我看来,这些结果是相反的。我认为ClusterIP服务只使用内部网络,而LoadBalancer服务通过互联网。

这个结果是真的吗?或者在测试的方式上有任何错误?

如果这是真的,为什么会发生这种情况?

代码语言:javascript
复制
import logging, requests
import statistics
import time
from flask import Flask, jsonify

app = Flask(__name__)


#clusterIPを指定した応答時間の測定
@app.route('/req_cluster')
def req_cluster():
    try:
        #応答時間を測定(100リクエスト分)
        response_time_list = []
        for i in range(100):
            start = time.time()
            res = requests.get("http://10.0.7.70:8080/prease_get")
            end = time.time()
            print(start - end)
            response_time_list.append(float(start - end))

        #合計値を格納
        execution_hours_sum = sum(response_time_list)
        #中央値を格納
        median = statistics.median(response_time_list)
        #平均値を格納
        mean = statistics.mean(response_time_list)

        #出力フォーマットの指定
        print("clusterIPを指定した応答時間の測定\n\n最終(100回目)のステータスコード:{}\n応答時間の合計値:{}\n応答時間の中央値:{}\n応答時間の平均値:{}".format(jsonify(res.status_code), execution_hours_sum, median, mean))
        result = "clusterIPを指定した応答時間の測定\n\n最終(100回目)のステータスコード:{}\n応答時間の合計値:{}\n応答時間の中央値:{}\n応答時間の平均値:{}".format(jsonify(res.status_code), execution_hours_sum, median, mean)

    except Exception as err:
        logging.error(err.args) 

    return result

#LoadBalancerを指定した応答時間の測定
@app.route('/req_loadbalancer')
def req_loadbalancer():
    try:
        #応答時間を測定(100リクエスト分)
        response_time_list = []
        for i in range(100):
            start = time.time()
            res =  requests.get("http://34.85.40.229:8080/prease_get") 
            end = time.time()
            print(start - end)
            response_time_list.append(float(start - end))

        #合計値を格納
        execution_hours_sum = sum(response_time_list)
        #中央値を格納
        median = statistics.median(response_time_list)
        #平均値を格納
        mean = statistics.mean(response_time_list)

        #出力フォーマットの指定
        print("LoadBalancerを指定した応答時間の測定\n\n最終(100回目)のステータスコード:{}\n応答時間の合計値:{}\n応答時間の中央値:{}\n応答時間の平均値:{}".format(jsonify(res.status_code), execution_hours_sum, median, mean))
        result = "LoadBalancerを指定した応答時間の測定\n\n最終(100回目)のステータスコード:{}\n応答時間の合計値:{}\n応答時間の中央値:{}\n応答時間の平均値:{}".format(jsonify(res.status_code), execution_hours_sum, median, mean)

    except Exception as err:
        logging.error(err.args) 

    return result

if __name__ == '__main__':
   app.run()
   logging.info('fugafuga')
   logging.warning('hogehoge')

当访问100次时,集群IP期望比负载均衡器更快的结果。

enter image description here

参考图片如下。service_type: ClusterIP == PodB service_type: LoadBalancer == PodC

EN

回答 1

Stack Overflow用户

发布于 2019-08-13 06:25:04

可能有以下几种情况:

resources

  • Your测试您的pod是否具有相同的pod内容可能缓存在Google Cloud CDN

  • Your上
  • 可能会使您的pod资源不堪重负,而负载均衡器可能已经“平衡”了您的测试

从一个容器到另一个pod容器的ICMP测试得到多少个"ms“?

你有没有试过使用内部负载均衡器来看看它是如何进行的?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57424416

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档