简体   繁体   English

响应时间WCF REST服务返回大文件时出现问题

[英]Response time Issue in WCF REST Service returning a large file

HI, 嗨,

I have created a WCF REST service with response format as JSON. 我创建了WCF REST服务,响应格式为JSON。 The basic functionality of the service is that when it is called it will return a large file(mostly zip file) from the file system to the requester. 该服务的基本功能是,在调用该服务时,它将从文件系统返回一个大文件(主要是zip文件)到请求者。 The time taken for the file to completely downloaded by the user is taking more than 20 mins for 20MB file. 用户完全下载文件所需的时间对于20MB的文件来说要花费20分钟以上的时间。

How to find the issue in the service implementation? 如何在服务实现中发现问题? Is there any config parameters to be included to accommodate large file downloads using WCF REST Service? 是否包含任何配置参数来容纳使用WCF REST服务下载的大文件? Is there tools/methods available to monitor the performance of a WCF REST service? 是否有可用的工具/方法来监视WCF REST服务的性能?

OMG, I just realized that you said you are using a JSON response format. OMG,我刚刚意识到您说您正在使用JSON响应格式。 Arrgh, you really do not want to try and serialize zip file into a JSON format. 抱歉,您真的不想尝试将zip文件序列化为JSON格式。 Change your service operation to return a stream and write the bytes directly to the stream. 更改服务操作以返回流并将字节直接写入该流。

As far as monitoring the conversation between client and server i'd recommend using Fiddler for that, also have a look at this link which speaks to transfering large data with Web Services. 至于监视客户端和服务器之间的对话,我建议为此使用Fiddler ,还请看一下该链接 ,它涉及通过Web服务传输大数据。

I'm not sure if refactoring you're code is on the table, but if it is you might consider going with a MTOM strategy. 我不确定表中是否有重构代码,但如果是这样,您可以考虑采用MTOM策略。 Here is a link to a WCF implementation. 这是 WCF实现的链接 This allows you to send/receive binary data in a chunked manner. 这使您可以分块方式发送/接收二进制数据。 This is cool because chunking the data, coupled with an AJAX UI, will allow you to present a progress bar to the user that is uploading it and will help to see what the status is for your own sanity. 这很酷,因为对数据进行分块,再加上AJAX UI,将使您可以向正在上传数据的用户显示进度条,并有助于查看状态的状态。

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

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