一切數據皆可配置:愛奇藝海外站的運營後臺設計實踐

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"愛奇藝海外App是一個"},{"type":"text","marks":[{"type":"strong"}],"text":"重運營"},{"type":"text","text":"的應用。對於App裏的頂導航、我的頁面、彈窗等,需要根據模式、版本、平臺、語言、渠道等不同的維度進行運營管理。隨着業務快速發展,版本快速迭代,如何保持運營資源能夠被高效、穩定和靈活地配置,如何高效穩定的爲新的運營需求提供支持,是我們需要解決的問題。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在這種背景下,愛奇藝海外Phone後端研發組通過打造一個"},{"type":"text","marks":[{"type":"strong"}],"text":"穩定、靈活、高效"},{"type":"text","text":"的運營配置平臺來解決前面遇到的問題。本文主要分享我們在建設高效的運營配置平臺過程中積累的一些經驗以及面臨的"},{"type":"text","marks":[{"type":"strong"}],"text":"挑戰和思考"},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"1.配置資源拆解"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"運營類配置可以分爲兩塊,運營資源和基礎數據的配置。"}]},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/f9\/a2\/f9dd01e9e6526e9a5563df73f100c4a2.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"1.1 運營資源"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"簡單而言,運營資源可以理解爲App中經常變動的一些廣告、運營活動等。比如上圖中彈窗廣告,就是一個典型的運營資源。對於這類運營資源,它們一般有如下特徵:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"時效性強:"},{"type":"text","text":"只在一定時間範圍內顯示在C端固定位置。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"模式強相關:"},{"type":"text","text":"每個活動、廣告都只會出現在固定的某些模式。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"數據變動頻繁:"},{"type":"text","text":"特別是活動類數據,展示的圖片文案等變動較爲頻繁。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"支持多語言展示:"},{"type":"text","text":"基於愛奇藝海外站面向全球用戶的情況,不同模式下需要展示不同的語言文案。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"1.2 基礎數據配置"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"基礎數據配置相對於運營資源來說其變更的頻率相對較低,與時間、版本的關係也沒那麼強。譬如下面愛奇藝海外App-底部導航欄(樣式如上圖所示)。這類配置有如下幾個特徵:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"多維度:"},{"type":"text","text":"需要針對不同的模式、語言做不同的配置。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"長期有效:"},{"type":"text","text":"這種類型的配置一般長期存在,過期場景較少。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"2.實踐中的痛點:運營效率低、重複工作多"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"面對接二連三的運營配置需求,我們最初通過實現不同的配置界面來對接各類運營產品需求。但這必然會遇到很大的問題,這主要體現爲以下方面:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"運營效率低"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於新的運營配置需求,研發同學需要開發對應的配置頁面,然後轉給運營同學進行配置的管理,最後運營人員對資源進行配置上線,其流程圖如下:"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/47\/476d047cca2cfa55fea0f5a89aa62faf.png","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於每個運營配置需求都要經過需求評審、頁面開發、配置管理、上線的流程。同時,對於配置頁面的開發,少則需要1到2天的開發工時,研發成本高。問題總結如下:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1. 研發成本高,每個需求要開發新的配置管理頁面。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2. 研發週期長,運營效率低,從需求的提出到運營上線週期長。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3. 靈活性差,對不同的運營維度(模式、版本、時間等)都需要事先確定好,無法動態調整。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"重複開發工作多"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於通用型的運營配置後臺,某些特有的功能特別對於前後端來說重複開發工作明顯。如操作記錄,審覈機制,根據不同的模式版本語言過濾數據等功能,在每次出現的配置需求中都需要重複的開發。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"3.實踐中的思考:明確三個原則"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"針對以上問題,我們希望通過設計一個通用的解決方案,去解決上文闡述的各種運營資源管理的問題。我們把這個項目稱爲IQ運營位。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通過調研我們確認項目設計的原則主要有以下三個:"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一切數據皆可配置"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"運營數據高可用"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接口性能高效"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通過不斷的實踐和總結,我們希望能從以下三個方面實現上述原則:"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"3.1 數據JSON化"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"隨着業務的不斷迭代,無論採用怎樣的數據字段組成,都很難滿足業務變化的字段(這裏是指像標題、副標題、圖片、跳轉鏈接等)要求。對底層數據進行JSON化,其對應的數據字段即可實現"},{"type":"text","marks":[{"type":"strong"}],"text":"可動態擴展"},{"type":"text","text":",從而滿足業務不斷迭代的需求。JSON化隨之也會帶來運營位字段管理的問題,我們通過在運營後臺提供了相應的字段管理功能來解決這個問題。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"3.2 運營數據多點存儲"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通過持久化存儲,分佈式緩存,以及接入業務方的本地緩存,運營數據的多方存儲,保證極端情況下都有降級數據獲取,降低系統異常的損失。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"3.3 接口SDK化"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於運營數據,無論是通過數據庫的落地方案、還是通過分佈式緩存的方案,都無法徹底解決服務中心化和服務抖動的問題。通過接入的SDK化,可以做到數據的本地緩存更新機制,解除對中心化服務的依賴,大大"},{"type":"text","marks":[{"type":"strong"}],"text":"提升服務的穩定性和性能"},{"type":"text","text":"。同時整個IQ運營位服務變成可水平擴展,在擴展過程中也不會影響中心服務的穩定性。調用方請求流程圖如下:"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/8c\/8cabb2e5760b06a552243ab6d57eff0f.png","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"4.IQ運營位架構"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"IQ運營位配置系統整體框架圖。從功能角度,大體上分爲四層:數據層、服務層、接入層和監控層。IQ運營位架構圖如下:"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/d8\/d8ac651dddc7e50ed37e454a90068ff6.png","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"4.1 數據層"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"數據層主要是存儲接入IQ運營位的各類運營數據。數據層主要面臨以下難點。"},{"type":"text","marks":[{"type":"strong"}],"text":"難點1,數據量大;難點2,QPS高。"},{"type":"text","text":"基於以上兩大難點,我們通過redis集羣做中間緩存,通過SDK使各業務方接入本地緩存、通過消息監聽異步更新的方式來解決中心服務的流量壓力。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"4.2 服務層"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"服務層向下對底層數據進行操作;向上爲接入層獲取數據提供接入能力。其提供四個服務能力:"},{"type":"text","marks":[{"type":"strong"}],"text":"運營後臺、開放平臺、數據服務、IQKIT-SDK"},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其中運營後臺主要面向運營人員和產品,提供數據的配置後臺。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"開放平臺收歸於開發技術人員,提供一個增加運營位配置的後臺。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"數據服務主要是爲調用數據的開發提供一個"},{"type":"text","marks":[{"type":"strong"}],"text":"統一的、高可用的、高性能的api接口"},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"SDK爲數據服務服務。主要目前是簡化開發人員的接入成本,提供數據服務性能和可用性。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"4.3 接入層"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"C端接入如何更方便?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"爲了簡化開發人員的接入成本,調用邏輯在SDK內實現,用戶只需要引入maven包,注入OppkitClient,封裝OppkitRequest,通過OppkitClient直接調用即可返回過濾並且翻譯後的數據。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"B端配置如何更便捷?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在設計項目的時候後臺配置秉持的原則有且只有一個:"},{"type":"text","marks":[{"type":"strong"}],"text":"一切皆可配置"},{"type":"text","text":"。通過開放後臺來配置IQ運營位,每個IQ運營位相當於一個業務形態,比如導航欄,而運營位內包含多個數據,比如title,link等,而title包含多種語言,需要配置多語言key。開放平臺的作用就是創建IQ運營位,爲IQ運營位配置字段。運營後臺則用於配置開放平臺創建的IQ運營位數據。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"4.4 監控層"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"除了數據存儲層的監控以及烽火臺對數據層與服務層的監控外,我們還對SDK內實現的本地緩存進行了監控。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"C端的接入即數據的獲取在SDK內部實現,SDK內部我們做了以下功能:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1. 如果請求包含某些特定離散字段如設備id,因爲包含的數據量極大,存入本地緩存會給業務方的機器內存帶來很大壓力,則避開緩存直接請求服務。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2. 爲了滿足數據實時性要求較高的業務方,新增不接入本地緩存的邏輯。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3. 如果只包含某些聚合度高的字段如平臺字段,版本,模式,語言等,則把請求的數據存入本地緩存。本地緩存通過監聽運營平臺的方式進行異步更新,當異步更新獲取數據失敗,則保持之前的數據返回,避免極端情況運營數據全部爲空,將"},{"type":"text","marks":[{"type":"strong"}],"text":"業務損失降至最低"},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4. SDK內部通過異步線程,將本地緩存的使用情況通過定時線程存入,通過後臺界面展示各緩存使用情況,對各類緩存的使用情況實時監控。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"5.穩定性與性能保障"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如上文所說在運營後臺的設計考慮中,我們秉持了以下幾個原則:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一切數據皆可配置"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"運營數據高可用"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接口性能高效"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下面我們介紹下運營後臺穩定性與性能保障所作出的解決方案。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"整體請求流程圖如下:"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/28\/2857b53f155400f4860ed5f9eb88d2d4.png","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"5.1 穩定性保障"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"作爲各類運營數據配置的運營後臺,"},{"type":"text","marks":[{"type":"strong"}],"text":"穩定性"},{"type":"text","text":"尤爲重要。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"除了在操作機制上即運營流程化數據配置機制、多級數據存儲使用分佈式緩存以及分佈式數據庫以外,我們還提供了一個SDK方案來對服務的故障進行降級。下面我們將詳細介紹該方案的落地過程。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"SDK本地緩存方案"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們考慮到在實現本地緩存,有這樣幾個好處:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1. 緩解中心服務的流量壓力,更多的流量將會請求到本地服務的內存中。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2. 基於愛奇藝海外站業務的特點,國外網絡環境不可預測,環境差等情況,儘可能的減少網絡請求鏈路。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3. 一旦中心服務故障,周知各業務方不要重新部署,以本地緩存實現數據降級。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"但是本地緩存的方案缺點也非常明顯,即一旦有運營後臺數據更新,各業務方無法實時獲取到最新的數據。基於此,我們對SDK進行了以下幾個版本迭代工作。具體見下圖:"}]},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/d8\/c5\/d8fd9c08dee428f6b164f641cbe44dc5.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"技術架構演進到第三版,可以較好的解決中心服務流量問題,使得運營後臺的流量由用戶請求量決定改爲"},{"type":"text","marks":[{"type":"strong"}],"text":"後臺的數據更新頻率"},{"type":"text","text":"決定,從而解決流量過載問題。但是該版實現也需要解決以下幾個難點:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1. 各業務方本地緩存的使用情況種類繁多,如何進行提供系統監控?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":"br"}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2. MQ的方案該如何設計?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"針對問題1,我們在SDK內部實現一套這樣的機制,通過"},{"type":"text","marks":[{"type":"strong"}],"text":"scheduledexecutorservice"},{"type":"text","text":"定時任務,週期性的將緩存使用情況拉取到庫內,這樣在通過後臺界面就可以根據時間展示本地緩存的使用情況。這樣,可以系統的掌握各個不同的業務方緩存的使用情況,供業務方的內存申請和分配提供數據支撐。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/e8\/e8fe5a584186b1d38dca3d792edd2028.png","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"針對問題2,涉及到的難點主要有兩個:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)業務服務機器一般都是一個服務有多臺機器,所以一個消息的更新需要被多臺部署相同代碼的服務器同時消費,這樣"},{"type":"text","marks":[{"type":"strong"}],"text":"確保每臺機器都獲取到最新的數據"},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)運營位有多個,但對於業務方來說沒有必要在沒有接入的運營位更新數據時去異步地請求運營後臺中心服務更新數據(因爲這些數據這個業務方壓根沒接入)。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"針對(1),明確的是消息的生產者是運營後臺服務,而一個消息需要被所有業務方監聽,具體的說是所有業務方的每臺機器。所以,每臺機器應該屬於不同的消費組。所以我們需要找到一個每臺機器都不一樣的"},{"type":"text","marks":[{"type":"strong"}],"text":"標識節點"},{"type":"text","text":",以這個節點做爲消費組。顯然,這個節點最好的就是機器地址,可以保證每臺機器所在分組都不一樣。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"針對(2),我們提供一個配置文件,各業務方需要在配置文件內寫入各自業務方使用的IQ運營位名稱,當一個消息來臨時,首先需要判斷這個消息中的運營位名稱是否包含在配置文件內,如果不在,則這條消息被忽略(空消費),如果在,則請求響應的運營位更新本地數據。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"5.2 性能保障"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"以上的SDK提供的本地緩存可以提高後端服務的性能,除此以外,我們還做了其他一些工作。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在運營位的實踐配置中我們發現,運營數據的變化或者說運營人員更改運營數據的情形相比網絡請求來說是非常低頻的,比如之前分析的基礎運營數據。因此,數據緩存在客戶端可以避免客戶端與後端服務的網絡消耗,極大的提高性能。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們的方案是爲每個運營位數據提供一個版本的概念。通過保存各運營位的操作最新時間,在客戶端開屏時發起一次請求,將所有的運營位最近的數據更新時間返回給客戶端,客戶端將該時間戳緩存在本地,當下次開屏請求時,同樣會獲取到服務端返回的運營位最近更新時間戳,將本地的與服務的進行匹配,來確認是否去更新各個運營位的數據,如果客戶端緩存的運營數據時間與運營後臺返回一致,則直接展示緩存在客戶端的數據。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這種方案的另一個好處是可以在極端的情況下,如對外暴露的api出現故障,通過"},{"type":"text","marks":[{"type":"strong"}],"text":"禁止運營後臺的數據更新,可以使業務數據正常展示,避免出現運營數據消失的嚴重故障"},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"具體的請求流程圖如下:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/2f\/2fc1cf7c87b4f7afc0a23ac63913a826.png","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"6.總結與展望"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本文主要介紹了IQ運營位的設計與開發的相關內容,首先根據遇到的痛點提出了運營後臺的設計原則:一切數據皆可配置,運營數據高可用,接口性能高效。針對提出的原則去思考與實現具體的技術方案。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通過配置數據的Json化實現業務字段的"},{"type":"text","marks":[{"type":"strong"}],"text":"可擴展性"},{"type":"text","text":"。通過設計的數據模型來介紹滿足多語言情況下的各類運營配置數據方法。通過提供SDK內部實現本地緩存,MQ監聽,異步更新的機制解決了服務中心化的大流量問題和緩存導致的數據不一致問題。針對海外的具體情況,提出了客戶端緩存的相關方案。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"IQ運營位從今年5月開始規劃,歷時近半年時間,由於中途穿插了很多的產品需求,所以在自身使用與用戶反饋兩個渠道進行問題收集,前後共經過了兩個版本的迭代。目前在運營後臺的界面與使用便利度上在持續優化。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"IQ運營位上線2個多月以來在愛奇藝海外站得到廣泛使用,在工程效率上更是有質的提高,拿最近的錯誤碼配置來舉例,錯誤碼需要給客戶端返回各類錯誤碼以及對應的相關文案,文案是多語言場景的,通過IQ運營位配置化實現,只需要在分析需求,拆分業務字段和數據露出的條件後,"},{"type":"text","marks":[{"type":"strong"}],"text":"5min以內"},{"type":"text","text":"就可以給出相應的運營後臺。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當然,隨着業務的迭代與場景更新,IQ運營位仍存在一些不完善的地方,在未來我們將會在工程實踐中的持續迭代過程中做更進一步的工作,解決各類問題,更好的服務好IQ運營位的客戶與廣大愛奇藝海外用戶。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"團隊介紹:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"愛奇藝海外phone後端團隊:愛奇藝海外事業部下,負責愛奇藝海外phone後端服務的開發和維護,爲廣大用戶提供穩定、高效、流暢的視頻內容服務。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"正飛:IQ運營位項目負責人,IQ運營位的設計與開發者。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本文轉載自:愛奇藝技術產品團隊(ID:iQIYI-TP)"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"原文鏈接:"},{"type":"link","attrs":{"href":"https:\/\/mp.weixin.qq.com\/s\/ZBk4C4FpHoce6ngA340FfQ","title":"xxx","type":null},"content":[{"type":"text","text":"一切數據皆可配置:愛奇藝海外站的運營後臺設計實踐"}]}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章