winstonjs / winston

A logger for just about everything.
http://github.com/winstonjs/winston
MIT License
22.37k stars 1.8k forks source link

[Question]: Winston seems to be opening 11 file descriptors per transport in Linux distributions. #2087

Open kencrimavx opened 2 years ago

kencrimavx commented 2 years ago

🔎 Search Terms

File Descriptors, Linux, Threads, Workers

The problem

WinstonJS Version: 3.3.3 NodeJS Version: 14.16.0 Linux Distribution: Ubuntu 18.04.3 LTS (Bionic Beaver)

When we instantiate a logger on an OSX machine, we see one file descriptor per transport, as expected, but in Linux environments, we're seeing 11 per transport. We're curious whether it's an issue on our end, or a part of Winston's implementation. Our use case involves a large number of worker threads being spun up, each with its own instance of Winston, so the multiplicative file descriptors presents something of an issue for us. Is there anything that can be done to configure this?

What version of Winston presents the issue?

3.3.3

What version of Node are you using?

14.16.0

If this worked in a previous version of Winston, which was it?

No response

Minimum Working Example

Logger code:

const { createLogger, format, transports } = require('winston');
const logger = createLogger({
  transports: [
    new transports.File({ level: 'info', dirName: '/var/log', filename: 'testlog.log' })
  ]
});

LSOF Command lsof | grep "testlog" | wc -l // 11 Results once './logger' has been required

We ran it on an AWS EC2 T2 Micro, if that makes any difference.

Additional information

No response

wbt commented 2 years ago

Is it actually 11, or are you reporting that number because the default report comes out once when the number exceeds a default threshold of 10?

kencrimavx commented 2 years ago

It's specifically 11, I believe. We saw 11/transport in our prod env, so we spun up an additional instance with only Winston installed to validate.