Data Driven Load Tests using Visual Studio Online and SQL Azure Microsoft Dev. Ops Blog. Data Driven Load Tests using Visual Studio Online and SQL Azure. Editors Note While working in Australia I was blessed to work with some truly gifted technologists. In the SQL space David Lean was the local legend with the deserved reputation of being THE SQL Performance Guru. David has since left Microsoft but continue his cutting edge work with SQL Server and Application Tuning. Thanks for the great post on using SQL Azure and performance Testing David Chuck Data Driven Load Tests using Visual Studio Online and SQL Azure. Almost everyone who IT Operations for a large company can tell you war stories about apps whose performance died within 1. Many dont even last 6 mths. Nearly everyone in corporate IT can tell you war stories about some application whose performance died within 6 1. Why do they blow up More often than not, the root cause is inadequate stress testing, with inadequate data. Either not enough data, or data whose distribution didnt represent real world. Including errors. So why dont we do more testing Often it is because of the cost. Consider the costs of HW just for load generation, Data Center Floor space, Insurance, Testing SW, people. It is easy to burn more than 1 mill just trying to prove a new system can scale to the needs of the business. So we try to make do. Without those resources, design decisions are often made by a single developer based on timing loops on their desktop. Benefits problems of caching will rarely be seen if you only test with one user. Same goes for inefficient database queries poor architecture. Without load, it is impossible to answer the hard questions like. The AsyncAwait is great for IO bound applications, but it adds overhead. Given that IISs application pool is designed to handle blocking threads. Would I get better perf by merely increasing the IIS thread pools Max Concurrent parametersIf my Web Servers are suffering Thread Starvation due to the synchronous calls blocking on the database. Will rewriting them as Async improve the situation or merely exacerbate the issue by the RDBMS to divert memory to tracking even more user requestsI thought that spraying that guy was the least damaging thing I could do, he told the Times. In my left hand I had a flashlight. My other option, other than. create schema testdata go. create table testdata. racepage id int not null identity1,1, url varchar100 not null, constraint pkid primary key. Should I just increase the IIS Max Concurrent values The good news is Microsoft has made that investment for us. For around 6 you can simulate 2. Data Driven Load Tests using Visual Studio Online. This article shows how to create LoadStress Tests for both Web Sites Web API controllers, with the potential to simulate 1. Allowing you to compare caching other techniques in order to optimise the rendering of your site. Why Data Driven In recent years ASP. NET MVC has grown in popularity. And with it, the use of dynamic routing. This has created a problem for testers. Simply recording your mouse keystrokes into a static test then replaying them, doesnt work if your URLs change frequently. If your Web Site dynamically generates its URLs based on your data, ie your product catalogue or recent news events, then you need a load test that can also dynamically generate valid URLs to click on. Fortunately Visual Studios Web Performance Tests Load Testing makes this easy. The answer is Data Driven Web Performance Tests. What if you dont have access to a dozen or more idle servers you can use to run these performance tests The answer is in the cloud. Visual Studio Online makes it possible to simulate 1,0. You can get it running in under 5 mins. There are 4 common scenarios for Data driven testing. Simulating URLs that change based on the data in your system. Filling out a form with different data for different users. Calling a Web Service with different parameters. Simulating an AJAX call. Scenario 1 Dynamic URLs. Use Case The logic in your page generates a URL based on some internal data structure. Eg In an E Commerce site each Product you sell is likely to have its own URL. For CMS System, each new article may have a unique URL. In this example we will look at the Horse Racing Industry. The Meetings page below shows all the Races. Each cell is a link to a Races Page. Each race only occurs once, so its URL contains the Meeting. Date. So each new day a new set of racing links are created. Any test you build today using static URLs will be broken tomorrow. Picture 1. Each cell in the table points to a race page. One approach is to have your test always go to the Meeting page. Then run the javascript on that page to select a valid link. The disadvantage with this approach is you tie up your test agents with meeting page processing. Which reduces the number of clients you can simulate per agent. Another approach is to pre calculate all the valid links immediately prior to the test execution put them in a data store. The Test Agent only needs to ask for a valid URL send it to the server you are testing. Part A Setup your data. We will need to create table similar to the one below. Our Test only needs the URL column. But sometimes an ID column is handy for the clean up task. Most SQL DBAs would use SQL Server Management Studio SSMA, but you dont need to install SQL Client tools. Visual Studio is just as powerful as I will demonstrate. Start Visual Studio. Click menu View SQL Server Object Explorer. Right Click SQL Server node. Click Add SQL Server 5. Enter login credentials. You should now see a SQL Object Explorer tree. Tip I put my test data in an Azure Database. It has the following benefits i. Safer than opening a port thru the corporate firewall to expose an internal SQL Server containing the Test data database. Closer to the VSO Test agents. So less latency. iii. Better upload speed than most Home Small Office LANs. Cheap, only pay for the duration of the testing then delete it. To remember your connection strings just copy it from the Azure Portal. Open a SQL Query Window. R. Click your SQL Database New Query 9. I prefer to create a Schema to hold all my load testing artifacts. Especially if they arent in a dedicated database. SCHEMA Test. Data GOCREATE TABLE Test. Data. Race. Page ID INT NOT NULL IDENTITY1,1, URL VARCHAR1. NOT NULL, CONSTRAINT PKID PRIMARY KEY CLUSTERED ID GO1. To simplify the load tests Setup Clean up Scripts, I prefer to create Stored Procedures. This keeps the logic out of my scripts closer to the data in case I need to change anything. lt Procedure for Load Tests Setup Script CREATE PROCEDURE Test. Data. pSetup. Race. Page. Data. Test Web. Site VARCHAR3. 0 http mysite. AS Swap to a new meeting date at 5pm Sydney. AEDTDECLARE Meeting. Date DATE DATEADDHOUR, 4, SYSUTCDATETIME TRUNCATE TABLE Test. Data. Race. Page INSERT INTO Test. Data. Race. PageURLSELECT Web. Site race CASTM. Meeting. Date AS CHAR1. CASTM. Track. Id AS VARCHAR5 CASTR. Race. Number AS VARCHAR2 AS URLFROM Racing. Meeting AS MJOIN Racing. Race AS R ON R. Meeting. Id M. Meeting. Id. WHERE M. Meeting. Date Meeting. Date. AND R. Race. Status. Id 1 1 Open Races Enum. GO lt Check it works EXEC Test. Data. pSetup. Race. Page. Data. Test GOSELECT TOP 2. FROM Test. Data. Race. Page GO lt Procedure for Load Tests Clean up Script CREATE PROCEDURE. Cleanup. Race. Page. Data. Test ASTRUNCATE TABLE Test. Data. Race. Page GO1. Run it Part B Connect the data to your Web Test. Select Menu File New Project Test Web Performance and Load Test Projecta. Even if you only work by yourself I suggest you add it to Source Control. It is so handy to be able to roll back any mistakes you make. Personally I prefer to use VSOs Team Foundation Server. For small teams it is free great to have a central store where your code is compiled deployed via Continuous Integration. However you will note from the picture below, Visual Studio also works fine if you prefer to use another Source control system like Subversion or GIT. The new web test automatically opens a browser, ready to start recording your test. As we plan to get our URLs from our database, we dont need to do this. Just hit stop create a blank test. R. Click Web. Test. Rename it. eg Race. Page. webtest. 1. Add a Data Source to your Web. Test. There are 3 ways to do this. Via the Toolbar b. Via the Context Menu c. Via the property menu. This should start the New Test Data Source Wizarda. Enter the name of your Data Source. Eg Test. Data. In.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2017
Categories |