最好的文件系统使用nginx服务1GB文件,在中等写入,阅读性能明智? [英] Best file system for serving 1GB files using nginx, under moderate write, read performance-wise?

查看:251
本文介绍了最好的文件系统使用nginx服务1GB文件,在中等写入,阅读性能明智?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要构建大文件服务器,并且需要堆栈溢出社区对文件系统选择(linux)的建议。

通过Nginx,文件服务器将持续适度地向磁盘写入数据(1-2个大小的静态文件(通常与每个请求不同)(RAID5 SATA / 7200磁盘巨大的)。写入读取比率约为1:5-10,每写入1个字节每秒,读取5-10个。
对我来说最重要的是读取性能,我可以忍受较慢的写入。

什么Linux文件系统将是这个任务的最佳解决方案?我为每个实际磁盘(主轴)实现了80MB / s的随机读取性能, 。
这是我的发现。所以,首先要确定需要向用户推送多少流量以及每台服务器需要多少存储空间。



您可以跳过下面给出的磁盘设置建议,因为您已经安装了RAID5。


让我们举一个带有3 * 2TB磁盘的专用1Gbps带宽服务器的例子。
保留专用于OS和tmp的第一个磁盘。对于其他2个磁盘,你可以创建一个软件RAID(对我来说,它比板载硬件RAID更好)。否则,您需要将您的文件平分在独立的磁盘上。想法是保持两个磁盘共享读/写负载平等。软件raid-0是最好的选择。

Nginx Conf
有两种方法可以实现使用nginx的高性能。


  1. use directio

    aio on;

    directio 512;
    output_buffers 1 8m;

    这个选项需要你有大量内存
    需要大约12-16GB的内存。 / b>

  2. userland io

    output_buffers 1 2m;

    确保你已经将软件RAID安装设置为4-6MB
    blockdev --trace 4096 / dev / md0(或者独立的磁盘安装)



    此设置将会最佳地使用系统文件缓存,并且需要更少的内存。
    需要8GB左右的RAM。




  3. 常见注释:


    • 保留sendfile off;


      lockquote

      也可能希望使用带宽限制来在可用带宽上启用100个连接。每个下载连接将使用4MB的活动内存。




        limit_rate_after 2m; 
      limit_rate 100k;

      以上两种解决方案都可轻松扩展到3个磁盘服务器上的1k +同时用户。
      假设您拥有1Gbps的带宽,每个连接以1Mb / ps的速度进行节流
      在不影响读取的情况下优化磁盘写入还需要进行额外的设置



      所有上传到主要的操作系统磁盘在一个安装说/ tmpuploads。这将确保没有间歇性的干扰,而繁重的阅读正在进行。然后使用dd命令将文件从/ tmpuploads移动到withlag = direct。就像

        dd if = / tmpuploads /< myfile>的= / raidmount /上传/< MYFILE> oflag = direct bs = 8196k 


      I'm going to build large files server, and need stack-overflow community advice for file system choice (linux).

      File server is going to serve 1-2GB sized static files (mostly different with every request) via Nginx, under constant moderate write to the disks (RAID5 SATA/7200 disks massive). Write to read ratio is about 1:5-10, for every 1 byte written per second, 5-10 are read. Most important for me is read performance, I can live with slower writes.

      What Linux file system would be the best solution for this task? And why :) Thanks!

      解决方案

      I achieved 80MB/s of "random read" performance per "real" disk (spindle). Here are my findings.

      So, first decide how much traffic you need to push down to users and how much storage you need per server.

      You may skip the disk setup advice given below since you already have a RAID5 setup.

      Lets take an example of a dedicated 1Gbps bandwidth server with 3 * 2TB disks. Keep first disk dedicated to OS and tmp. For other 2 disks you may create a software raid (For me, it worked better than on-board hardware raid). Else, you need to divide your files equally on independent disks. Idea is to keep both disk share read/write load equally. Software raid-0 is best option.

      Nginx Conf There are two ways to achieve high level of performance using nginx.

      1. use directio

        aio on;
        directio 512; output_buffers 1 8m;

        "This option will require you to have good amount of ram" Around 12-16GB of ram is needed.

      2. userland io

        output_buffers 1 2m;

        "make sure you have set readahead to 4-6MB for software raid mount" blockdev --setra 4096 /dev/md0 (or independent disk mount)

        This setting will optimally use system file cache, and require much less ram. Around 8GB of ram is needed.

      Common Notes:

      • keep "sendfile off;"

      you may also like to use bandwidth throttle to enable 100s of connections over available bandwidth. Each download connection will use 4MB of active ram.

              limit_rate_after 2m;
              limit_rate 100k;
      

      Both of above solution will scale easily to 1k+ simultaneous user on a 3 disk server. Assuming you have 1Gbps bandwidth and each connection is throttled at 1Mb/ps There is additional setup needed to optimize disk writes without affecting reads much.

      make all Uploads to main os disk on a mount say /tmpuploads. this will ensure no intermittent disturbance while heavy reads are going on. Then move the file from /tmpuploads using "dd " command with oflag=direct. something like

      dd if=/tmpuploads/<myfile> of=/raidmount/uploads/<myfile> oflag=direct bs=8196k
      

      这篇关于最好的文件系统使用nginx服务1GB文件,在中等写入,阅读性能明智?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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