简体   繁体   English

使用HttpHandler在ASP.Net网页中加载缩略图

[英]Loading Thumbnails in ASP.Net Web Page using HttpHandler

My requirement is load 100 thumbnails under 2 seconds in my Asp.Net Web Application. 我的要求是在2秒内在Asp.Net Web应用程序中加载100张缩略图。 Actual size of each images are approx.800 KB. 每个图像的实际大小约为800 KB。 So I used a web handler method to re-size the image on the fly(Here image size reduced to 8KB). 因此,我使用了一个Web处理程序方法来即时调整图像大小(此处图像大小减小为8KB)。 Here I found 96 requests are sent to the server and thumbnails are loaded under 4 seconds. 在这里,我发现96个请求被发送到服务器,并且缩略图在4秒内被加载。 I found 90% of the time is losing in blocking inspected in Firebug net tab. 我发现90%的时间都在Firebug的“网络”标签中检查的阻止中丢失了。 So I moved from 96 request to a single request. 因此,我从96个请求移至单个请求。 Thus web handler accept a single request and creates 96 thumbnail images and combine 96 thumbnails into a big single image and write this single image to the output stream.This case I found about 6 seconds was taken for loading the single image. 因此,Web处理程序接受单个请求并创建96个缩略图图像,然后将96个缩略图组合成一个大的单个图像并将该单个图像写入输出流中。这种情况下,我发现加载单个图像花费了大约6秒的时间。 Then I used a .Net Thread Pool mechanism for creating the thumbnails in the web handler.Thus load time reduced to 2.6 seconds.I found that only 1 second or below time is actually taken for the server processing.Remaining 1.6 seconds is losing. 然后我使用.Net线程池机制在Web处理程序中创建缩略图,因此加载时间减少到2.6秒,发现服务器处理实际上只花费了1秒或更少的时间,而剩下的1.6秒正在丢失。 My Questions are below 我的问题如下

  1. Where is losing my processing time. 哪里浪费了我的处理时间。 Server side or client side? 服务器端还是客户端? If it is in server side where is the bottle neck? 如果在服务器端,瓶颈在哪里? How can I identify the request processing and page load time? 如何确定请求处理和页面加载时间?

  2. Is Web handler a better way to do the image resizing? Web处理程序是调整图像大小的更好方法吗?

  3. Can I have any alternative solution.? 我可以有其他替代解决方案吗?

My System Config is 我的系统配置是

Processor - Intel Core - i7 , RAM: - 4 GB 处理器-Intel Core-i7,RAM:-4 GB

Web Server: IIS 7 Web服务器:IIS 7

OS : Windows 7 作业系统:Windows 7

Please help me 请帮我

> Where is losing my processing time. >在哪里浪费我的处理时间。 Server side or client side? 服务器端还是客户端?

Maybe its in between... 1.6 seconds sounds about right for transferring the data: 也许介于两者之间...传输数据的正确时间为1.6秒:

8KB per image * 100 images ~= 1MB of data
1 M bytes = 8 M bits
8 M bits / 1.6 secs = 5 Mbps transfer rate
... sounds reasonable to within an order of magnitude

Your one-big-image approach is probably better, as this will reduce the overhead of 100 separate requests. 您的单映像方法可能更好,因为这将减少100个单独请求的开销。 Beware of using background threads in the ASP.NET process, though. 但是,请注意在ASP.NET进程中使用后台线程。

The transfer time is one limiting factor. 传输时间是一个限制因素。 Even if you could make the server respond immediately, you would still have to wait for the data to get back to the client. 即使您可以使服务器立即做出响应,您仍然必须等待数据返回到客户端。

The other limiting factor is the speed that the client browser can render the images. 另一个限制因素是客户端浏览器可以渲染图像的速度。

Basically, your requirements are pushing the boundaries of what is practical ATM. 基本上,您的要求正在突破实际ATM的界限。

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

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