让Apache将它传递给Django的前阅读所有发布的数据 [英] Make apache read all posted data before passing it on to Django

查看:110
本文介绍了让Apache将它传递给Django的前阅读所有发布的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装Linux服务器与Apache和mod_wsgi的。从我的Apache配置:

I have setup a Linux server with Apache and mod_wsgi. From my Apache configuration:

WSGIDaemonProcess myapp processes=1 threads=10

下面的myapp是一个Django的web应用。当的myapp来自Apache的一个Django的Htt prequest对象收到大量HTTP POST请求,访问发布的数据拳头时需要的时钟时间几秒钟。我想这是因为myApp为POST的全身是从网络读取前和访问中的Htt prequest对象块发布的数据,直到发布的数据读取。调用

Here myapp is a Django webapp. When myapp receives a large http POST request from Apache in a Django HttpRequest object, accessing the posted data the fist time takes several seconds of wallclock time. I assume this is because myapp is invoked before the full body of the POST is read from the network and that accessing the posted data in the HttpRequest object blocks until the posted data is read.

有没有办法不具有的myapp援引直到阿帕奇已经阅读所有发布的数据?

Is there a way to not have myapp invoked until Apache has read all the posted data?

请问因为我想调线程到什么是最优化的用于MyApp的并行处理数(在这种情况下,10)。所以,我不想花时间在这些要求上只是在等待从网络接收发布的数据。

I ask because I want to tune the number of threads (in this case 10) to what is most optimal for concurrent processing in myapp. Therefore, I do not want to spend time in these requests on just waiting on receiving posted data from the network.

我知道我可能会增加线程数超过10个,并实施另一种机制,以确保在10线程同时处理。

I am aware that I could potentially increase the number of threads to more than 10 and implement another mechanism to ensure that at most 10 threads are processing concurrently.

推荐答案

多大大?

如果这是非常大的,那么你就有可能吹出来的内存使用情况,如果出了什么pre甚至交给它关闭到Web应用程序之前,阅读这一切到内存中。无论如何,没有在阿帕奇/ mod_wsgi的没有办法做这样的pre读。

If it is very large, then you risk blowing out memory usage if something were to pre read it all into memory before even handing it off to the web application. Anyway, there is no means in Apache/mod_wsgi to do such a pre read.

使用nginx的作为阿帕奇/ mod_wsgi的前代理可以帮助从慢HTTP客户端隔离了Apache,但在此之前代理的请求内容大小可达1MB nginx的只有pre读取。允许$​​ P $ P阅读和缓冲的大的请求内容大小,然后你必须提到担心内存的使用。

Using nginx as a proxy in front of Apache/mod_wsgi can help to isolate Apache from slow HTTP clients, but nginx only pre reads before proxying for request content sizes up to 1MB. Allow pre reading and buffering on large request content sizes and then you have to worry about memory usage as mentioned.

你应该做的或许是那些卸载特定的URL nginx的一个带有上传管理器来处理。例如:

What you should perhaps do is offload those specific URLs to nginx to handle with an upload manager. For example:

  • http://www.grid.net.ru/nginx/upload.en.html

这篇关于让Apache将它传递给Django的前阅读所有发布的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆