granian icon indicating copy to clipboard operation
granian copied to clipboard

Maximum number of open files

Open mindflayer opened this issue 1 year ago • 5 comments

It'd be great if we had a way to set the max number of file descriptors. See for instance the uWSGI setting for it: https://uwsgi-docs.readthedocs.io/en/latest/Options.html#max-fd

mindflayer avatar Aug 22 '24 09:08 mindflayer

It'd be great if we had a way to set the max number of file descriptors.

I'm not sure complicating Granian code to manage system related stuff is a good idea. What prevents you from using the relevant system configuration utilities for this (like sysctl and ulimit, or some supervisors)?

gi0baro avatar Aug 22 '24 10:08 gi0baro

Of course it's something I could fix in a different way. I've just changed the command with the prefix prlimit -n=8192 to set it at the process level.

It's worth mentioning I thought it was a simple change, and I believe it's a nice setting to have. Why did I think it was simple? Because in Python there is a simple way to play with resources: https://docs.python.org/3/library/resource.html.

The main reason for it would be not depending on external packages/commands. In the end ulimit values are usually specific to the application I am running, and I love to keep all the settings for an application in the same place.

mindflayer avatar Aug 22 '24 11:08 mindflayer

This said, feel free to close the issue if it's outside the scope of granian, and kudos for what you achieved.

mindflayer avatar Aug 22 '24 11:08 mindflayer

It's worth mentioning I thought it was a simple change, and I believe it's a nice setting to have. Why did I think it was simple? Because in Python there is a simple way to play with resources: https://docs.python.org/3/library/resource.html.

AFAIK, resource is available in Unix only, whereas Granian also supports Windows. Also I'm not sure about the implications of those limits with child processes, given that's the actual Granian implementation for workers.

That being said, I'm not completely against some limits features in Granian, as soon as the implementation is clearly documented (an option might be to describe those parameters are Unix-available only and warn the users in other cases). In the end: right now I don't have time to invest on this given the current priorities, but I'm willing to review PRs in this direction.

gi0baro avatar Aug 22 '24 12:08 gi0baro

I am against this as well. This is not Granian's problem and Granian shouldn't spend maintenance efforts to align with all available ways to detect and modify file descriptors on various OSes.

winstxnhdw avatar Nov 28 '24 11:11 winstxnhdw