简体   繁体   English

在ASP.NET应用程序中处理大型并发HTTP POST

[英]Handling large concurrent HTTP POSTs in ASP.NET application

A client page uses javascript to post multipart form data (files) to my ASP.NET site (ashx handler). 客户端页面使用javascript将多部分表单数据(文件)发布到我的ASP.NET站点(ashx处理程序)。

User selects several files and start a concurrent upload. 用户选择多个文件并开始并发上传。 When files are like 150MB+, this generates several concurrent POST handlers of the ASP.NET server side. 当文件类似于150MB +时,这将生成ASP.NET服务器端的多个并发POST处理程序。

I have the session control implemented, along with captcha functionality to exactly know if it is not a bot flooding my server. 我实现了会话控制,以及验证码功能,以确切知道它是不是泛滥我的服务器的机器人。

But the problem is with the initial upload start. 但问题是初始上传开始。

Each time a handler is to process a POST , it checks an ID of the session (my custom session, one per user page), and adds the Request.ContentLength size to the total size of files POST ed per session. 每次处理程序处理POST ,它都会检查会话的ID(我的自定义会话,每个用户页面一个),并将Request.ContentLength大小添加到每个会话POST的文件总大小。 This data is saved to an XML. 此数据将保存到XML。

But since several initial posts occur simultaneously, an XML writer that records the sum of bytes "chokes" and reports 0 bytes per session for all initial POST s, since they come in at the same time. 但由于几个初始帖子同时发生,一个XML编写器记录字节总和“chokes”并报告所有初始POST的每个会话0字节,因为它们同时进入。

I've implemented lock on my persister object (that does XML-writing), but now until one POST is totally processed, others can't go on. 我已经对我的persister对象(执行XML编写)实现了lock ,但现在直到一个POST完全处理完毕,其他人无法继续。

Also even though I don't do anything with the requests that come in "after the upload limit", they still take time to upload the data to the server. 即使我对“上传限制之后”的请求没有做任何事情,他们仍然需要时间将数据上传到服务器。

So my questions are: 所以我的问题是:

What is the correct pattern to process several concurrent POST uploads? 处理多个并发POST上传的正确模式是什么?

Is there a way to immediately drop POST as soon as the request is filtered in ASP.NET handler code, and save the client an effort of uploading the data to IIS? 有没有办法在ASP.NET处理程序代码中过滤请求后立即删除POST,并保存客户端将数据上传到IIS的工作量?

UPDATE: When lock ing only on XML writing/max session length calculation I still have the concurrency, which is good. 更新:当仅lock XML写入/最大会话长度计算时,我仍然具有并发性,这是好的。 Now I only need to figure out how to drop session immediately from ashx handler code. 现在我只需要弄清楚如何立即从ashx处理程序代码中删除会话。

Is your ashx handler written to execute asynchronously? 您的ashx处理程序是否写入异步执行? If not, this a great article for implementing async ashx handlers: 如果没有,这是一篇用于实现异步ashx处理程序的好文章:

http://msdn.microsoft.com/en-us/magazine/cc163463.aspx http://msdn.microsoft.com/en-us/magazine/cc163463.aspx

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

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