SlideShare a Scribd company logo
1 of 35
Web Program Performance Optimization




                        Email:designsor@gmail.com
                        Twitter:twitter/xiao_jue
Program Optimization ?

Program ?

Performance Optimization ?
data structure + algorithm (Worth)
What's Algorithm?

Simplify data structure.

Good design patterns may be not fastest.
One Billion loop Performance for language

time.c

time.py

time.js

time.php

Can you guess who the fastest?




           time.c 0.28s time.js 0.19s time.php 10s time.python 5.46599197388s
Where's web program different than common program?




            We need more and more things to do.
Fat client,thin client;
B/S or ERP;
Web site;
Web game;
More and more.

Back-end or Front-end
development and optimization.

Historical issues.
Browser - > server -> DB;
DB-> server -> Browser;

Read:
Browser->server->Cache->DB;
1,Cache->server->Browser;
2,DB->Cache->server->Browser;

Write:
Browser->server->Cache ;

Interval write:
Cache-> DB;
I/O

Network I/O

Disk I/O

Memory I/O
Nosql

Cassandra
Mongo
Memcached
Redis
Terracotta


Somethings else for back-end development
1,You type an URL into address bar in your preferred browser.

2,The browser parses the URL to find the protocol, host, port, and path.

3,It forms a HTTP request (that was most likely the protocol)

4,To reach the host, it first needs to translate the human readable host into an IP number,
and it does this by doing a DNS lookup on the host

5,Then a socket needs to be opened from the user’s computer to that IP number, on the port specified (most often port 80)

6,When a connection is open, the HTTP request is sent to the host

7,The host forwards the request to the server software (most often Apache) configured to listen on the specified port

8,The server inspects the request (most often only the path), and launches the server plugin needed to
handle the request (corresponding to the server language you use, PHP, Java, .NET, Python?)

9,The plugin gets access to the full request, and starts to prepare a HTTP response.

10,To construct the response a database is (most likely) accessed. A database search is made, based on parameters in the
path (or data) of the request

11,Data from the database, together with other information the plugin decides to add, is combined into a long string of text
(probably HTML).

12,The plugin combines that data with some meta data (in the form of HTTP headers), and sends the HTTP response back
to the browser.

13,The browser receives the response, and parses the HTML (which with 95% probability is broken) in the response

14,A DOM tree is built out of the broken HTML

15,New requests are made to the server for each new resource that is found in the HTML source (typically images, style
sheets, and JavaScript files). Go back to step 3 and repeat for each resource.

16,Stylesheets are parsed, and the rendering information in each gets attached to the matching node in the DOM tree

17,Javascript is parsed and executed, and DOM nodes are moved and style information is updated accordingly

18,The browser renders the page on the screen according to the DOM tree and the style information for each node

19,You see the page on the screen

20,You get annoyed the whole process was too slow.




https://github.com/chaosmical/HTTP-headers-status-CN/raw/master/http-headers-status-CN.jpg
Front-end-process
Resource downloads(cache and server handle)

CDN

DNS

Js Module downloads(Sync and Asyn)

Pack code

HTTP and browsers limit

Handle slowly users
Resource downloads
Accept-Encoding:gzip
Cache-control,max-age,last-Modified, expires, eTag
Transfer-Encoding:keep-alive,Connection:chunked
CDN
CloudFlare

Speedy Mirror

Webluker

Public Resources on SAE

Taobao CDN
DNS
Js Module downloads(Sync and Asyn)
sync               function loadByQueue(list,type,callback){
                     Var _load={
                        “sync”:function(list){
>>                            Var src = list[0];
                              If(!src) callback();
 >>                            getScript(src,function(){
                                 list.shift();
  >>                              _load['sync'](list);
                               });
asyn                     },
                        “asyn”:function(list){
                            Var list = list.reverse(),len = list.length;
>>                           while(len—){
                               Var src = list[len];
>>                              queue[len] = flase;
                                 getScript(src,function(){
>>                                  queue.foreach(function(i){
                                     If(!i) return;
                                     If(i && i==queue.length){
                                        callback();
                                     }
                                    });
                                 });
                             }
                         }
                     }
                   }

                   LoadByQueue(['1.js','2.js','3.js'],”sync”);
Pack code
Css:No gzip
Js:More fastest execute,more smaller
Google Closure Compiler vs yuicompress
HTTP and browsers limit
Get fast than post

URLs over 2,000 characters will not work in the most popular web browser.

HTTP1.1 persistent connection

HTTP 1.1 HTTP 1.0 complicated the same domain

IE 6,7      2        4

IE 8        6        6

Firefox 2   2        8

Firefox 3   6        6

Safari 3, 4 4        4

Chrome 1,2           6   ?

Chrome 3 4           4

Opera 9.63,10.00alpha 4         4

One client 300 Cookie , One domain 20 Cookie

IE: css 31 stylesheet
Handle slowly users
var someapp = new app();

someapp.init();



var someapp = new app();

$.extend(someapp,{

Speed:null,

checkSpeed:function(){

var self = this,timeout = 10000;

self.Speed =
     setTimeout(function(){

$.trigger(“slowly”,[self]);

},timeout);

},

closeCheckSpeed:function(){

clearTimeout(this.Speed);
Front-end-execute
Dom Rendering

Css Rendering

Javascript Executed

Test and code refactoring

Some code skills
Dom Rendering
Css Rendering

1,Use efficient CSS selectors

2,Avoid CSS expressions

3,Put CSS in the document head

4,Specify a character set

5,Avoid reflow and repaint by specifying image
dimension

6,CSS3 Selectors

Speed vs Practicality
Javascript Execute

Order
Loading and Execution
Data Access and Cache(closures,scope)
DOM Scripting
Repaints and Reflows
Event Delegation
Algorithms and Flow Control
String and Regular Expressions(trim)
http://blog.stevenlevithan.com/archives/faster-trim-javascript

Responsive Interfaces
Ajax(MXHR,Data Format)
Test and code refactoring
refactoring based on Test
Write Testable code
Ui test and Unit test
Some code skills
Avoid Double Evaluation
Use Object/Array Literals
Don't repeat work
Lazy/Conditional Advance Loading(code or assets)
Bitwise Operators
Native Methods
Front-end-scheme
Img optimization

Design

Seo

More choose for user

Tailor-made
Img optimization
JPG GIF PNG(8,24,32)
Pngcrush
Jpegtran
Gifsicle
Smush.it
Avoid AlphaImageLoader
Optimizing Sprites
Avoid Scaling Images
Design
Seo
Define keywords
In order of popularity
Removed Repeat keywords
Top three is title
Description meta tag
Keywords meta tag
h1-h6
Keywords appear tactics
Content for keywords(uri is title,tags cloud)
More choose for user
Slowly user
Special user
Disability user
Different terminal user
Tailor-made
User habits Analysis
Advance load assets
Front-end-tools
Page speed

Yslow

Chrom monster

DynaTrace
Endless possibilities
Meteor

Tower.js

Yes,they all based on nodejs !
Web program-peformance-optimization
Web program-peformance-optimization

More Related Content

What's hot

Lightweight DAS components in Perl
Lightweight DAS components in PerlLightweight DAS components in Perl
Lightweight DAS components in Perlguestbab097
 
Storing 16 Bytes at Scale
Storing 16 Bytes at ScaleStoring 16 Bytes at Scale
Storing 16 Bytes at ScaleFabian Reinartz
 
Using ngx_lua in upyun 2
Using ngx_lua in upyun 2Using ngx_lua in upyun 2
Using ngx_lua in upyun 2OpenRestyCon
 
Intro KaKao MRTE (MySQL Realtime Traffic Emulator)
Intro KaKao MRTE (MySQL Realtime Traffic Emulator)Intro KaKao MRTE (MySQL Realtime Traffic Emulator)
Intro KaKao MRTE (MySQL Realtime Traffic Emulator)I Goo Lee
 
Developing High Performance Application with Aerospike & Go
Developing High Performance Application with Aerospike & GoDeveloping High Performance Application with Aerospike & Go
Developing High Performance Application with Aerospike & GoChris Stivers
 
Monitoring MySQL with OpenTSDB
Monitoring MySQL with OpenTSDBMonitoring MySQL with OpenTSDB
Monitoring MySQL with OpenTSDBGeoffrey Anderson
 
NoSQL and SQL Anti Patterns
NoSQL and SQL Anti PatternsNoSQL and SQL Anti Patterns
NoSQL and SQL Anti PatternsGleicon Moraes
 
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaRoll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaJon Moore
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxyIsmael Celis
 
Redis modules 101
Redis modules 101Redis modules 101
Redis modules 101Dvir Volk
 
Building a High-Performance Distributed Task Queue on MongoDB
Building a High-Performance Distributed Task Queue on MongoDBBuilding a High-Performance Distributed Task Queue on MongoDB
Building a High-Performance Distributed Task Queue on MongoDBMongoDB
 
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::ClientBuilding Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::ClientMike Friedman
 
Lua tech talk
Lua tech talkLua tech talk
Lua tech talkLocaweb
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev ConfTom Croucher
 
MySQL Monitoring using Prometheus & Grafana
MySQL Monitoring using Prometheus & GrafanaMySQL Monitoring using Prometheus & Grafana
MySQL Monitoring using Prometheus & GrafanaYoungHeon (Roy) Kim
 
From zero to hero - Easy log centralization with Logstash and Elasticsearch
From zero to hero - Easy log centralization with Logstash and ElasticsearchFrom zero to hero - Easy log centralization with Logstash and Elasticsearch
From zero to hero - Easy log centralization with Logstash and ElasticsearchRafał Kuć
 

What's hot (20)

Tuning Solr for Logs
Tuning Solr for LogsTuning Solr for Logs
Tuning Solr for Logs
 
Lightweight DAS components in Perl
Lightweight DAS components in PerlLightweight DAS components in Perl
Lightweight DAS components in Perl
 
Storing 16 Bytes at Scale
Storing 16 Bytes at ScaleStoring 16 Bytes at Scale
Storing 16 Bytes at Scale
 
Using ngx_lua in upyun 2
Using ngx_lua in upyun 2Using ngx_lua in upyun 2
Using ngx_lua in upyun 2
 
Intro KaKao MRTE (MySQL Realtime Traffic Emulator)
Intro KaKao MRTE (MySQL Realtime Traffic Emulator)Intro KaKao MRTE (MySQL Realtime Traffic Emulator)
Intro KaKao MRTE (MySQL Realtime Traffic Emulator)
 
Developing High Performance Application with Aerospike & Go
Developing High Performance Application with Aerospike & GoDeveloping High Performance Application with Aerospike & Go
Developing High Performance Application with Aerospike & Go
 
Monitoring MySQL with OpenTSDB
Monitoring MySQL with OpenTSDBMonitoring MySQL with OpenTSDB
Monitoring MySQL with OpenTSDB
 
NoSQL and SQL Anti Patterns
NoSQL and SQL Anti PatternsNoSQL and SQL Anti Patterns
NoSQL and SQL Anti Patterns
 
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaRoll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and Lua
 
On Centralizing Logs
On Centralizing LogsOn Centralizing Logs
On Centralizing Logs
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxy
 
Redis modules 101
Redis modules 101Redis modules 101
Redis modules 101
 
Building a High-Performance Distributed Task Queue on MongoDB
Building a High-Performance Distributed Task Queue on MongoDBBuilding a High-Performance Distributed Task Queue on MongoDB
Building a High-Performance Distributed Task Queue on MongoDB
 
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::ClientBuilding Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::Client
 
Lua tech talk
Lua tech talkLua tech talk
Lua tech talk
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
 
MySQL Monitoring using Prometheus & Grafana
MySQL Monitoring using Prometheus & GrafanaMySQL Monitoring using Prometheus & Grafana
MySQL Monitoring using Prometheus & Grafana
 
From zero to hero - Easy log centralization with Logstash and Elasticsearch
From zero to hero - Easy log centralization with Logstash and ElasticsearchFrom zero to hero - Easy log centralization with Logstash and Elasticsearch
From zero to hero - Easy log centralization with Logstash and Elasticsearch
 
Top Node.js Metrics to Watch
Top Node.js Metrics to WatchTop Node.js Metrics to Watch
Top Node.js Metrics to Watch
 
Tuning Solr & Pipeline for Logs
Tuning Solr & Pipeline for LogsTuning Solr & Pipeline for Logs
Tuning Solr & Pipeline for Logs
 

Similar to Web program-peformance-optimization

nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.Mike Brevoort
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPMariano Iglesias
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareAlona Mekhovova
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHPKing Foo
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programmingFulvio Corno
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
 
Scaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachScaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachJinal Jhaveri
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...François-Guillaume Ribreau
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsOhad Kravchick
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web PerformanceAdam Lu
 
Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"EPAM Systems
 
JRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldJRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldSATOSHI TAGOMORI
 

Similar to Web program-peformance-optimization (20)

nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHP
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
Android and REST
Android and RESTAndroid and REST
Android and REST
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHP
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programming
 
NodeJS
NodeJSNodeJS
NodeJS
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
Scaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachScaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approach
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
 
Rack
RackRack
Rack
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web Performance
 
Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"
 
JRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldJRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing World
 

More from xiaojueqq12345

More from xiaojueqq12345 (7)

前端模块化开发
前端模块化开发前端模块化开发
前端模块化开发
 
Fds-给前端用的服务器
Fds-给前端用的服务器Fds-给前端用的服务器
Fds-给前端用的服务器
 
Voluminous_Weibo
Voluminous_WeiboVoluminous_Weibo
Voluminous_Weibo
 
Lithe
LitheLithe
Lithe
 
nodejs开发web站点
nodejs开发web站点nodejs开发web站点
nodejs开发web站点
 
Mxhr
MxhrMxhr
Mxhr
 
淘宝帮派活动项目总结
淘宝帮派活动项目总结淘宝帮派活动项目总结
淘宝帮派活动项目总结
 

Recently uploaded

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Web program-peformance-optimization

  • 1. Web Program Performance Optimization Email:designsor@gmail.com Twitter:twitter/xiao_jue
  • 2. Program Optimization ? Program ? Performance Optimization ?
  • 3. data structure + algorithm (Worth)
  • 4. What's Algorithm? Simplify data structure. Good design patterns may be not fastest.
  • 5. One Billion loop Performance for language time.c time.py time.js time.php Can you guess who the fastest? time.c 0.28s time.js 0.19s time.php 10s time.python 5.46599197388s
  • 6. Where's web program different than common program? We need more and more things to do.
  • 7. Fat client,thin client; B/S or ERP; Web site; Web game; More and more. Back-end or Front-end development and optimization. Historical issues.
  • 8. Browser - > server -> DB; DB-> server -> Browser; Read: Browser->server->Cache->DB; 1,Cache->server->Browser; 2,DB->Cache->server->Browser; Write: Browser->server->Cache ; Interval write: Cache-> DB;
  • 11. 1,You type an URL into address bar in your preferred browser. 2,The browser parses the URL to find the protocol, host, port, and path. 3,It forms a HTTP request (that was most likely the protocol) 4,To reach the host, it first needs to translate the human readable host into an IP number, and it does this by doing a DNS lookup on the host 5,Then a socket needs to be opened from the user’s computer to that IP number, on the port specified (most often port 80) 6,When a connection is open, the HTTP request is sent to the host 7,The host forwards the request to the server software (most often Apache) configured to listen on the specified port 8,The server inspects the request (most often only the path), and launches the server plugin needed to handle the request (corresponding to the server language you use, PHP, Java, .NET, Python?) 9,The plugin gets access to the full request, and starts to prepare a HTTP response. 10,To construct the response a database is (most likely) accessed. A database search is made, based on parameters in the path (or data) of the request 11,Data from the database, together with other information the plugin decides to add, is combined into a long string of text (probably HTML). 12,The plugin combines that data with some meta data (in the form of HTTP headers), and sends the HTTP response back to the browser. 13,The browser receives the response, and parses the HTML (which with 95% probability is broken) in the response 14,A DOM tree is built out of the broken HTML 15,New requests are made to the server for each new resource that is found in the HTML source (typically images, style sheets, and JavaScript files). Go back to step 3 and repeat for each resource. 16,Stylesheets are parsed, and the rendering information in each gets attached to the matching node in the DOM tree 17,Javascript is parsed and executed, and DOM nodes are moved and style information is updated accordingly 18,The browser renders the page on the screen according to the DOM tree and the style information for each node 19,You see the page on the screen 20,You get annoyed the whole process was too slow. https://github.com/chaosmical/HTTP-headers-status-CN/raw/master/http-headers-status-CN.jpg
  • 12. Front-end-process Resource downloads(cache and server handle) CDN DNS Js Module downloads(Sync and Asyn) Pack code HTTP and browsers limit Handle slowly users
  • 15. DNS
  • 16. Js Module downloads(Sync and Asyn) sync function loadByQueue(list,type,callback){ Var _load={ “sync”:function(list){ >> Var src = list[0]; If(!src) callback(); >> getScript(src,function(){ list.shift(); >> _load['sync'](list); }); asyn }, “asyn”:function(list){ Var list = list.reverse(),len = list.length; >> while(len—){ Var src = list[len]; >> queue[len] = flase; getScript(src,function(){ >> queue.foreach(function(i){ If(!i) return; If(i && i==queue.length){ callback(); } }); }); } } } } LoadByQueue(['1.js','2.js','3.js'],”sync”);
  • 17. Pack code Css:No gzip Js:More fastest execute,more smaller Google Closure Compiler vs yuicompress
  • 18. HTTP and browsers limit Get fast than post URLs over 2,000 characters will not work in the most popular web browser. HTTP1.1 persistent connection HTTP 1.1 HTTP 1.0 complicated the same domain IE 6,7 2 4 IE 8 6 6 Firefox 2 2 8 Firefox 3 6 6 Safari 3, 4 4 4 Chrome 1,2 6 ? Chrome 3 4 4 Opera 9.63,10.00alpha 4 4 One client 300 Cookie , One domain 20 Cookie IE: css 31 stylesheet
  • 19. Handle slowly users var someapp = new app(); someapp.init(); var someapp = new app(); $.extend(someapp,{ Speed:null, checkSpeed:function(){ var self = this,timeout = 10000; self.Speed = setTimeout(function(){ $.trigger(“slowly”,[self]); },timeout); }, closeCheckSpeed:function(){ clearTimeout(this.Speed);
  • 20. Front-end-execute Dom Rendering Css Rendering Javascript Executed Test and code refactoring Some code skills
  • 22. Css Rendering 1,Use efficient CSS selectors 2,Avoid CSS expressions 3,Put CSS in the document head 4,Specify a character set 5,Avoid reflow and repaint by specifying image dimension 6,CSS3 Selectors Speed vs Practicality
  • 23. Javascript Execute Order Loading and Execution Data Access and Cache(closures,scope) DOM Scripting Repaints and Reflows Event Delegation Algorithms and Flow Control String and Regular Expressions(trim) http://blog.stevenlevithan.com/archives/faster-trim-javascript Responsive Interfaces Ajax(MXHR,Data Format)
  • 24. Test and code refactoring refactoring based on Test Write Testable code Ui test and Unit test
  • 25. Some code skills Avoid Double Evaluation Use Object/Array Literals Don't repeat work Lazy/Conditional Advance Loading(code or assets) Bitwise Operators Native Methods
  • 27. Img optimization JPG GIF PNG(8,24,32) Pngcrush Jpegtran Gifsicle Smush.it Avoid AlphaImageLoader Optimizing Sprites Avoid Scaling Images
  • 29. Seo Define keywords In order of popularity Removed Repeat keywords Top three is title Description meta tag Keywords meta tag h1-h6 Keywords appear tactics Content for keywords(uri is title,tags cloud)
  • 30. More choose for user Slowly user Special user Disability user Different terminal user

Editor's Notes

  1. 程序( program )是为实现特定目标或解决特定问题而用计算机语言编写的命令序列的集合。为实现预期目的而进行操作的一系列语句和指令。一般分为系统程序和应用程序两大类。 一个程序应该包括以下两方面的内容。    1 对数据的描述。在程序中要指定数据的类型和数据的组织形式,即数据结构( data structure )。    2 对操作的描述。即操作步骤,也就是算法( algorithm )。 以上当然全部来自(百度百科)啦。 犀利的总结一下:数据结构 + 算法 = 程序(沃思)。 我这里想说的是 计算机语言,程序设计模式,不应该算在程序这个概念中,程序就定义而言,只是完成任务的工具集合或者操作指令等,看的是结果,所以语言和设计模式不算在程序的概念中,只是实现的过程。