New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mosquitto 1.5.1 becomes unresponsive after max open files is exceeded #948
Comments
Try to compile with the option WITH_EPOLL=no in order to clarify the cause. |
I expected to get the same behavior back without EPOLL ('access denied by tcpd'), but the behavior is actually the same (it does to 100% CPU when max open files is exceeded). Probably error handling is missing when opening a socket, and it retries? My point about a config directive is that Mosquitto needs to be aware of max open files; to to give useful log messages and instructions/documentation to the user. Take Nginx, which really has been engineered for this. It has |
Thanks. Understood that EPOLL was not the cause. |
p.s. |
Adding |
I agree that mosquitto should give you a better error message if it can detect that it was out of files, but I don't think it's any of mosquitto's business to go around validating ulimits vs connection settings of it's own. Mosquitto should limit itself to what it's been configured to do, but what the external container rules are are none of it's concern. Certainly, simply disabling ulimits wholesale in init scripts goes against the entire purpose of ulimits. |
I am at the side of @karlp . Mosquitto's behavior after max open files is an issue. But it is minor because setting max_connections properly becomes the remedy for @wiebeytec 's concern. |
I disagree. What if you want to service 2000 clients with the default Mosquitto init script? You just can't without hacking then. Setting the |
@wiebeytec , could you clarify what you insist now on this issue?
Thereby I will add labels on this issue, although I'm afraid I cannot promise fixing. |
@wiebeytec methods of customizing init scripts is simply out of scope. By all means distro packaging should make it easy to set ulimits, but mosquitto shouldn't be trying to circumvent distro mechanisms for setting ulimits (and cgroups and all other system wide limits and restrictions) |
@toast-uz the bug is that Mosquitto crashes to 100% CPU when you exceed your open file limit. It should detect this, and present the user with log messages, otherwise it's mysterious behavior. Whether or not to also implement As for the ulimits: the Mosquitto debs do provide an init script, which is where ulimit needs to be set based on something configurable (like |
@wiebeytec what I mean is, take that up with debian packaging, it's out of scope of mosquitto itself. Of course your distro should let you change these settings, I'm certainly not saying that. |
But the deb, and init scripts, is provide by the Mosquitto authors here, albeit outdated at the moment. |
@wiebeytec , thanks. I've labeled. |
It's interesting that there is this different behaviour. The difference you're seeing is down to compiling with
If we have
I've replicated this behaviour by keeping a spare socket around in case of fd exhaustion. If I get EMFILE when trying to accept(), then I close the spare socket, accept the incoming connection, close the incoming connection, then reopen my spare socket ready for the next time. |
Could you take a look and close this if you're happy? |
So the builds provided by the Mosquitto deb repo do have tcp wrapping? What is the reasoning behind it? I do know that 1.5.1 (built from source) has significantly higher performance than the pre-built 1.4 release. Connecting thousands of idle clients took 50% CPU with Mosquitto 1.4. With 1.5.1, it's about 5%. E_POLL is faster, obviously, but is TCP wrapping likely also detrimental to performance? |
The tcp wrappers library is just a different mechanism for allowing/denying access with /etc/hosts.allow and /etc/hosts.deny. It only comes into play when a new connection is made, so unless you have a high reconnection rate it shouldn't have any impact on performance. |
… limit. Closes #948. Thanks to wiebeytec.
Mosquitto 1.4.15 would give 'access denied by tcpd' or something when you exceed the maximum open files (
ulimit -n
). Mosquitto 1.5(.1) seems to have the same limit, but no such log message appears. Instead, it jumps to 100% CPU and messages aren't getting through anymore. The threshold is quite sudden, from almost no CPU to a lot. Is it related to the E_POLL change?I used this test script:
Without publishing, you can see a jump to 100% CPU. If you make 950 subscribers (with the default file limit of 1024), there is very little CPU.
To still test publishing (just an example):
(my user is admin, so I see all publishes)
Open file limit exhaustion may need to be dealt with more gracefully, but also the ulimit may need to be set better. Perhaps the process can increase it (based on a config) before switching to user
mosquitto
? I currently had to hack the init script (also for 1.4.15), and set it in Supervisor (I run two daemons).The text was updated successfully, but these errors were encountered: