官术网_书友最值得收藏!

  • Lighttpd
  • Andre Bogus
  • 427字
  • 2021-08-25 18:06:23

Core Settings

Using this scenario as a starting point, we will enumerate the knobs to be turned. Here are some configuration settings that will make our Lighttpd serve large files faster and more reliably than the defaults. First, we make sure range requests are enabled using the following command:

# if we have disabled range requests for some reason:
server.range-requests = "enable"

We want to use the optimal network backend for sending out content. If in doubt, take a file of the size we want to serve or create (for example, we can use dd to create a 1GB file):

$ dd if=/dev/zero of=our_file bs=1024 count=10480576

Now, put this file into our document root and run an http_load test (refer to Chapter 9 for further details) with each network backend that we get to run. Then, pick the fastest network backend. Probably it is one of the following, depending on your system. Take your pick and be sure to test on our system; when in doubt, test all of them:

server.backend = "writev"             # optimal for 1.4 versions
server.backend = "posix-aio"          # the fastest for large files
server.backend = "gthread-aio"        # using threads to multiplex
server.backend = "linux-aio-sendfile" # optimized for linux

Note

Each backend uses a different strategy to optimize throughput. On POSIX-compatible systems, posix-aio is, at least for the time being, the fastest backend for large files.

In the next step, ramp up the idle write timeouts:

server.max-write-idle = 720   # double to 12 minutes.

This allows clients to keep a connection-on-hold a little longer, which they might do for any old reason (for example, their network might be down for a second), without killing their download. On the other hand, we might want to reduce the maximum keep-alive requests to free up connections sooner (because we will not have as many requests, but the ones we have will last longer):

server.max-keepalive-requests = 8 # half the requests
# if we have a different setting than the default, set
server.max-keepalive-idle = 5     # seconds

This should be all it needs to make our Lighttpd large-file friendly. Note that some of the settings may be pessimizations in other scenarios, for example, say some small requests. Therefore, we might want to limit the impact of these options to where we need them.

Note

Multiple configurations

All the above settings have a connection scope, which is that we can put them into selectors. This means that we can have some areas optimized for large content, and other areas optimized for lots of small requests, for example, AJAX applications.

主站蜘蛛池模板: 崇礼县| 穆棱市| 桃源县| 巴彦淖尔市| 普安县| 砚山县| 华蓥市| 老河口市| 红河县| 清远市| 苍溪县| 栾川县| 太仓市| 中牟县| 克什克腾旗| 顺义区| 凤庆县| 霍山县| 陇西县| 上饶市| 门头沟区| 叙永县| 高邮市| 开鲁县| 万山特区| 玉环县| 防城港市| 惠东县| 汨罗市| 文化| 湟中县| 杭州市| 芜湖市| 崇仁县| 漠河县| 太湖县| 宝兴县| 门头沟区| 鄂州市| 五寨县| 陵川县|