天天看點

資料庫壓力測試思路

原文是E文,做一下翻譯并且提取一些重要的思路。

1.定義業務規格

What are your most critical business processes and how often are they processed (e.g. number of sales activities per day, number of client requests per day, etc.)

最重要的業務流程是什麼,使用頻率如何

What is regarded (required) as acceptable response times from the online application? How about reports?

可以接受的線上應用程式的響應時間是多少,報告又如何

How much data must be kept available on the live database (over 1 month, 1 year, 5 years?). Can data be archived? How and when?

資料在live資料庫中要儲存多久,可不可以歸檔,如何歸檔,什麼時候歸檔

How many concurrent application users are expected?

并發的使用者數是多少

Are there periods of more than average usage? (E.g. Daily between 9:00 A.M. and 10:00 A.M. /yearly ’round about Christmas.) What business processes will be impacted the most?

業務的高峰期在什麼時候,那些流程會被影響

How much data latency is acceptable for reports?

報表資料延遲,多少時間内可以接受

Etc.

等等

2.分析業務

How many inserts/updates/deletes/selects will be performed on the most important database objects when the database is averagely stressed? How much when there is a period of more than average usage?

在平均負載的情況下,在重要的資料庫對象中,有多少insert,delete,select會發生。在業務高峰期有是多少

How large will your database core objects become (over 1 month, 1 year, 5 years)?

若幹時間後,資料庫的核心對象會變得多大?

How many concurrent database users are expected? (This is not equal to application users if connection pooling is implemented.)

資料庫的并發量是多大

What should be regarded as acceptable database response times? For online requests/for reporting requests?

可以接受的資料庫響應時間是多少

3.定義磁盤子系統的需求

可以使用sqlio 來測試 磁盤子系統

也可以使用SQLIOStress

如何達到标準文章并沒有提及,可以根據業務繁忙時段,io的吞吐量也确定,多少才能滿足要求

4.為準備腳本

Ask a business user to perform a realistic work process as he would in real life situation, including realistic intervals between tasks.

咨詢終端使用者實際工作流程,真實的工作狀況,包括任務之間的時間間隔

Trace this activity using SQLProfiler (only <b>textdata</b> and <b>starttime</b> are important)

使用SQLProfiler跟蹤操作

Replace variables with placeholders for parameters that can be defined at random. (This is where you wanted all database interactions to be performed using stored procedures.)

使用随機數來代替使用者操作的變量

Add think times to the script.

增加延遲

相關的操作作者給出了代碼,可以參考原文

5.添加虛拟使用者

6.添加測試資料

可以使用DTS或者SSIS初始化資料

7.監控

8.疊代測試

  It is important to run multiple iterations using different parameter combinations but you also need to perform multiple iterations of the same scenario to avoid accidental external impact.

  使用不同的參數組合疊代測試十分重要,你也需要執行在同一個場景下執行疊代測試來避免意外情況的影響。