玄铁剑

成功的途径:抄,创造,研究,发明...
posts - 128, comments - 42, trackbacks - 0, articles - 174

     摘要:   阅读全文

posted @ 2007-04-12 21:55 玄铁剑 阅读(1171) | 评论 (15)编辑 收藏

     摘要:   阅读全文

posted @ 2007-04-12 21:54 玄铁剑 阅读(181) | 评论 (0)编辑 收藏

     摘要:   阅读全文

posted @ 2007-04-05 20:23 玄铁剑 阅读(585) | 评论 (0)编辑 收藏

     摘要:   阅读全文

posted @ 2007-03-30 21:14 玄铁剑| 编辑 收藏

     摘要: Real-time displays the progress result of the jobs running at the server side.  阅读全文

posted @ 2007-03-08 22:25 玄铁剑 阅读(455) | 评论 (0)编辑 收藏

     摘要: GridView Redux,sample code  阅读全文

posted @ 2007-03-08 22:05 玄铁剑 阅读(336) | 评论 (0)编辑 收藏

Developing a web application that responds to users requests quickly is a target and a challenge for all web developers. ASP.NET was designed with speed optimization and performance improvements in mind. The set of enhancements like: Pages compilation, and Automatic storage on the server are new to ASP.NET. However, these enhancements are not enough to protect you from slow performance when a large number of  http requests are simultaneously processed by your web application.

To write a well performing web application you must make a balance between four common performance measures. These measures are:

Execution Time: It is the time taken to process a request. This is measured as the time elapsed between the first byte received from the server and the last one.

Response Time: It is the time between issuing a request and the first byte received as a response from the server.

Scalability: It measures the performance of a web application against resources (memory, processors, or computers) allocated for it.

Throughput: It is the number of requests your application can serve in a time unit, usually a second.

What follows is a list of areas that you can invoke to harvest for techniques that you can use to develop a high performance ASP.NET application.

State management
Data access
Page and server controls
Web applications
Coding practices

In what follows we will cover the first two areas. Part 2 covers the last three areas, and caching techiniques are deeply explained in Caching optimization.

State Management

The following issues give you some ideas about how to make state management efficient.

SessionState State

Disable session state when you are not using it. Not all web application require a session state for each user. When you disable unneeded session state you are definitely improving your application performance.

To disable session state for a complete page in your application, use the following code:

 
	<%@ page EnableSessionState="false" %>
 

If your page requires access to session variables only to read them then set the session state for this page to read only.

To disable  session state for the entire application, open the 'web.config' file, and set the mode attribute to off under the session state section as in the following code:

 
       <SessionState mode="off" />
 

Session State Provider

There are more than one approach for storing your session state data. You can choose the approach you prefer by setting the mode attribute under the session state section of your application 'web.config' file. The supported modes are: in-process mode, state server mode, SQL server mode, and custom mode. Each mode is suitable in some circumstance, and has its own set of advantages. The in-process session state is by far the fastest one. So, it is recommended to use the in-process provider if you want to store small amounts of volatile data in the session state. Other state server and SQL server providers are needed if your application using a web farm or garden, or if you want to retain your session state date if the web server is restarted.

Data Access

The following points give you some ideas about how to render data access efficient:

Use SQL server provider

Among the data providers available to be used, choose SQL data provider to build a high performance, scalable web application.

Use SQL Data Reader

The SQLDataReader class gives you the ability to read only retrieved records from the database for once. So, if this is all what you actually need, then it is extremely recommended to use a data reader class instead of a DataSet or, a Table Class. This will gives your application much higher performance.

Use Stored Procedures

Whenever possible use compiled stored procedure instead of SQL plain text commands, this gives your application an extra speed performance. SQL server builds and stores execution plans for previously stored procedures.

Make use of  SQLDataSource useful properties

Instead of writing a query that includes the "Where", or "Sort By" clauses use the caching, filtering, and sorting properties of the SQLDataSourse provider. You can set the SQLDataSource object's "EnableCaching" property to true to enable caching of the retrieved data by this data source. When you enable data source caching, SQLDataSource will do the operations like filtering and sorting on the cached data. You can use the "FilterExpression" property, and the "SortParameterName" property to perform filtering and sorting using the SQLDataSource object. This will certainly makes your application faster.

View State Encryption

You must balance between the importance of encrypting your application view state data to make your transferred data more secure, and the cost / the impact of using encryption on your application speed. Encryption has a fixed cost for initialization plus a unfixed cost depends on the size of data to be encrypted. In brief, it is recommended to avoid using unnecessary view state data encryption.

Paging

It is known that to display data from a given data source you have to use data controls like: GridView, and/or DetailsView controls and to bind them to the data source you want to display data from. You may want to adjust the display layout of some data records and columns within your screen by using the GridView, or the DetailsView paging property and set it to true. This paging technique is called UI paging (User Interface paging). To perform this service, the GridView control requests data from the specified data source, it then filters the elements that will be displayed in the current page and simply ignores the rest. It does this process each time a new page is required ... which is certainly a great waste of resources.

There is another technique for doing the same task, it is typically referred to as data source paging. In this technique you make use of a data source control that implements the DataSourceView class, and set its CanPage property to true, then you feed the GridView control or the DetailsView control from this data source. In this case the data source object queries only for the elements needed in each page. Thus, data source paging is more efficient than UI paging. The only data source class that allows data source paging is ObjectDataSource class.

Caching

Using the caching technique appropriately can improve the performance of your application more than using any other technique. .Net framework provides some mechanisms for caching pages and data within your ASP.NET application. You can use caching for pages that exhibit heavy traffic and do not change between requests. You can also cache small sized data that is used extensively by your application instead of processing them each time.

To use caching effectively, give attention to the following notes:

- Don't assign a small duration for your cached items, items that expire quickly take extra cost for cleaning up and garbage collection.
- Don't cache too many data items, there is a memory cost for each data item. It is not necessary to cache items that can be easily calculated or those which are rarely calculated or used.

Caching is so important and the ASP.NET framework gives a varity of caching mechanisms you can use to improve your application performance more and more. Some of those  mechanisms are: Caching application data, Page output casching, Caching web forms, and Caching parts of web forms.

posted @ 2007-03-08 22:02 玄铁剑 阅读(195) | 评论 (0)编辑 收藏


前  言
对于直接面对互联网用户的WEB应用,在开发设计的时候必须格外小心,因为谁也不知道在单位时间内WEB程序访问和运行的速度。所以,在程序设计完成以后,最后针对程序进行一些严格的甚至是苛刻的测试,以确定程序在复杂的网络环境和服务器高压负荷下是否可以保持正常和相对稳定的效率。
什么是负压测试
负压测试一般针对WEB应用进行,比如网站等。进行负压测试的目的是为了确定WEB应用在现实的网络环境中是否可以正确而安全的处理各种用户提交的不确定请求,检验程序的健壮性。
负压测试的另外一个目的在于故意提供足够多的请求,观察程序在这种情况下的反应能力。
为什么要负压测试
可能大家现在都已经很熟悉一个很著名的搜索引擎Google,我们知道,这个搜索引擎不但搜索结果准确,而且,搜索速度更是奇快无比。搜索结果准确,那是程序算法在一个方面的表现,搜索速度快,则关系到整个系统的构件和程序的健壮行。如果希望自己编写的程序也可以在大访问量的情况下“从容不迫”,就有必要对程序进行负压测试。
对于访问量较大的网站或者程序,特别是提供一些比较热门话题程序,最好在正式将网站或者程序公布以前进行比较完备的负压测试,并且根据测试即使优化程序或者合理配置服务器硬件,这样网站不至于在用户量急剧增加的情况下出丑甚至崩溃。
使用ACT进行测试
ACT简介
ACT(或者MSACT)是微软的Visual Studio 和Visual Studio.NET带的一套进行程序测试的工具,也正是我们的负压测试需要用到的。ACT不但可以记录程序运行的详细数据参数,用图表显示程序运行状况,而且安装和使用都比较简单,结果阅读也很方便,是一套较理想的测试工具。
安装ACT
最起码,当然我们需要Visual Studio,ACT似乎还没有单独的版本出现。在这里,我们测试一个WEB Service的在高负荷情况下的运行性能。首先,在Visual Studio中打开ACT(如图)
程序会提示是否建立一个新的工程,点击“是”,然后输入一个文字说明,出现以下界面(图二):

打开ACT以后,我们可以开始测试了。
建立一个新的测试
点击菜单【Action】->【New Test】(如图三)

会出现一个向导界面(图四)

向导我们太熟悉了,仔细阅读每个界面的说明文字, 选择就可以了。
编辑测试
经过以上的设置,会出现以下界面(图五):

很明显,以上界面我们人为的将它分为了三个部分,而且每个部分颜色各不相同。以上不同颜色的三个部分分别为:
左边蓝色部分:导航栏,测试入口和结果人口;
右上绿色:提示信息栏;
右下红色:VBS代码栏,在这里编辑测试需要的一些VBS代码,测试成功有效与否,全部依靠这些代码的执行情况。所以,这些代码最好仔细考虑并且多次测试;
在进行测试之前,首先设置测试的一些选项(菜单【Action】—>【Properties】)如图六

在以上界面,主要设置两个参数:
(1) Test duration设置,这里设置测试进行时间,默认为5分钟;
(2) 在Counters标签页设置一些测试性能数据;
以上设置完成以后,就可以开始修改VBS代码了,我们没必要遍历整个VBS代码,只看一些主要的:
Test.SendRequest("http://localhost/")
以上是默认代码,我们可以修改为以下代码:
Test.SendRequest("http://localhost/philipq/wsmessages/wsmsg.asmx/MPost?webKey=w2k&UName=Ad&UPassword=pwd&UTo=Admin&UMessage=ACT+Test")
以上代码的编写应该根据自身程序的特点来修改,以达到最好测试效果。
执行测试
点击工具栏的【Start】按钮开始测试如图):

测试进行的时候,会出现以下窗口提示(如图):

以上界面显示程序测试的时间、剩余时间、每秒提交的Request数量、提交的Request总量、错误数量等。点击按钮【Show details】可以查看详细数据。
测试结束以后,就可以查看测试的结果了。
阅读测试结果
测试完成以后,可以在图二左边的Result分支点击查看测试结果,在右方的报表栏我们可以查看到以下数据:OverView、Graphs、Requests等,下图是一个OverView的数据举例:

从以上报告可以看到,测试的程序每秒提交request23次,总共1400次。
测试结果的使用
根据测试的结果,我们可以知道程序运行的情况、在高负荷下服务器的承受能力。根据这些数据,我们来确定程序的性能和服务器的性能,以此来预测在程序正式使用以后可能遇到的情况和服务器需要的改进。
其他选择
上面介绍的ACT虽然很不错,但是,毕竟不是每一个用户都使用Visual Studio,这时候,我们可以考虑其他工具来进行测试。
Microsoft Web Application Stress Tool (WAS)
这个工具和ACT一样是微软的产品,但是,这个工具没有和Visual Studio集成,可以单独使用。感觉这个程序现在还在测试,但是一些基本的功能已经很完备,可以完成ACT几乎所有功能,而且,WAS使用更加简单,设置也更加完备明了。这个工具的另外一个特点是,它的报表是纯文本文件,而不是流行的HTML文件格式,但是,内容方面一点也不逊色。
关于这个工具的更多信息,可以在这里查阅:
http://homer.rte.microsoft.com/
Open System Testing Architecture (OpenSTA)
OpenSTA的特点是可以模拟很多用户来访问需要测试的网站,它是一个功能强大、自定义设置功能完备的软件,但是,这些设置大部分需要通过Script来完成,因此,在真正的使用这个软件之前,必须学习好它的Script编写。如果需要完成很复杂的功能,Script的要求还比较高,当然,这也是它的优点,一些程序员不会在意这些Script的。
这个软件完全免费而且源代码可以下载,感兴趣的朋友可以自己修改达到要求。
关于这个工具的更多信息,可以在这里查阅:
http://www.opensta.org/
http://opensta.sourceforge.net/
PureLoad
PureLoad是基于Java的测试工具,它的Script代码完全使用XML,所以,这些代码的编写很简单,它的测试报表包含文字和图形并可以输出为HTML文件。由于是基于Java的软件,所以,可以通过Java Beans API来增强软件功能。
关于这个工具的更多信息,可以在这里查阅:
http://www.pureload.com/
QALoad
QALoad不单单测试WEB应用,还可以测试一些后台的东西,比如SQL Server等,只要是它支持的协议,都可以测试;另外一点,QALoad不但可以测试Windows,而且可以测试AIX, HP-UX 和 Solaris等系统。但是,这款软件价格很高。
关于这个工具的更多信息,可以在这里查阅:
http://www.compuware.com/products/qacenter/qaload/
LoadRunner
对于财大气粗的大公司而言,这款软件可能比较适合,它的功能和QALoad相比不相上下,市面上著名的公司如IBM、SUN、Oracle等都用这个软件。但是它的价格也高不可攀,和功能成正比。
关于这个工具的更多信息,可以在这里查阅:
http://www-heva.mercuryinteractive.com/products/loadrunner/

posted @ 2007-03-08 21:46 玄铁剑 阅读(188) | 评论 (0)编辑 收藏

在WebForm上,有的处理需要比较长的时间,为了防止重复提交,就要使用防连击
javaScript代码:
function doubleCheck(){
    
if (window.document.readyState != null &&
            window.document.readyState 
!= 'complete')
    
{
        alert(
"正在处理,请等待!");
        
return false;
    }

    
else
    
{
    
        
return true;
    }

}

在C#代码中:
this.backButton.Attributes["onClick"]         = "return doubleCheck()";

posted @ 2007-03-08 21:34 玄铁剑 阅读(472) | 评论 (0)编辑 收藏

ConvertZ內碼轉換工具
http://alf-li.pcdiscuss.com/
TestDriven
http://testdriven.net/

Resharp
http://www.jetbrains.com/
Microsoft examcollection
http://www.examcollection.com/microsoft.html
http://www.visualcertexam.com/

.net控件网
http://www.dnc.com.cn/

绿色下载
http://www.xdowns.com

中国历法
http://www.chinesefortunecalendar.com/Default.htm

posted @ 2007-03-07 11:57 玄铁剑 阅读(600) | 评论 (1)编辑 收藏

仅列出标题
共13页: First 5 6 7 8 9 10 11 12 13