简体   繁体   中英

How to Stress Test Sql Server Performance vs Number Requests per Second

I want to do a stress test of my sql server by calling the server by a simple query in a loop. I want to run this procedure in parallel. Say I have x clients calling the server in loop for 10000 times, I will measure y seconds until the last query finishes. I will measure how y and x behaves.

Does this test make sense?

I only have one PC and one dev database server. How can run the queries in a multithreading context -- knowing the sql server has connection pool and will cache my query, is there anything that I need to keep in mind?

You cannot do that using a simple query as it cache the data (as you mentioned)

You need to use different queries which take time (at least a couple of seconds to a couple of minutes). Also your query should read large amount of data and return large/small amount of data to client.

My suggestions is do it this way:

  1. Create a table with 2 columns (id int, query nvarchar(max)) . populate your table with different queries, simple to complicated, fast to time consuming. You may need hundred or thousands of different queries.
  2. Write a multi-thread program that each thread randomly reads queries from different rows and execute it. you may need hundred or thousands of threads querying the database.
  3. If your database is OLTP, and users update/insert data along with reading data, you need to have update/insert statements too.

Note : You should have SQL Server on a different machine than your program, otherwise your test is not very valid, because in real world, data transfers over a network.

Please "Mark as Answer" if a post has answered the question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM