首页 > nginx > 优化nginx+fastcgi上传

优化nginx+fastcgi上传

2010年8月6日 eric 发表评论 阅读评论

由于公司网站的项目要用到用户上传20M左右的文件,经过测试发现,上传的时候php-fpm单个进程占用CPU利用率大而长,上传速度也不是很理想,如果是多个人上传,效果就会更糟糕。在看nginx官网网站的时候。看到nginx支持POST,原理是这样的,POST到nginx的产生一个临时文件,nginx接受到数据在转移到FastCGI,这样多了一次复制过程和内存开销,比较浪费。但是对于上传大文件来说速度有明显改善。但是光nginx支持不够,还需要php-fpm的支持。

添加这个功能需要修改nginx配置文件:

http
{
.......
添加如下:
client_body_in_file_only clean;
client_body_temp_path /dev/shm 1 2;
fastcgi_param  REQUEST_BODY_FILE  $request_body_file;
...
}

最好使用内存文件系统 /dev/shm 这样减少对磁盘的读写,减少了 磁盘 I/O,这样大大的优化了NGINX上传速度。

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/221.html

分类: nginx 标签: , ,
  1. 2018年11月17日18:47 | #1

    Ridiculous quest there. What happened after?

    Good luck!

  2. 2018年11月18日00:55 | #2

    I know this web site provides quality depending content and additional data, is there any other website which provides these kinds of data in quality?

  3. 2018年11月18日20:05 | #3

    Hola! I’ve been following your web site for a long time now and
    finally got the bravery to go ahead and give you a shout out from
    Huffman Texas! Just wanted to mention keep
    up the excellent job!

  4. 2018年11月18日23:30 | #4

    Hey! Do you use Twitter? I’d like to follow you if that would
    be okay. I’m undoubtedly enjoying your blog and look forward to new
    posts.

  5. 2018年11月19日00:31 | #5

    This piece of writing is genuinely a pleasant one it assists new internet users, who are
    wishing in favor of blogging.

  6. 2018年11月19日10:55 | #6

    If you are going for finest contents like I do, only go to
    see this web site all the time because it presents feature contents,
    thanks

  7. 2018年11月19日12:03 | #7

    Hi there! Quick question that’s completely off topic.
    Do you know how to make your site mobile friendly? My site looks weird when viewing from my iphone4.
    I’m trying to find a theme or plugin that might be able to
    resolve this problem. If you have any recommendations,
    please share. Cheers!

  8. 2018年11月19日12:24 | #8

    It’s actually a great and helpful piece of information. I am happy that you
    simply shared this helpful information with us.
    Please keep us up to date like this. Thank you for sharing.

  9. 2018年11月20日01:03 | #9

    I really like your blog.. very nice colors & theme. Did you design this
    website yourself or did you hire someone to do it
    for you? Plz respond as I’m looking to create my own blog
    and would like to find out where u got this from.
    thank you

  10. 2018年11月20日03:40 | #10

    I really like looking through a post that can make people
    think. Also, thank you for allowing me to comment!

  11. 2018年11月20日05:38 | #11

    viagra cheap india
    viagra without a doctor prescription walmart
    viagra online fedex
    [url=http://viagrawithouatdoctor.com/#]viagra without a doctor prescription walmart[/url]
    viagra generico envio rapido

  12. 2018年11月20日15:51 | #12

    can get nhs prescription viagra
    100mg viagra without a doctor prescription
    safe place get generic viagra
    [url=http://viagrawithouatdoctor.com/#]viagra without a doctor prescription walmart[/url]
    prozac viagra together

  13. 2018年11月21日01:56 | #13

    I was able to find good advice from your blog articles.

  14. 2018年11月21日21:42 | #14

    Keep this going please, great job!

  15. 2018年11月22日14:11 | #15

    Spot on with this write-up, I seriously feel this web site needs much
    more attention. I’ll probably be back again to read through
    more, thanks for the info!

  16. 2018年11月23日02:05 | #16

    Hello, i read your blog from time to time and i own a similar one and i was just wondering if you
    get a lot of spam comments? If so how do you stop it, any plugin or anything you can recommend?

    I get so much lately it’s driving me mad so any assistance is very much appreciated.

  17. 2018年11月28日14:55 | #17

    casino online subtitrat
    casino online subtitrat
    casino online application
    online casinos 2016

  18. 2018年12月2日01:15 | #18
  19. 2018年12月2日21:46 | #19

    best us casinos online
    casino games roulette
    vegas casino games
    new usa online casinos 2017

  20. 2018年12月3日08:42 | #20

    casino games list
    casino games free
    play casinos
    new usa online casinos

  21. 2018年12月3日23:01 | #21

    top rated free online casino games
    casinos online
    casino online free
    new usa online casinos

  22. 2018年12月5日02:29 | #22

    Hello! This is kind of off topic but I need some guidance from an established blog.
    Is it tough to set up your own blog? I’m not very techincal but I can figure things out pretty fast.

    I’m thinking about making my own but I’m not sure
    where to begin. Do you have any ideas or suggestions?
    Thanks

  23. 2018年12月6日02:34 | #23
  24. 2018年12月6日22:14 | #24

    I loved as much as you’ll receive carried out right here.

    The sketch is tasteful, your authored subject matter stylish.
    nonetheless, you command get bought an edginess over that you
    wish be delivering the following. unwell unquestionably come more formerly again since exactly
    the same nearly very often inside case you shield this hike.

  25. 2018年12月7日01:53 | #25

    Thank you for any other informative website.
    Where else may I am getting that kind of info
    written in such a perfect means? I’ve a challenge that I’m just now running on, and I’ve been at the glance out for such info.

  26. 2018年12月10日03:22 | #26
评论分页
1 ... 4 5 6 221
订阅评论
3+8= (必填)