Welcome! Log In Create A New Profile

Advanced

Re: Behavior of nginx on Allocation Failure

Maxim Dounin
June 15, 2022 08:30PM
Hello!

On Tue, Jun 14, 2022 at 09:11:32PM -0700, Colin wrote:

> I'm interested in how nginx performs when close to/at memory limits, but
> haven't been able to find answers to a couple of things. Mainly: Does nginx
> usually treat allocation failures as recoverable, or fatal? I know
> ngx_alloc fires an emergency-level error on failure, but I'm curious about
> how nginx usually behaves afterwards.
>
> More generally, does nginx make any guarantees about behavior when
> allocations fail? I've looked at the memory management API but if I've
> missed any other documentation that answers these questions, feel free to
> just link me to it.

In nginx, allocation errors are properly handled according to the
particular place where the error happens. For example, if an
error happens during nginx startup - it is not possible to do
anything, so nginx will simply exit with an error. If an error
happens while handling a request, nginx will respond with error
500 (Internal Server Error) if possible and close the connection.
That is, as long as nginx is started, it is expected to work even
if some memory allocations fail (though will drop some requests /
connections).

Note though that proper handling might not apply to 3rd party
libraries being used. For example, Perl calls abort() on
allocation failures, so one certainly shouldn't rely on nginx with
embedded Perl being used in memory-constrained environments.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

Behavior of nginx on Allocation Failure

Colin June 15, 2022 12:12AM

Re: Behavior of nginx on Allocation Failure

Maxim Dounin June 15, 2022 08:30PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 119
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready