简体   繁体   English

发送请求和接收响应时如何优化Web服务中的时间?

[英]how to optimize time in webservice while sending request and receiving response?

I m working with some web services where im requesting for web service around 4000 times in loop each time im getting some data from web service, that is working fine...but the problem is that it's taking time...obviously 4000 times cost a time, but is there any way that we can optimize the time with this? 我正在使用某些Web服务,每次从Web服务获取一些数据时,我都会请求约4000次循环的Web服务,这很好,但是...问题是这需要时间...显然是4000倍的成本时间,但是有什么方法可以优化时间呢? thanks. 谢谢。

Actually .. i have 3 dropdownlistbox. 其实..我有3 dropdownlistbox。 first dropdownlistbox is about to country , second one is about to cities of that selected country. 第一个dropdownlistbox将针对该国家/地区,第二个dropdownlistbox将针对该所选国家/地区的城市。 and third one is all cities of world. 第三是世界所有城市。 third dropdownlistbox is around 4413 cities from all over the world. 第三个下拉列表框来自世界各地的4413个城市。

why am i using this? 我为什么要使用这个? because in . 因为在。 this web services is for taking data for airport countries. 该Web服务用于获取机场国家的数据。

first. 第一。 user select contry in first dropdownlistbox so. 用户在第一个下拉列表框中选择“ contry”。 its postback and fill the second one using webservices request and response. 它的回发,并使用webservices请求和响应填充第二个。 by cities name of that selected country. 根据所选国家/地区的城市名称。

now. 现在。 select country from second dropdownlistbox, which place is my start point. 从第二个下拉列表框中选择国家,这是我的起点。

and now i am matching that country's airport flight services to other cities and list all that cities name into third dropdownlistbox which is connecting with that country. 现在,我将该国家的机场航班服务与其他城市进行匹配,并将所有城市的名称列出到与该国家连接的第三个dropdownlistbox中。

now. 现在。 this all data which i filled in dropdownlistbox is .. using webservices. 这是我在dropdownlistbox中填写的所有数据..使用网络服务。 request and respones.. 请求和响应

now problem is that. 现在的问题是。 in world there are 4414 cities. 世界上有4414个城市。 so. 所以。 i matched that one city with all this cities. 我将一个城市与所有这些城市相匹配。 so. 所以。 request is increasing and response taking so much time. 要求不断增加,响应花费了很多时间。

so help me get out of this problem. 所以帮我摆脱这个问题。

tell me any method that i used for reducing this time. 告诉我我用来减少时间的任何方法。 i am doing some coding. 我正在做一些编码。 which is right. 哪个是对的。 but because of this problem . 但是因为这个问题。 its taking so much time in response. 它花了很多时间来回应。 so .tell me any method .which i used to reduce time. 所以告诉我我用来减少时间的任何方法。

thanks. 谢谢。

缓存城市列表,一周之内不会更改。

If you have access to the webservice (= you're the developer of it) and the client using it, you should optimize it (or make an extra function) so that you can put all the data from the 4000 queries into one call to avoid the connection/call overhead. 如果您有权访问Web服务(=您是它的开发者)并且使用它的客户端,则应该对其进行优化(或进行额外的功能),以便可以将4000个查询中的所有数据放入一个调用中避免连接/通话开销。

If the webservice is not yours, you should see if the server supports keep alive as this would you allow you to send several HTTP requests on the same connection, without reconnecting each time. 如果不是您的Web服务,则应查看服务器是否支持keep alive因为这将允许您在同一连接上发送多个HTTP请求,而无需每次都重新连接。

Both of these assume that you are calling the same method with different values on the same server. 这两个都假定您在同一服务器上调用具有不同值的相同方法。

I'm not sure I fully understand your scenario. 我不确定我是否完全了解您的情况。 However you should simply cache the airport / city lists in your app. 但是,您应该只在应用程序中缓存机场/城市列表。 You can update the cache every day or something to make sure it's fresh. 您可以每天更新缓存或进行某些更新以确保它是最新的。

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

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