简体   繁体   English

如何压力测试Sql Server性能与每秒请求数

[英]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. 我想通过循环中的一个简单查询调用服务器来对我的sql服务器进行压力测试。 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. 假设我有x个客户端在循环中调用服务器10000次,我将测量y秒,直到最后一个查询完成。 I will measure how y and x behaves. 我将测量y和x的行为。

Does this test make sense? 这个测试有意义吗?

I only have one PC and one dev database server. 我只有一台PC和一台dev数据库服务器。 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? 如何在多线程上下文中运行查询-知道sql服务器具有连接池并可以缓存我的查询,我有什么需要记住的吗?

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)) . 创建一个包含2列的表(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. 您可能需要数百或数千个different查询。
  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. 如果您的数据库是OLTP,并且用户在读取数据的同时更新/插入了数据,那么您也需要具有更新/插入语句。

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. 注意 :您应该将SQL Server与程序放在不同的计算机上,否则测试不是很有效,因为在现实世界中,数据是通过网络传输的。

Please "Mark as Answer" if a post has answered the question 如果帖子回答了问题,请“标记为答案”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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