《電子技術(shù)應(yīng)用》
您所在的位置:首頁 > 其他 > 設(shè)計(jì)應(yīng)用 > 基于內(nèi)存映射文件的高性能庫存緩存系統(tǒng)
基于內(nèi)存映射文件的高性能庫存緩存系統(tǒng)
2020年電子技術(shù)應(yīng)用第7期
黃向平1,2,彭明田1,2,楊永凱1,2
1.中國民航信息網(wǎng)絡(luò)股份有限公司,北京101318;2.民航旅客服務(wù)智能化應(yīng)用技術(shù)重點(diǎn)實(shí)驗(yàn)室,北京101318
摘要: 傳統(tǒng)余票庫存查詢系統(tǒng)以內(nèi)存數(shù)據(jù)庫或嵌入式數(shù)據(jù)庫作為緩存系統(tǒng),在高并發(fā)與密集計(jì)算環(huán)境中,讀取性能很難滿足需求。設(shè)計(jì)一種高性能庫存緩存系統(tǒng),利用內(nèi)存映射文件技術(shù),消除進(jìn)程間通信消耗,減少數(shù)據(jù)拷貝,避免讀寫操作互鎖,從而大幅提高緩存讀取性能。實(shí)驗(yàn)表明,該方法在并發(fā)讀取效率上提升了兩個(gè)數(shù)量級(jí)以上。
中圖分類號(hào): TP311.132
文獻(xiàn)標(biāo)識(shí)碼: A
DOI:10.16157/j.issn.0258-7998.191043
中文引用格式: 黃向平,彭明田,楊永凱. 基于內(nèi)存映射文件的高性能庫存緩存系統(tǒng)[J].電子技術(shù)應(yīng)用,2020,46(7):113-117,126.
英文引用格式: Huang Xiangping,Peng Mingtian,Yang Yongkai. High performance inventory caching system based on memory mapping files[J]. Application of Electronic Technique,2020,46(7):113-117,126.
High performance inventory caching system based on memory mapping files
Huang Xiangping1,2,Peng Mingtian1,2,Yang Yongkai1,2
1.TravelSky Technology Limited,Beijing 101318,China; 2.Key Laboratory of Intelligent Passenger Service of Civil Aviation,Beijing 101318,China
Abstract: Traditional balance inventory query system uses memory database or embedded database as cache system. In high concurrent and intensive computing environment, the reading performance is difficult to meet the demand. A high-performance inventory caching system is designed, which uses memory mapping file technology to eliminate communication consumption between processes, reduce data copy and avoid interlocking between read and write operations, thus greatly improving the cache reading performance. Experiments show that this method improves the concurrent reading efficiency by more than two orders of magnitude.
Key words : inventory query;memory database;embedded database;memory mapping files;high performance caching system

0 引言

    近年來,移動(dòng)互聯(lián)網(wǎng)[1]應(yīng)用急劇擴(kuò)大,作為一種典型的移動(dòng)互聯(lián)網(wǎng)電子商務(wù)應(yīng)用,票務(wù)查詢系統(tǒng)[2]向用戶隨時(shí)隨地提供余票庫存信息,幫助移動(dòng)用戶做交通住宿規(guī)劃、影院演出門票預(yù)定等操作。12306鐵路票務(wù)系統(tǒng)[3]是一個(gè)典型的高并發(fā)應(yīng)用,余票查詢高峰值超過了百億次/天。如此高的負(fù)載與高并發(fā)量會(huì)使應(yīng)用服務(wù)訪問擁堵,容易出現(xiàn)查詢結(jié)果不穩(wěn)定等異?,F(xiàn)象。航空票務(wù)搜索[4]也同樣面臨相似的問題,中轉(zhuǎn)點(diǎn)選擇豐富,可搭配的航班多,單次搜索需要成千上萬次的航班座位庫存信息查詢。能夠及時(shí)準(zhǔn)確地獲取盡量多航班座位庫存數(shù)據(jù),是搜索出經(jīng)濟(jì)快捷的航班集合的關(guān)鍵所在。

    在此類實(shí)時(shí)響應(yīng)度要求比較高且性能要求比較高的查詢系統(tǒng)中,key-value結(jié)構(gòu)的NoSQL數(shù)據(jù)庫[5]作為緩存系統(tǒng)[6]得到了廣發(fā)的應(yīng)用。典型的NoSQL數(shù)據(jù)庫有內(nèi)存數(shù)據(jù)庫memcached/redis[7]嵌入式數(shù)據(jù)庫Berkeley DB[8]。在進(jìn)一步性能分析之后發(fā)現(xiàn),這些數(shù)據(jù)訪問方式仍存在性能瓶頸,并發(fā)訪問量大時(shí)依然會(huì)出現(xiàn)排隊(duì)延遲的現(xiàn)象。鑒于此,本文提出了一種基于內(nèi)存映射文件[9]的高性能庫存緩存系統(tǒng),主要從三方面進(jìn)行改進(jìn):(1)通過內(nèi)存映射文件,緩存系統(tǒng)與應(yīng)用進(jìn)程同處一個(gè)進(jìn)程空間,避免進(jìn)程間通信,從而提高數(shù)據(jù)讀取效率;(2)緩存結(jié)果以指針方式返回,節(jié)省了內(nèi)存拷貝,從而減少內(nèi)存和CPU資源消耗;(3)數(shù)據(jù)讀寫過程采用無鎖設(shè)計(jì),多進(jìn)程或多線程無需爭搶排隊(duì)訪問,從而提高訪問并發(fā)效率。




本文詳細(xì)內(nèi)容請(qǐng)下載:http://ihrv.cn/resource/share/2000002915




作者信息:

黃向平1,2,彭明田1,2,楊永凱1,2

(1.中國民航信息網(wǎng)絡(luò)股份有限公司,北京101318;2.民航旅客服務(wù)智能化應(yīng)用技術(shù)重點(diǎn)實(shí)驗(yàn)室,北京101318)

此內(nèi)容為AET網(wǎng)站原創(chuàng),未經(jīng)授權(quán)禁止轉(zhuǎn)載。