符号链接 - 性能命中? [英] Symlinks - performance hit?

查看:172
本文介绍了符号链接 - 性能命中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关部署的原因,它是稍微容易,我使用的符号链接,但这些将是其将要访问的数千次10的我所有的网站的核心文件和配置的日子。

For deployment reasons, it is slightly easier for me to use symlinks, but these would be for all of my websites core files and configurations which will be accessed 10’s of thousands of times a day.

我是更明智的移动文件到正确的位置服务器(略更成问题的部署),而不是使用符号链接的一切对(轻微的性能下降?)

Am I more sensible to move the documents to the correct positions on the server (slightly more problematic deployment) rather than using symlinks for everything (slight performance degradation?)

推荐答案

我创建了一个文件 TESTFILE.TXT 1000行 blablabla 在里面,并创建了一个本地的符号链接( testfile.link.txt )它:

I have created a file testfile.txt with 1000 lines of blablabla in it, and created a local symlink (testfile.link.txt) to it:

$ ls -n
total 12
lrwxrwxrwx 1 1000 1000    12 2012-09-26 14:09 testfile.link.txt -> testfile.txt
-rw-r--r-- 1 1000 1000 10000 2012-09-26 14:08 testfile.txt

(即 -n 开关只是没有隐藏我的超级秘密的用户名:))

(The -n switch is only there to hide my super-secret username.:))

,然后执行10轮 ING进入的/ dev / null的 1000次,这两个文件。
(结果以秒。)

And then executed 10 rounds of cating into /dev/null 1000 times for both files. (Results are in seconds.)

直接访问文件:

$ for j in `seq 1 10`; do ( time -p ( for i in `seq 1 1000`; do cat testfile.txt >/dev/null; done ) ) 2>&1 | grep 'real'; done
real 2.32
real 2.33
real 2.33
real 2.33
real 2.33
real 2.32
real 2.32
real 2.33
real 2.32
real 2.33

通过符号链接访问:

Accessing through symlink:

$ for j in `seq 1 10`; do ( time -p ( for i in `seq 1 1000`; do cat testfile.link.txt >/dev/null; done ) ) 2>&1 | grep 'real'; done
real 2.30
real 2.31
real 2.36
real 2.32
real 2.32
real 2.31
real 2.31
real 2.31
real 2.32
real 2.32

测定的(一个相当老装)Ubuntu的:

Measured on (a rather old install of) Ubuntu:

$ uname -srvm
Linux 2.6.32-43-generic #97-Ubuntu SMP Wed Sep 5 16:43:09 UTC 2012 i686

当然,这是一种简单化向下的例子,但在此基础上通过使用符号连接时,我不会期望太大的性能下降。

Of course it's a dumbed-down example, but based on this I wouldn't expect too much of a performance degradation when using symlinks.

我个人认为,这使用符号连接是比较实用的:

I personally think, that using symlinks is more practical:


  • 正如你所说,你的部署过程会更简单。

  • 您也可以轻松使用版本控制和回滚,如果你有一些目录中的名称时间戳或版本号(如 my_web_files.v1 my_web_files.v2 ),并指向现场版符号链接(如 my_web_files )使用了官方的名字。如果你想改变的版本,只需重新链接到另一版本的目录。

  • As you said, your deployment process will be simpler.
  • You can also easily use versioning and roll-back if you include some kind of timestamp or version number in the directory names (e.g. my_web_files.v1, my_web_files.v2), and use the "official" name in the symlink (e.g. my_web_files) pointing to the "live" version. If you want to change the version, just re-link to another versioned directory.

这篇关于符号链接 - 性能命中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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