简体   繁体   English

使用Node.js的大量Inode

[英]Lots of Inodes with Node.js

It is a question related to programming but more on the server administration side. 这是一个与编程有关的问题,但更多的是服务器管理方面的问题。

I have a server with 256K INodes available (which should be enough) but, on the other side, I have 5 projects running on this server with a lots of node dependencies (and lots of nested dependencies). 我有一台具有256K INode的服务器(应该足够了),但另一方面,我在该服务器上运行了5个项目,这些项目具有大量的节点依赖性(以及大量的嵌套依赖性)。 With the npm install of these 5 projects, I use 70% of all available inodes (176215 of 251844 to be precise). 通过这5个项目的npm install ,我使用了所有可用inode的70%(准确地说是251844的176215)。

My question is: 我的问题是:

Is there a way to compress the node deps? 有没有办法压缩节点深度? To have more data per file but less files? 要每个文件有更多数据但文件更少?

Thanks 谢谢

I do not know of an automatic way of reducing the number of files in node_modules (which is where npm stores its dependencies.) However, I can think of some options to reduce the inode use. 我不知道一种自动减少node_modules中文件数量的方法(npm存储依赖关系的位置。)但是,我可以想到一些减少inode使用的选项。

1) If there are shared dependencies (of the same version-number) between these projects, you can symlink some dependencies from one project into the other. 1)如果这些项目之间存在共享的依赖关系(版本号相同),则可以将某些依赖关系从一个项目符号链接到另一个项目。 If you get a dependency with lots of nested dependencies, this can really save quite a few inodes. 如果您获得了具有大量嵌套依赖关系的依赖关系,那么实际上可以节省很多inode。 (untested) (另)

2) Another alternative, if there are lots of shared dependencies, would be to copy the node_modules of project 1 to project 2 with cp -l. 2)如果存在很多共享依赖项,则另一种选择是使用cp -l将项目1的node_modules复制到项目2。 In this case each copy would be a hardlink to the same file, not using any additional inodes. 在这种情况下,每个副本将是到同一文件的硬链接,而不使用任何其他inode。 After that, run npm install && npm prune in project 2 to download any changes / additional dependencies. 之后,在项目2中运行npm install && npm prune以下载所有更改/其他依赖项。 (also untested) (也未经测试)

3) However, both options are hacky, and might or might not give you hard-to-debug problems later, after copy-ing, after restoring a backup, etc. The real solution would be to re-create the filesystem with more inodes. 3)但是,这两个选项都是很棘手的,在复制之后,还原备份之后等以后,可能会或可能不会给您带来难以调试的问题。真正的解决方案是使用更多inode重新创建文件系统。 。 For ext4, this can be done with mkfs.ext4 -i . 对于ext4,可以使用mkfs.ext4 -i完成。 See https://unix.stackexchange.com/questions/26598/how-can-i-increase-the-number-of-inodes-in-an-ext4-filesystem . 参见https://unix.stackexchange.com/questions/26598/how-can-i-increase-the-number-of-inodes-in-an-ext4-filesystem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM