瀏覽代碼

add MAX_FREQ_FROM_FLOW_POOL_18_19: 3

liqian 2 年之前
父節點
當前提交
c949228c22
共有 2 個文件被更改,包括 12 次插入3 次删除
  1. 2 0
      config.py
  2. 10 3
      video_recall.py

+ 2 - 0
config.py

@@ -278,6 +278,8 @@ class BaseConfig(object):
     MAX_FREQ_FROM_ROV_POOL = 3
     # 从流量池获取视频的最大频次,限制每次请求的获取次数
     MAX_FREQ_FROM_FLOW_POOL = 0
+    # 从流量池获取视频的最大频次,限制每次请求的获取次数 appType:[18, 19]
+    MAX_FREQ_FROM_FLOW_POOL_18_19 = 3
 
 
     # 兜底视频redis存储key

+ 10 - 3
video_recall.py

@@ -928,7 +928,7 @@ class PoolRecall(object):
 
     def flow_pool_recall_18_19(self, size=4, push_from=config_.PUSH_FROM['flow_recall']):
         """从流量池中获取视频"""
-        # log_.info('====== flow pool recall')
+        start_time = time.time()
         flow_pool_key = self.get_pool_redis_key('flow')
         flow_pool_recall_result = []
         flow_pool_recall_videos = []
@@ -939,12 +939,13 @@ class PoolRecall(object):
         idx = 0
         while len(flow_pool_recall_result) < size:
             freq += 1
+            if freq > config_.MAX_FREQ_FROM_FLOW_POOL_18_19:
+                break
+
             # 获取数据
-            st_get = time.time()
             data = self.redis_helper.get_data_zset_with_index(key_name=flow_pool_key,
                                                               start=idx, end=idx + get_size - 1,
                                                               with_scores=True)
-            et_get = time.time()
             # log_.info('get data from flow pool redis: freq = {}, data = {}, execute time = {}ms'.format(
             #     freq, data, (et_get - st_get) * 1000))
             if not data:
@@ -973,6 +974,12 @@ class PoolRecall(object):
                 flow_pool_recall_result.extend(temp_result)
             idx += get_size
 
+        log_.info({
+            'logTimestamp': int(time.time() * 1000),
+            'request_id': self.request_id,
+            'operation': 'flow_pool_recall_18_19',
+            'executeTime': (time.time() - start_time) * 1000
+        })
         return flow_pool_recall_result[:size]
 
     def get_pool_redis_key_with_day(self, pool_type):