开发者

ASP.Net Web Services Response Time Slow

We are using ASP.Net Web services.

The architecture is Desktop Based Application developed in .Net 3.5 - Client App (Client Machine) ASP.Net Based Web Service in .Net 3.5 - Business Logic Layer (IIS on Server) SQL 2005 Database - Database Layer (Same or different server then IIS)

The application is almost developed and it is going in for first implementation. On day 1 we have faced a show stopper issue. We have loaded database of patient's with 30000 records and the response time of patient search screen is more then 20 seconds. We have indexed the database and removed all unncessary calls a. fr开发者_运维技巧om client to web service b. from web service to database. Still the response time is 7 seconds which is not acceptable it has to got down under 3 seconds. The main problem we see is 4 seconds are being taken as a part in which the web service returns the data of such size over network to client.

What is the solution to this?


If your search queries return large result sets, you could consider adding paging functionality to the webservice calls.

It seems unlikely that a user will review 250 (or an arbitrary number > 10) patients at a single glance. So instead of a method that returns all 250, you could return them in in sets of 10. You'll have to change the signature your web methods a bit though.

This would reduce the network payload.

You could cache the search results on the server, to avoid running expensive queries too often.

This could be part of a solution but there will probably be many other options!

Good luck!


make sure your queries can use the indexes. The easiest way to index a table in SQL Server is to use Sql Server Tuning Wizard. Another way to diagnose the problem is to add a Ping method on the service. This will give you the ability to check the network latency. You can also cache common records using Cache object. 30000 row for sql server is less than drop of water for the whole ocean :)


Make sure you are only returning data that is actually useful to the client. It's too easy with web services to just return large datasets exactly as they are sitting in the database. If speed really is a high priority, you should do as much as you can to trim down the amount of information being returned back to the client machine to only that which is immediately necessary for whatever action you are taking.

You could set up some proxy/datacontract objects that are passed through the web service that only contain information specific to the web service call being made. A simple example would be only returning a a person's name, instead of returning their name, address, phone number, etc.


If your problem is indeed the amount of data being sent over the network. You have few options other than reducing the amount of data. As Scotty would say "Capin, I cannah change the laws of phsyics" right before he would change the laws of physics ;)

It takes x amount of time to transfer y bytes of data over z speed data link.

How you reduce that data depends greatly on your situation. You can use compression, which may or may not gain you anything depending on the makeup of the data, but being largely XML based you should get a fairly good improvement from that.

You can also transfer a smaller number of records at a time, or use lazy loading to load subsets of data only upon demand.

Of course, if you're transfering an entire table when you only need 3 fields, that can greatly increase the size of your data as well. Make sure you're only transfering the data you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜