Open-sourcing periodic upstream server resolution and implementing a dedicated service worker.
Vladimir Kokshenev
V.Kokshenev at F5.com
Fri Jul 22 00:42:15 UTC 2022
Hi Neil
Thank you for sharing your perspectives.
TTL-based DNS re-resolving is planned for this feature.
Also, nginx resolver (which we plan to use) supports "ipv6=off" and
(since 1.23.1) "ipv4=off" parameters for cases when IPv6 or IPv4 addresses
are not desired.
We know about solutions based on Lua. However, the motivation is to provide
a solution that works out of the box.
--
Vladimir Kokshenev
On 7/21/22, 6:02 AM, "Neil Craig" <Neil.Craig at bbc.co.uk> wrote:
EXTERNAL MAIL: Neil.Craig at bbc.co.uk
Hi Vladimir
I hope you don't mind me chipping in here.
We currently have 2 services which use Nginx with upstreams whose DNS can change frequently (e.g. AWS S3, ELB/ALB origins) so we're familiar with this problem. Initially we did a config reload every minute to solve the issue but since then, we've created custom Lua (using the OpenResty Lua module) to achieve the same thing in a more efficient way.
What you're proposing sounds great to me. I wanted to suggest a few feature ideas for your consideration:
* DNS TTL-based refresh (rather than refreshing every N seconds)
* DNS prefresh (update DNS when the elapsed time since the last refresh is perhaps 90% of the TTL)
* IPv4/6 ignore (useful for example when there's a v6 IP available but the system/network doesn't support v6)
Cheers
Neil Craig (He/Him)
Lead Architect, BBC Digital Distribution
On 20/07/2022, 20:09, "Vladimir Kokshenev via nginx-devel" <nginx-devel at nginx.org> wrote:
Hello!
This is the two-part proposal to open-source periodic upstream server resolution
and implement a dedicated service worker for nginx. The purpose of this e-mail
is to describe the WHY and solicit feedback.
Nginx supports domain names in the upstream server configuration.
Currently, domain names are resolved at configuration time only,
and there are no subsequent name resolutions.
There are plans to open-source re-resolvable upstream servers.
This will allow applying DNS updates to upstream configurations in runtime.
So, there is a need to support periodic asynchronous operations.
And a dedicated service worker is a possible architectural way to address this.
The master process reads and parses configuration and creates the service worker
when needed (in a similar way to cache-related processes).
The service worker manages periodic name resolutions and updates corresponding
upstream configurations. The name resolution relies on the existing nginx
resolver and upstream zone functionality.
The service worker will be responsible solely for periodic background tasks
and wouldn't accept client connections.
The service worker should be the last worker process to shut down
to maintain the actual state of upstreams when there are active workers.
Alternative architecture considered was about choosing one of the regular
workers (e.g., worker zero) to take care of periodic upstream server resolution,
but it creates asymmetry in responsibilities and load for this dedicated worker.
--
Vladimir Kokshenev
_______________________________________________
nginx-devel mailing list -- nginx-devel at nginx.org
To unsubscribe send an email to nginx-devel-leave at nginx.org
More information about the nginx-devel
mailing list