影響系統性能的20個瓶頸

 

在   Zen And The Art Of Scaling - A Koan And Epigram Approach 一文中  Russell Sullivan 提出一個很有趣的設想:一共有20種經典的瓶頸。這聽起來就像只有20種基本的故事情節(20 basic story plots那樣讓人懷疑。不過基於每個人不同的分類方式,這個說法或許是對的,但是在現實中,衆所周知,瓶頸是無窮無盡的而且涉及方方面面。

 

·         數據庫:

·         工作中數據大小超過可用內存 RAM

·         長短查詢混合

·         -寫 衝突

·         大的聯合查詢佔光內存

·         虛擬化:

·         共享 HDD 存儲,磁盤尋道掛起

·         雲平臺中的網絡 I/O 波動

 

編程:

·         線程:死鎖、相對於事件驅動來說過於重量級、調試、線程數與性能比非線性

·         事件驅動編程:回調的複雜性、函數調用中如何保存狀態(how-to-store-state-in-function-calls

·         缺少profile工具、缺少trace工具、缺少日誌工具

·         單點故障、橫向不可擴展

·         有狀態的應用

·         搓設計:一臺機器上能跑,幾個用戶也能跑,幾個月後,幾年後,尼瑪,發現扛不住了,整個架構需要重寫。

·         算法複雜度

·         依賴於諸如DNS查找等比較搞人的外部組件

·         棧空間

 

·         磁盤:

·         本地磁盤存取

·         隨機磁盤讀寫 -> 磁盤尋道

·         磁盤碎片化

·         寫入超過SSD容量的數據導致SSD硬盤性能降低

·         操作系統:

·         內核緩衝刷入磁盤,填充linux緩衝區緩存

·         TCP緩衝區過小

·         文件描述符限制

·         功率分配

緩存:

·         不使用memcached

·         HTTP中,headeretags,不壓縮(headers, etags, not gzipping

·         沒有充分使用瀏覽器緩存功能

·         字節碼緩存(如PHP

·         L1/L2緩存. 這是個很大的瓶頸. 把頻繁使用的數據保持在L1/L2. 設計到的方面很多:網絡數據壓縮後再發送,基於列壓縮的DB中不解壓直接計算等等。有TLB友好的算法。最重要的是牢固掌握以下基礎知識:多核CPUL1/L2,共享L3NUMA內存,CPU、內存之間的數據傳輸帶寬延遲,磁盤頁緩存,髒頁,TCPCPUDRAM到網卡的流程。

 

CPU:

·         CPU 過載

·         上下文切換 -> 一個內核上跑了太多的線程,linux調度對於應用來說很不友好, 太多的系統調用, 等等...

·         IO 等待 -> 所有的CPU都掛起等待比較慢的IO

·         CPU 緩存: 緩存數據是一個爲了平衡不同實例有不同的值和繁重的同步緩存數據保持一致,而精心設計的一個進程。

·         背板吞吐量

 

網絡:

·         網卡的最大輸出帶寬,IRQ達到飽和狀態,軟件中斷佔用了100%CPU

·         DNS查找

·         丟包

·         網絡路由瞎指揮

·         網絡磁盤訪問

·         共享SANStorage Area Network)

·         服務器失敗 -> 服務器無響應

 

過程:

·         測試時間 Testing time

·         開發時間 Development time

·         團隊人數 Team size

·         預算 Budget

·         代碼缺陷 Code debt

 

內存:

·         內存溢出 -> 殺進程,進入 swap ,越來越慢

·         內存溢出導致磁盤頻繁讀寫(swap相關)

·         內存庫開銷

·         內存碎片

·         Java 需要垃圾收集導致程序暫停

·         C 語言的 malloc 無法分配

 

IDEAS, PLOTS & USING THE PREMISE SHEETS



After you come up with your own system for generating ideas, the next step is to put them in some recognizable story form (the basic plot idea), build your central conflict (the story premise sheet), then build your character and underlying themes (the thematic premise sheet. 

#1 QUEST - the plot involves the Protagonist's search for a person, place or thing, tangible or intangible (but must be quantifiable, so think of this as a noun; i.e., immortality). 

#2 ADVENTURE - this plot involves the Protagonist going in search of their fortune, and since fortune is never found at home, the Protagonist goes to search for it somewhere over the rainbow. 

#3 PURSUIT - this plot literally involves hide-and-seek, one person chasing another. 

#4 RESCUE - this plot involves the Protagonist searching for someone or something, usually consisting of three main characters - the Protagonist, the Victim & the Antagonist. 

#5 ESCAPE - plot involves a Protagonist confined against their will who wants to escape (does not include some one trying to escape their personal demons). 

#6 REVENGE - retaliation by Protagonist or Antagonist against the other for real or imagined injury. 

#7 THE RIDDLE - plot involves the Protagonist's search for clues to find the hidden meaning of something in question that is deliberately enigmatic or ambiguous. 

#8 RIVALRY - plot involves Protagonist competing for same object or goal as another person (their rival). 

#9 UNDERDOG - plot involves a Protagonist competing for an object or goal that is at a great disadvantage and is faced with overwhelming odds. 

#10 TEMPTATION - plot involves a Protagonist that for one reason or another is induced or persuaded to do something that is unwise, wrong or immoral. 

#11 METAMORPHOSIS - this plot involves the physical characteristics of the Protagonist actually changing from one form to another (reflecting their inner psychological identity). 

#12 TRANSFORMATION - plot involves the process of change in the Protagonist as they journey through a stage of life that moves them from one significant character state to another. 

#13 MATURATION - plot involves the Protagonist facing a problem that is part of growing up, and from dealing with it, emerging into a state of adulthood (going from innocence to experience). 

#14 LOVE - plot involves the Protagonist overcoming the obstacles to love that keeps them from consummating (engaging in) true love. 

#15 FORBIDDEN LOVE - plot involves Protagonist(s) overcoming obstacles created by social mores and taboos to consummate their relationship (and sometimes finding it at too high a price to live with). 

#16 SACRIFICE - plot involves the Protagonist taking action(s) that is motivated by a higher purpose (concept) such as love, honor, charity or for the sake of humanity. 

#17 DISCOVERY - plot that is the most character-centered of all, involves the Protagonist having to overcome an upheavel(s) in their life, and thereby discovering something important (and buried) within them a better understanding of life (i.e., better appreciation of their life, a clearer purpose in their life, etc.) 

#18 WRETCHED EXCESS - plot involves a Protagonist who, either by choice or by accident, pushes the limits of acceptable behavior to the extreme and is forced to deal with the consequences (generally deals with the psychological decline of the character). 

#19 ASCENSION - rags-to-riches plot deals with the rise (success) of Protagonist due to a dominating character trait that helps them to succeed. 

#20 DECISION - riches-to-rags plot deals with the fall (destruction) of Protagonist due to dominating character trait that eventually destroys their success. 

(Note: Sometimes #19 & #20 are combined into rags-to-riches-to-rags (or vice versa) of a Protagonist who does (or doesn't) learn to deal with their dominating character trait.) 

For an in-depth look at these plots, read the excellent "20 Master Plots and How To Build Them" by Ronald B. Tobias available through the TSA Writers Store.

 

非原創,轉自互聯網。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章