SlideShare uma empresa Scribd logo
1 de 36
App創業與實作
本授權條款允許使用者重製、散布、傳輸著作,但不得為商業目的之使用,亦不得修改該著作。
使用時必須按照著作人指定的方式表彰其姓名。
App Entrepreneurship and implementation
Week 15
軟體效能分析與安全性議題
黃敬群 Jim Huang
(聯發科技顧問)
(2013-05-30)
姓名標示─非商業性─禁止改作
本授權條款允許使用者重製、散布、傳輸著作,但不得為商
業目的之使用,亦不得修改該著作。使用時必須按照著作人
指定的方式表彰其姓名。
CC (Creative Commons)
淺談系統效能與安全議題
Jim Huang ( 黃敬群 ) <jserv@0xlab.org>
May 30, 2013 / NTHU, Taiwan
About me
• 台灣創新行動服務推廣協會 / 理事長
• 成功大學資訊工程系 / 兼任教師
• 聯發科技 / 顧問
• 杏昕科技 / 技術長
• 晶心科技 / 幕僚工程師
• 開放原始碼開發
– 新酷音輸入法 , GCC / GNU Classpath, LXDE,
Android Open Source Project
• Others: http://about.me/jserv
About this presentation
• 我不是專家,只是碼農
• 今天不是以經營者的觀點去解讀,而以 * 低層次 *
工程師的角度去分享
Think of the possibility
萬一你的期末計畫或者玩票性質的
App 獲得上萬次下載,接著會如何?
Think of the possibility
source: http://www.cw.com.tw/article/article.action?id=5033139
部落客化身食譜網站創辦人,平均年齡三十的大男生,如何改寫日本
最大食譜網站的成功模式,六個月攻陷萬名粉絲?
三千多道菜,每天有二十多道新菜色上線。每個月有近三百萬瀏覽
量,熱烈討論哪道人氣菜色怎麼煮,食材可以在哪裡買。
這是上線才半年,食譜分享社群網站「 iCook 愛料理」的成績。
The traffic
3M visit per month;
10K members
in 6 month
The impact
• operation cost
– 當瀏覽次數從每月 3K 到每月 3M ,成本即以指
數性成長
• membership variance
– 當會員數量超過 1K 時,很可能面臨質變,考驗
經營者的智慧
• performance impact
– 原本的雛型設計勢必得改寫,無論是 web 前端
、後端、資料庫,抑或整體的運作模型
• security issue
– 樹大招風
The key point
“Scalable”
Agenda (1) Concepts about Scaling
(2) Performance
Concepts about Scaling
Scaling
• 以 web 為例,有以下考量點
– web server
– database
– caching
one server
load
balanced
Database Scaling
Everyone starts with just one server:
Multiple steps to take as you move forward
Step 1: Master/Slave
Step 1: Master/Slave - Preparation
Even with one server:
Make code write to master and read from slave
Don't write code that would fail with slave lag:
$master->query('update users set comments += 1');
$slave->query('select comments from users');
Step 2: Multiple Slaves
One slave per server?
Not as flexible
Better solution: Random
Code to select Random Slave
class DB {
private static $cfg = array(
'write' =>
array('mysql:dbname=MyDB;host=10.1.2.3'),
'read' =>
array('mysql:dbname=MyDB;host=10.1.2.7',
'mysql:dbname=MyDB;host=10.1.2.8',
'mysql:dbname=MyDB;host=10.1.2.9');
);
public static function getConnection($pool) {
$max = count(self::$cfg[$pool]) - 1;
$dsn = self::$cfg[$pool][mt_rand(0, $max)];
return new PDO($dsn, USER, PASS);
}
}
$db = DB::getConnection('read');
Step 3: Slave Pool
Virtually divide your slaves into pools
Use this to isolation high database load
Potentially enhance query caches
Possible Pool Layout
Step 4: Partitioning
Simplest Definition:
Break your tables or databases into smaller ones
Cost of Partitioning
• Loss of direct SQL support
• Increased Web Server / Application Load
• More complicated programming
Caching in Brief
• Often considered performance
• Can absolutely be a scalability factor, especially
when combined with smaller discrete DB queries
• Allows you to get around DB scalability by
ignoring the DB
Type of Caching
• Single server memory caches
– For PHP: APC or Zend Server Data Cache
– Limited due to lack of sync'd cache
• Distributed
– Memcached (Generic) or Zend Platform (PHP)
– Required for true scalability enhancement
Performance
Synchronization Primitives
Work
Partitioning
Interacting
With Hardware
Parallel
Access Control
Resource
Partitioning
& Replication
Do this first!
Job #1 is not selecting primitives!
Atomic Increment of global variable
CPU CPU CPU CPU
$ $ $ $
Interconnect
CPU CPU CPU CPU
$ $ $ $
Interconnect
CPU CPU CPU CPU
$ $ $ $
Interconnect
CPU CPU CPU CPU
$ $ $ $
Interconnect
Interconnect MemoryMemory
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Lots and Lots of Latency!!!
Security
Security Groups
…
DB
Security
Group
Web
Security
Group
… …
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
DB
VM
DB
VM
WebWeb
VMVM
WebWeb
VMVM
DB
VM
DB
VM
WebWeb
VMVM
WebWeb
VMVM
…
DB
Security
Group
Web
Security
Group
Understanding security
groups
… …
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
WebWeb
VMVM
DB
VM
DB
VM
WebWeb
VMVM
WebWeb
VMVM
DB
VM
DB
VM
WebWeb
VMVM
WebWeb
VMVM
Ingress Rule: Allow VMs in Web Security Group access to VMs in DB Security Group on Port 3306
Atomic Increment of per CPU variable
CPU CPU CPU CPU
$ $ $ $
Interconnect
CPU CPU CPU CPU
$ $ $ $
Interconnect
CPU CPU CPU CPU
$ $ $ $
Interconnect
CPU CPU CPU CPU
$ $ $ $
Interconnect
Interconnect MemoryMemory
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Store
Buffer
Little Latency, Lots of Increments at Core Clock RateLittle Latency, Lots of Increments at Core Clock Rate
Cloud at scale
• Host management
• Capacity management
• What host to use to deploy a new VM
• Failure handling
• Security group propagation
Reference
• Highly Scalable Web Applications, Eli White (2009)
• 雲端運算 - 商業模式、核心技術與架構 , Jazz Wang
(2012)
http://0xlab.org

Mais conteúdo relacionado

Semelhante a Week 15 - Scaling & Security_Jim Huang

Intro to SW Eng Principles for Cloud Computing - DNelson Apr2015
Intro to SW Eng Principles for Cloud Computing - DNelson Apr2015Intro to SW Eng Principles for Cloud Computing - DNelson Apr2015
Intro to SW Eng Principles for Cloud Computing - DNelson Apr2015
Darryl Nelson
 
Securing web applications
Securing web applicationsSecuring web applications
Securing web applications
Supreme O
 
Debate Initial Post and Response Rubric Student Name .docx
Debate Initial Post and Response Rubric Student Name     .docxDebate Initial Post and Response Rubric Student Name     .docx
Debate Initial Post and Response Rubric Student Name .docx
simonithomas47935
 

Semelhante a Week 15 - Scaling & Security_Jim Huang (20)

Pillars of great Azure Architecture
Pillars of great Azure ArchitecturePillars of great Azure Architecture
Pillars of great Azure Architecture
 
Intro to SW Eng Principles for Cloud Computing - DNelson Apr2015
Intro to SW Eng Principles for Cloud Computing - DNelson Apr2015Intro to SW Eng Principles for Cloud Computing - DNelson Apr2015
Intro to SW Eng Principles for Cloud Computing - DNelson Apr2015
 
DevOps in Practice: When does "Practice" Become "Doing"?
DevOps in Practice: When does "Practice" Become "Doing"?DevOps in Practice: When does "Practice" Become "Doing"?
DevOps in Practice: When does "Practice" Become "Doing"?
 
Top 20 azure interview questions
Top 20 azure interview questionsTop 20 azure interview questions
Top 20 azure interview questions
 
Securing web applications
Securing web applicationsSecuring web applications
Securing web applications
 
Best practice adoption (and lack there of)
Best practice adoption (and lack there of)Best practice adoption (and lack there of)
Best practice adoption (and lack there of)
 
Continuous Deployment at Etsy — TimesOpen NYC
Continuous Deployment at Etsy — TimesOpen NYCContinuous Deployment at Etsy — TimesOpen NYC
Continuous Deployment at Etsy — TimesOpen NYC
 
Performance Requirements: the Backbone of the Performance Engineering Process
Performance Requirements: the Backbone of the Performance Engineering ProcessPerformance Requirements: the Backbone of the Performance Engineering Process
Performance Requirements: the Backbone of the Performance Engineering Process
 
Virtualization and Cloud Computing
Virtualization and Cloud ComputingVirtualization and Cloud Computing
Virtualization and Cloud Computing
 
Finally, EE Security API JSR 375
Finally, EE Security API JSR 375Finally, EE Security API JSR 375
Finally, EE Security API JSR 375
 
Getting the most from your virtual infrastructure
Getting the most from your virtual infrastructureGetting the most from your virtual infrastructure
Getting the most from your virtual infrastructure
 
Cloud First Architecture
Cloud First ArchitectureCloud First Architecture
Cloud First Architecture
 
A Year of “Testing” the Cloud for Development and Test
A Year of “Testing” the Cloud for Development and TestA Year of “Testing” the Cloud for Development and Test
A Year of “Testing” the Cloud for Development and Test
 
Twelve Factor - Designing for Change
Twelve Factor - Designing for ChangeTwelve Factor - Designing for Change
Twelve Factor - Designing for Change
 
Open Source
Open SourceOpen Source
Open Source
 
Open Source
Open SourceOpen Source
Open Source
 
Accelerate your Application Delivery with DevOps and Microservices
Accelerate your Application Delivery with DevOps and MicroservicesAccelerate your Application Delivery with DevOps and Microservices
Accelerate your Application Delivery with DevOps and Microservices
 
Debate Initial Post and Response Rubric Student Name .docx
Debate Initial Post and Response Rubric Student Name     .docxDebate Initial Post and Response Rubric Student Name     .docx
Debate Initial Post and Response Rubric Student Name .docx
 
BPMS Buyer's Tool Kit - Sample RFP
BPMS Buyer's Tool Kit - Sample RFPBPMS Buyer's Tool Kit - Sample RFP
BPMS Buyer's Tool Kit - Sample RFP
 
JAVA Magazine Sep-Oct 2013
JAVA Magazine Sep-Oct 2013JAVA Magazine Sep-Oct 2013
JAVA Magazine Sep-Oct 2013
 

Mais de AppUniverz Org

Mais de AppUniverz Org (6)

Week 11 - KKBOX_Eric Tsai
Week 11 - KKBOX_Eric TsaiWeek 11 - KKBOX_Eric Tsai
Week 11 - KKBOX_Eric Tsai
 
Week 08 Cloud_Eric Shangkuan
Week 08 Cloud_Eric ShangkuanWeek 08 Cloud_Eric Shangkuan
Week 08 Cloud_Eric Shangkuan
 
Week 05 Web, App and Javascript_Brandon, S.H. Wu
Week 05 Web, App and Javascript_Brandon, S.H. WuWeek 05 Web, App and Javascript_Brandon, S.H. Wu
Week 05 Web, App and Javascript_Brandon, S.H. Wu
 
Week 04 Web Development Flow and Fast Prototyping_hlb (2013-03-14)
Week 04 Web Development Flow and Fast Prototyping_hlb (2013-03-14)Week 04 Web Development Flow and Fast Prototyping_hlb (2013-03-14)
Week 04 Web Development Flow and Fast Prototyping_hlb (2013-03-14)
 
Appuniverz 回顧與展望
Appuniverz 回顧與展望Appuniverz 回顧與展望
Appuniverz 回顧與展望
 
[課程介紹] App創業與實作
[課程介紹] App創業與實作[課程介紹] App創業與實作
[課程介紹] App創業與實作
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

Week 15 - Scaling & Security_Jim Huang