简体   繁体   English

Node JS 中的最大可写流

[英]Max writeable streams in Node JS

Prologue:序幕:

I'm experimenting with a "multi-tenant" flat file database system.我正在试验“多租户”平面文件数据库系统。 On application start, prior to starting the server, each flat file database (which I'm calling a journal) is converted into a large javascript object in memory.在应用程序启动时,在启动服务器之前,每个平面文件数据库(我称之为日志)都被转换为内存中的一个大型 javascript 对象。 From there the application starts it's service.从那里应用程序启动它的服务。

The application runtime behavior will be to serve requests from many different databases (one db per domain).应用程序运行时行为将服务于来自许多不同数据库(每个域一个 db)的请求。 All reads come from the in memory object alone.所有读取都来自内存对象。 While any CRUDs both modify the in memory object as well as stream it to the journal.虽然任何 CRUD 都修改内存中的对象并将其流式传输到日志。

Question: If I have a N of these database objects in memory which are already loaded from flat files (let's say averaging around 1MB each), what kind of limitations would I be dealing with by having N number of write streams?问题:如果我在内存中有 N 个已经从平面文件加载的这些数据库对象(假设每个对象平均大约 1MB),那么通过拥有 N 个写入流我会处理什么样的限制?

If you are using streams that have an open file handle behind them, then your limit for how many of them you can have open will likely be governed by the process limit on open file handles which will vary by OS and (in some cases) by how you have that OS configured.如果您使用的流背后有一个打开的文件句柄,那么您可以打开的文件句柄数量的限制可能会受到打开文件句柄的进程限制的约束,这会因操作系统和(在某些情况下)而异您如何配置该操作系统。 Each open stream also consumes some memory, both for the stream object and for read/write buffers associated with the stream.每个打开的流也消耗一些内存,用于流对象和与流关联的读/写缓冲区。

If you are using some sort of custom stream that just reads/writes to memory, not to files, then there would be no file handle involved and you would just be limited by the memory consumed by the stream objects and their buffers.如果您正在使用某种自定义流,它只是读取/写入内存,而不是文件,那么将不涉及文件句柄,并且您只会受到流对象及其缓冲区消耗的内存的限制。 You could likely have thousands of these with no issues.你可能有成千上万的这些没有问题。

Some reference posts:一些参考帖子:

Node.js and open files limit in linux linux中的Node.js和打开文件限制

How do I change the number of open files limit in Linux? 如何更改 Linux 中打开文件的数量限制?

Check the open FD limit for a given process in Linux 检查 Linux 中给定进程的开放 FD 限制

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

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