作者 主題: 請問如何改善asp .net 的效能 到 跟asp 一樣快? IIS tunning  (閱讀 10839 次)

0 會員 與 1 訪客 正在閱讀本文。

小徒兒

  • 鑽研的研究生
  • *****
  • 文章數: 622
    • 檢視個人資料
請問如何改善asp .net 的效能 到 跟asp 一樣快?

以前同事用asp連資料庫(透過撥接都可以上),現在說透過撥接 asp.net慢到不能用,請問各位前輩先進有無改善asp.net效能的寶貴經驗?

先謝謝囉~~
代碼: [選擇]

Tool:
Visual studio team edition for tester or visual studio team suite
Support recording the operation webpage
Support webpage unt test
Support web function test
Support loading test

Visual Studio 2008 Team Load Test Agent
Support big scale
Msdn web performance


Analyzer web page performance Tool
Microsoft log parser
1、 The most slow response web page
2、 The most being viewed web page
SQL Server Report Pack for IIS Log
3、 2004 good to view
4、 Core Pase

Microsoft SQL Server Analysis Service + Microsoft Excel
5、 Advanced performance analysis
6、 Tivot analyzing Table, Pivot Chart
7、 Import IIS log to import to SQL server by Log parser


***Demo
Visual studio
Add one website project
Default.aspx

 Login.aspx
Log in control
Align center
Add “Log in” control, use the format
Web.config
1、 Project asp.net 組態
2、 Security/ authenfication/from web/ anonymous deny
3、 Forms name=”website1” loginurl=”login.url”
4、 Copy the connection string to replace on connect string
Web.config
In the norwind add user table
ID(int) identity reconization format, PK
username, password
named users


*. Tem database version
. add one project
. import database instructure
l Pick up northwind
l Database project
l

Database
1. Data generation plan
2. Add data generation plan
3. Unchecked the others
4. Left users,  regular expression, generate pattern (   user [0-9]
5. Password, regular expression, generate pattern (     password[0-9]  )
6. 50 records
7. Generate records
8. Pick up DB
9. Clear then insert
10. To simulate the real loading
Use team database toward LoginCheck to do the Unit test
Go to login.aspx
5、 Add name space within “解析”
6、 Run SP “login check”
7、 Write SP
8、 Build and run


Test again
表單張貼參數,加入資料來源,northwind , user table
Sequential/random
User pick up DB/users/username
Password pick up DB/users/password
Plus loading test, user view 總測試數, 測1分鐘
Sql tracking start / sql tracking 都選擇
測試清單編輯器

Tool
Visual Studio 2008 Team Load Test Agent
Controller
1、 Write data into SQL
Agent
2、 Sending request
One agent 2000 users simulation

***Report
Codeplex.com/loadtestreports
Download load_test_report
Unzip
1、 Loadtestreport
2、 Summary report
3、 Counter values per time

***Visual studio 2008 report
Controller and agent
Checking result
Log-in check
1、 Exec logincheck

***Reporting Service
Log Parser
1、 Start IIS as default web site
2、 W3C/進階 checked all item

3、 Overlay context
4、 Load Test Statistics
5、 View State and Loadview state
6、 Counter (平均的頁面時間)
Log Parser
7、 View most viewing webpage
8、 Build your self DB Schema and pull in the log data
9、 The ten web pages top 10 slow
SQL Server Report Pack for IIS
10、 Pages summary
i. 2008 pick up what page take how many connection and percentage
ii. The top 1 web should be picked up as the top 1 tunning page
iii. Spent how many hours,

*** write sql query and post in the excel


***List the basic Tunning statistic
Find out the bottle neck of the efficiency
Cahe and no cache
1、 In memory always wins
2、 If your page need to get the web service or file content , ro db record to put into memory
3、 Use webpage and outputCache
4、 <%@ OutputCache Duration=”60”
VarybyParam=”none”
VarybyCustomer=”browser” %>
5、 Use substitution control
i. Methodname = “GetuserName”
ii. <asp:substitution
Micro Caching idea
6、 Put in the caching in the very short time
7、 <%@ OutputCache Duration=”2”
VarybyParam=”none”
VarybyCustomer=”browser” %>
8、 Pre-request Caching
i. User request data in cache
ii. http.context.current.item
1. put all data in the http.context.current.item

State Bag Access Pattern
9、 If (Cache[“customers”] == null
10、 List<Cusomer> my list = Cache
11、 Race condition
12、 Stale Data
i. Clear the memory content after data updating
ii. Use SQL Cache Dependency
1. http://msdn.mic/en-us/library/ms178604.aspx
13、 Microsoft Velocity support In many server support memory cache
Write Cache (緩存計術)
14、 Lower the times to write to DB and file
15、 Accompany log function
16、 How to :
i. Cache
ii. Microsoft Message Queue

DataSource control cache
17、 Sqldatasource, accessdatasource
18、 Objectdatasource, xmldatasource
19、 enableCaching = true


Databound control efficiency (Grid View or Repeater)
20、 Repeater light better
21、 Grid View 3.61
Data Source and UI Paging (no paging result system loading), UI paging -> result the in-efficiency
22、 Linq: one time for 10 pages
23、 Server side paging (grid view allow paging)
24、 Objectdatasource
i. Maximurowsparametername=”maxrows”
ii. Startrowindexparametername=”startrows”
iii. Selectmethod=”select cusomter”
iv. Linq : startrows, max rows
v. UI: 8.03 , datasource : 5.01

View state and no view state
25、 Turn off the viewstate : Enableviewstate to false
26、 3.97 ->2.25

Sync or not sync
27、 Async = true
28、 Asp.net ajax
i. Clientscriptcallback
29、 Compliation debug = false
Ajax or not ajax



和IIS效能有關的設定   

-------------------

1) Use IIS 6 Kernel Caching

   <httpRunTime enableKernelOutputCache="true" . . ./>

2) Use IIS GZIP compression function

   編輯\Windows\System32\inetsrv\Metabase.xml, 找到gzip的<IIsCompressionScheme>, 將HcScriptFileExtensions屬性修改成="aspx asp dll exe"

 

source from  王寧疆

0. sense if the source is from slow connection, use html contrl instead of web control

to be done, log parser search

How to improve IIS performance
1.   change the asp.net
   enable compression

to be done and search

2.   enable cache in the asp.net page

2.1   Cahe and no cache (efficency a lot of different)
代碼: [選擇]

<%@ OutputCache Duration=”60”
                 VarybyParam=”none”
VarybyCustomer=”browser” %>

to be done and search


2.2.   Micro Caching idea
i   Put in the caching in the very short time
ii   <%@ OutputCache Duration=”2”
VarybyParam=”none”
VarybyCustomer=”browser” %>


3.   turn off the view state (efficiency a lot of different)
can not done

3.1   Turn off the viewstate : Enableviewstate to false
3.2   3.97 ->2.25

4.         turn debug to false
   Compliation debug = false
done

***List the basic Tunning statistic
1.   Find out the bottle neck of the efficiency
         
  1.1   tinyget
i.   tinyget -srv:www.YourServer.com -uri:
ii.   tinyget -srv:localhost -uri:/BuggyBits/Links.aspx -loop:4000
b.   to view the status code match expected one

1.2.   log parser

1.2.1 以滑鼠右鍵按一下以開啟記錄, 為您要網站, 然後按一下 [ 內容 ] 。
在 [ 網站 ] 索引標籤, 選取 的 [ 啟用記錄 ] 核取方塊 。

請注意 [ 網站 ] 索引標籤上 的 [ 啟用記錄 ] 核取方塊 及 造訪記錄 在 [ 主目錄 ] 索引標籤必須先檢查是否記錄到會啟用。
在 [ 當前日誌格式 ] 清單選取格式。
按一下 內容 ] , 按一下 [ 進階 ] 索引標籤, 然後再選取項目, 您要監視記錄檔中

請注意 : 按一下 [ 內容 ] 如果您選取 [ ODBC 記錄 , 提供 ODBC 資料來源名稱 (DSN)、 資料表、, 使用者名稱和密碼, 然後按一下 [ 確定 ]

1.2.2
a.   in command window, type
i.   logparser “select count(*) from u_ex*.log”
ii.   logparser “select sc-status, count(*) from u_ex*.log gourp by sc-status”
iii.   logparser -o:IIS "select * into merged.log from ex*.log"

1.3.   wcat


1.4   performance counter

1.5 sql server profiler

1.6 sql server management studio
1.6.1 activity manager
1.6.2 dynamic management views
1.6.3 table scan
1.6.4 clustered index scan

1.7 CLR profiler
1.7.1 processor time
1.7.2 disk time
1.7.3 page/sec


3.   Use substitution control
i.   Methodname = “GetuserName”
ii.   <asp:substitution

need to search

5.   Pre-request Caching
i.   User request data in cache
ii.   http.context.current.item
1.   put all data in the http.context.current.item

4.   State Bag Access Pattern
甲、   If (Cache[“customers”] == null
乙、   List<Cusomer> my list = Cache
丙、   Race condition
丁、   Stale Data
i.   Clear the memory content after data updating
ii.   Use SQL Cache Dependency
1.   http://msdn.mic/en-us/library/ms178604.aspx
戊、   Microsoft Velocity support In many server support memory cache
5.   Write Cache (緩存計術)
甲、   Lower the times to write to DB and file
乙、   Accompany log function
丙、   How to :
i.   Cache
ii.   Microsoft Message Queue

6.   DataSource control cache
甲、   Sqldatasource, accessdatasource
乙、   Objectdatasource, xmldatasource
丙、   enableCaching = true


7.   Databound control efficiency (Grid View or Repeater)
甲、   Repeater light better
乙、   Grid View 3.61
8.   Data Source and UI Paging (no paging result system loading), UI paging -> result the in-efficiency
甲、   Linq: one time for 10 pages
乙、   Server side paging (grid view allow paging)
丙、   Objectdatasource
i.   Maximurowsparametername=”maxrows”
ii.   Startrowindexparametername=”startrows”
iii.   Selectmethod=”select cusomter”
iv.   Linq : startrows, max rows
v.   UI: 8.03 , datasource : 5.01

9.   View state and no view state
甲、   Turn off the viewstate : Enableviewstate to false
乙、   3.97 ->2.25

10.   Sync or not sync
甲、   Async = true
乙、   Asp.net ajax
i.   Clientscriptcallback
丙、   Compliation debug = false
11.   Ajax or not ajax
12.   



代碼: [選擇]

IIS 7.0
Server 2008 plus

? How to improve IIS performance
change the asp.net
enable compression
enable cache in the asp.net page
turn off the view state



**debug
use firefox debugging tool


***IIS 6.0 to IIS 7.0
buy upgrade kit

600 vroots
350 iss web applications
11 application pools
windows server 2008 enterprise x64
early adoption of  MS OS

? efficency comparision
? real statistic to approve it


lab testing
single productin servr (offline)
single production server (live load)
single server cluster (20)
preproduction and staging
full production deployment


***build base image, on the test server

Intergrated lights-out
install 2008
use servermanagercmd.exe
a. servermanagercmd.exe –I web-server web-common-http  WAS
sysprep
b. server name set up (mini setup)
use imagex to build image file (OS partitions only)
waik
imagex /config c:\imaging\<configuration_list>.ini /capture d:d:\imaging\data.wim "Drive D"


***Deploy to other servers
***setup the server role
www.microsoft.com include
a. iis
b. distributed file system replication (DFSR)
IIS role service
c. Only install the service you want. IIS 6 WMI compatibility provide Windows management instrumentation (WMI)


***IIS migration tool kit
use the scipts to upgrade IIS 6.0 to IIS 7.0

test and pressure test tool use TinyGet and Web Capacity Analysis Tool (WCAT)
what’s the differences between TinyGet and WCAT?

you can find them in IIS resource Tool Kit

Integrated mode for big 5 will error, classic mode




Tools
sysprep
imagex
web deployment tool
appcmd
servermanagercmd.exe
legacy scripts

***test & pressure test

 
4. 以滑鼠右鍵按一下以開啟記錄, 為您要網站, 然後按一下 [ 內容 ] 。    
5. 在 [ 網站 ] 索引標籤, 選取 的 [ 啟用記錄 ] 核取方塊 。

請注意 [ 網站 ] 索引標籤上 的 [ 啟用記錄 ] 核取方塊 及 造訪記錄 在 [ 主目錄 ] 索引標籤必須先檢查是否記錄到會啟用。    
6. 在 [ 當前日誌格式 ] 清單選取格式。    
7. 按一下 內容 ] , 按一下 [ 進階 ] 索引標籤, 然後再選取項目, 您要監視記錄檔中

請注意 : 按一下 [ 內容 ] 如果您選取 [ ODBC 記錄 , 提供 ODBC 資料來源名稱 (DSN)、 資料表、, 使用者名稱和密碼, 然後按一下 [ 確定 ]

tinyget
i. tinyget -srv:www.YourServer.com -uri:
ii. tinyget -srv:localhost -uri:/BuggyBits/Links.aspx -loop:4000
b. to view the status code match expected one

log parser
c. in command window, type
i. logparser “select count(*) from u_ex*.log”
ii. logparser “select sc-status, count(*) from u_ex*.log gourp by sc-status”
iii. logparser -o:IIS "select * into merged.log from ex*.log"

wcat
d.


***Tinyget
need tinyget and log file
log file (sql server

***experiences sharing
one time do one big amendment
a. 32 bit and 64 bit app pools can exist at the same time
cooperate as early as possible
use Web deployment tool
use tinyget and wcat to do the log playback

*** IIS set
not need to do the metadata
machine config (.net) -> web.config (asp.net)

***delegated configuration
applicationhost.config seeting  allow certain program in the web.config
default document
directorybrowse
validation
httperros
modules
in web.config

***shared configuration
setting up the configfile on the unc share
use domain or local account

***experience
direct replicate applicaitonhost.config
app pool setting change will result recycle (eg application pool restart , pipeline mode)
back up the system
%windir%\system32\inetsrv\appcmd add backup “My Backup”
default value in schema

**efficiency
dynamic and static impression  (1/10) download
10 % Requests/Sec






Resource from胡士亮

« 上次編輯: 2008-10-02 15:10 由 小徒兒 »

threeseconds

  • 俺是博士!
  • *****
  • 文章數: 1368
    • 檢視個人資料
    • http://www.3sec.tw
這跟 asp.net 有什麼關係?
本文作者為天線寶寶,長期關注兒童智力發展狀態。

洋蔥叔叔

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 830
    • 檢視個人資料
    • 洋蔥叔叔的隨意漫談電腦、網路、.NET、軟體本地化、雜七雜八
要看你程式碼怎麼寫的吧,如果隨便就可以改善的話,你當設計 ASP.NET 跟 ADO.NET 的人都是白痴的嗎。